all: fix OS resolver looping issue on Windows

By making dnsFromAdapter ignores DNS server which is the same IP address
of the adapter.

While at it, also changes OS resolver to use ctrld bootstrap DNS only if
there's no available nameservers.
This commit is contained in:
Cuong Manh Le
2024-05-22 18:17:20 +07:00
committed by Cuong Manh Le
parent 96085147ff
commit 19020a96bf
3 changed files with 32 additions and 33 deletions
+5 -2
View File
@@ -39,10 +39,13 @@ var OsNameservers = defaultNameservers()
// or is the Resolver used for ResolverTypeOS.
var or = &osResolver{nameservers: OsNameservers}
// defaultNameservers returns OS nameservers plus ctrld bootstrap nameserver.
// defaultNameservers returns nameservers used by the OS.
// If no nameservers can be found, ctrld bootstrap nameserver will be used.
func defaultNameservers() []string {
ns := nameservers()
ns = append(ns, net.JoinHostPort(bootstrapDNS, "53"))
if len(ns) == 0 {
ns = append(ns, net.JoinHostPort(bootstrapDNS, "53"))
}
return ns
}