From f93dd6052e2f898a1925ab19f69ffd9bee138456 Mon Sep 17 00:00:00 2001 From: Skyxim Date: Mon, 11 Jul 2022 22:05:37 +0800 Subject: [PATCH] fix: default nameserver cannot use non-standard port of doh --- config/config.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index bb67000b..02c691c0 100644 --- a/config/config.go +++ b/config/config.go @@ -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") } }