Prefer LAN server answer over public one

While at it, also implementing new OS resolver chosing logic, keeping
only 2 LAN servers at any time, 1 for current one, and 1 for last used
one.
This commit is contained in:
Cuong Manh Le
2024-10-18 01:31:40 +07:00
committed by Cuong Manh Le
parent f87220a908
commit 0cdff0d368
4 changed files with 124 additions and 40 deletions
+2 -3
View File
@@ -1,9 +1,8 @@
package ctrld
import "net"
type dnsFn func() []string
// nameservers returns DNS nameservers from system settings.
func nameservers() []string {
var dns []string
seen := make(map[string]bool)
@@ -21,7 +20,7 @@ func nameservers() []string {
continue
}
seen[ns] = true
dns = append(dns, net.JoinHostPort(ns, "53"))
dns = append(dns, ns)
}
}