diff --git a/config/config.go b/config/config.go index 498b069f..d71fc63f 100644 --- a/config/config.go +++ b/config/config.go @@ -890,29 +890,24 @@ func parseNameServer(servers []string, preferH3 bool) ([]dns.NameServer, error) addr, err = hostWithDefaultPort(u.Host, "853") dnsNetType = "tcp-tls" // DNS over TLS case "https": - host := u.Host - proxyAdapter = "" - if _, _, err := net.SplitHostPort(host); err != nil && strings.Contains(err.Error(), "missing port in address") { - host = net.JoinHostPort(host, "443") - } else { - if err != nil { - return nil, err - } - } - clearURL := url.URL{Scheme: "https", Host: host, Path: u.Path} - addr = clearURL.String() - dnsNetType = "https" // DNS over HTTPS - if len(u.Fragment) != 0 { - for _, s := range strings.Split(u.Fragment, "&") { - arr := strings.Split(s, "=") - if len(arr) == 0 { - continue - } else if len(arr) == 1 { - proxyAdapter = arr[0] - } else if len(arr) == 2 { - params[arr[0]] = arr[1] - } else { - params[arr[0]] = strings.Join(arr[1:], "=") + addr, err = hostWithDefaultPort(u.Host, "443") + if err == nil { + proxyAdapter = "" + clearURL := url.URL{Scheme: "https", Host: addr, Path: u.Path} + addr = clearURL.String() + dnsNetType = "https" // DNS over HTTPS + if len(u.Fragment) != 0 { + for _, s := range strings.Split(u.Fragment, "&") { + arr := strings.Split(s, "=") + if len(arr) == 0 { + continue + } else if len(arr) == 1 { + proxyAdapter = arr[0] + } else if len(arr) == 2 { + params[arr[0]] = arr[1] + } else { + params[arr[0]] = strings.Join(arr[1:], "=") + } } } }