SpoofDPI/dns/resolver/system.go

29 lines
488 B
Go
Raw Normal View History

2024-08-19 02:00:26 +00:00
package resolver
2024-08-18 07:11:04 +00:00
import (
"context"
"net"
)
type SystemResolver struct {
*net.Resolver
}
func NewSystemResolver() *SystemResolver {
2024-08-18 07:11:04 +00:00
return &SystemResolver{
&net.Resolver{PreferGo: true},
}
}
func (r *SystemResolver) String() string {
2024-08-18 07:33:02 +00:00
return "system resolver"
2024-08-18 07:11:04 +00:00
}
2024-08-18 09:51:20 +00:00
func (r *SystemResolver) Resolve(ctx context.Context, host string, _ []uint16) ([]net.IPAddr, error) {
2024-08-18 07:11:04 +00:00
addrs, err := r.LookupIPAddr(ctx, host)
if err != nil {
return []net.IPAddr{}, err
}
return addrs, nil
}