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 <andrew@du.nham.ca>
Change-Id: Ie8d4fb93df96da910fae49ae71bf3e402b9fdecc
This commit is contained in:
Andrew Dunham 2023-03-02 22:42:45 -05:00
parent ef6f66bb9a
commit 27575cd52d

View File

@ -87,6 +87,7 @@ type nameIP struct {
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
}