net/dnsfallback: do not attempt lookups of IPs.

Currently if the passed in host is an IP, Lookup still attempts to
resolve it with a dns server. This makes it just return the IP directly.

Updates tailscale/corp#4475

Signed-off-by: Maisem Ali <maisem@tailscale.com>
This commit is contained in:
Maisem Ali 2022-03-24 22:21:41 -07:00 committed by Maisem Ali
parent b45bb577a0
commit b2f269d5b7

View File

@ -27,6 +27,10 @@
)
func Lookup(ctx context.Context, host string) ([]netaddr.IP, error) {
if ip, err := netaddr.ParseIP(host); err == nil && !ip.IsZero() {
return []netaddr.IP{ip}, nil
}
type nameIP struct {
dnsName string
ip netaddr.IP