From b2f269d5b7bb04c226cf509c3794481ef4395519 Mon Sep 17 00:00:00 2001 From: Maisem Ali Date: Thu, 24 Mar 2022 22:21:41 -0700 Subject: [PATCH] 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 --- net/dnsfallback/dnsfallback.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/dnsfallback/dnsfallback.go b/net/dnsfallback/dnsfallback.go index 0e09861eb..20dc3be8c 100644 --- a/net/dnsfallback/dnsfallback.go +++ b/net/dnsfallback/dnsfallback.go @@ -27,6 +27,10 @@ import ( ) 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