From 27575cd52d78f90c89f119343e9fbba578d96495 Mon Sep 17 00:00:00 2001 From: Andrew Dunham Date: Thu, 2 Mar 2023 22:42:45 -0500 Subject: [PATCH] net/dnsfallback: shuffle returned IPs This ensures that we're trying multiple returned IPs, since the DERP servers return the same response to all queries. This should increase the chances that we eventually reach a working IP. Signed-off-by: Andrew Dunham Change-Id: Ie8d4fb93df96da910fae49ae71bf3e402b9fdecc --- net/dnsfallback/dnsfallback.go | 1 + 1 file changed, 1 insertion(+) diff --git a/net/dnsfallback/dnsfallback.go b/net/dnsfallback/dnsfallback.go index ed45e77b1..175a74b53 100644 --- a/net/dnsfallback/dnsfallback.go +++ b/net/dnsfallback/dnsfallback.go @@ -87,6 +87,7 @@ func Lookup(ctx context.Context, host string) ([]netip.Addr, error) { continue } if ips := dm[host]; len(ips) > 0 { + rand.Shuffle(len(ips), func(i, j int) { ips[i], ips[j] = ips[j], ips[i] }) logf("bootstrapDNS(%q, %q) for %q = %v", cand.dnsName, cand.ip, host, ips) return ips, nil }