From cdc76f3ea7fd92945e1c777cecb0f846076d16a7 Mon Sep 17 00:00:00 2001 From: soypat Date: Sun, 7 Jan 2024 15:42:43 -0300 Subject: [PATCH] modify netif.Resolver to use net.DefaultResolver method set --- netif/netif.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/netif/netif.go b/netif/netif.go index 8b4f0b1..bde8ee9 100644 --- a/netif/netif.go +++ b/netif/netif.go @@ -1,6 +1,7 @@ package netif import ( + "context" "errors" "net" "net/netip" @@ -117,11 +118,13 @@ type Stack interface { SetSockOpt(sockfd int, level int, opt int, value interface{}) error } -// Should have UseResolver package level function that replaces the Go Resolver? +// Resolver is implemented by DNS resolvers, notably Go's [net.DefaultResolver]. type Resolver interface { - // GetHostByName returns the IP address of either a hostname or IPv4 - // address in standard dot notation - GetHostByName(name string) (netip.Addr, error) + // LookupNetIP looks up host using the local resolver. + // It returns a slice of that host's IP addresses of the type specified by + // network. + // The network must be one of "ip", "ip4" or "ip6". + LookupNetIP(ctx context.Context, network, host string) ([]netip.Addr, error) } // StackWifi is returned by `Probe` function for devices that communicate