mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
chore: Remove default DNS in system resolver
This commit is contained in:
parent
f35ff24d0c
commit
969c235490
|
@ -1144,6 +1144,9 @@ func parseDNS(rawCfg *RawConfig, hosts *trie.DomainTrie[resolver.HostValue], rul
|
|||
}
|
||||
// check default nameserver is pure ip addr
|
||||
for _, ns := range dnsCfg.DefaultNameserver {
|
||||
if ns.Net == "system" {
|
||||
continue
|
||||
}
|
||||
host, _, err := net.SplitHostPort(ns.Addr)
|
||||
if err != nil || net.ParseIP(host) == nil {
|
||||
u, err := url.Parse(ns.Addr)
|
||||
|
|
|
@ -12,10 +12,6 @@ import (
|
|||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultNS = []string{"114.114.114.114:53"}
|
||||
)
|
||||
|
||||
type dnsConfig struct {
|
||||
servers []string // server addresses (in host:port form) to use
|
||||
}
|
||||
|
@ -27,7 +23,6 @@ func loadSystemResolver() (clients []dnsClient, err error) {
|
|||
}
|
||||
nameservers := content.servers
|
||||
if len(nameservers) == 0 {
|
||||
err = fmt.Errorf("no nameserver found in windows system")
|
||||
return
|
||||
}
|
||||
servers := make([]NameServer, 0, len(nameservers))
|
||||
|
@ -42,11 +37,6 @@ func loadSystemResolver() (clients []dnsClient, err error) {
|
|||
|
||||
func dnsReadConfig() (conf *dnsConfig, err error) {
|
||||
conf = &dnsConfig{}
|
||||
defer func() {
|
||||
if len(conf.servers) == 0 {
|
||||
conf.servers = defaultNS
|
||||
}
|
||||
}()
|
||||
aas, err := adapterAddresses()
|
||||
if err != nil {
|
||||
return conf, err
|
||||
|
|
|
@ -82,7 +82,11 @@ func transform(servers []NameServer, resolver *Resolver) []dnsClient {
|
|||
case "system":
|
||||
clients, err := loadSystemResolver()
|
||||
if err != nil {
|
||||
log.Warnln("[DNS:system] load system resolver failed: %s", err.Error())
|
||||
log.Errorln("[DNS:system] load system resolver failed: %s", err.Error())
|
||||
continue
|
||||
}
|
||||
if len(clients) == 0 {
|
||||
log.Errorln("[DNS:system] no nameserver found in system")
|
||||
continue
|
||||
}
|
||||
ret = append(ret, clients...)
|
||||
|
|
|
@ -177,7 +177,7 @@ dns:
|
|||
- 8.8.8.8
|
||||
- tls://1.12.12.12:853
|
||||
- tls://223.5.5.5:853
|
||||
- system:// # get DNS server from system's configuration
|
||||
- system:// # append DNS server from system configuration. If not found, it would print an error log and skip.
|
||||
enhanced-mode: fake-ip # or redir-host
|
||||
|
||||
fake-ip-range: 198.18.0.1/16 # fake-ip 池设置
|
||||
|
|
Loading…
Reference in New Issue
Block a user