fix(core): keep the system resolver fallback when no DNS servers are reported
An Android service with no DNS servers sends an empty list, which split into a single empty address that mihomo builds into a "udp://:" nameserver. The system resolver then counted it as configured and never fell back to its default nameservers, so lookups through it failed while the preferred network reported no DNS. Changelog: DNS lookups no longer fail on networks that report no DNS servers
This commit is contained in:
+7
-1
@@ -246,6 +246,12 @@ var (
|
||||
)
|
||||
|
||||
func handleUpdateDns(value string) {
|
||||
// mihomo turns the [""] that Split returns for no servers into a "udp://:"
|
||||
// nameserver, which keeps the system resolver off its default fallback.
|
||||
var addr []string
|
||||
if value != "" {
|
||||
addr = strings.Split(value, ",")
|
||||
}
|
||||
seq := dnsUpdateSeq.Add(1)
|
||||
safeGoDetached("updateDns", func() {
|
||||
dnsUpdateMu.Lock()
|
||||
@@ -254,7 +260,7 @@ func handleUpdateDns(value string) {
|
||||
return
|
||||
}
|
||||
log.Infoln("[DNS] updateDns %s", value)
|
||||
dns.UpdateSystemDNS(strings.Split(value, ","))
|
||||
dns.UpdateSystemDNS(addr)
|
||||
dns.FlushCacheWithDefaultResolver()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user