fix: default nameserver cannot use non-standard port of doh

This commit is contained in:
Skyxim 2022-07-11 22:05:37 +08:00
parent 0c64d7e56a
commit f93dd6052e

View file

@ -817,7 +817,11 @@ func parseDNS(rawCfg *RawConfig, hosts *trie.DomainTrie[netip.Addr], rules []C.R
host, _, err := net.SplitHostPort(ns.Addr)
if err != nil || net.ParseIP(host) == nil {
u, err := url.Parse(ns.Addr)
if err != nil || net.ParseIP(u.Host) == nil {
if err == nil {
if ip, _, err := net.SplitHostPort(u.Host); err != nil || net.ParseIP(ip) == nil {
return nil, errors.New("default nameserver should be pure IP")
}
} else {
return nil, errors.New("default nameserver should be pure IP")
}
}