fix: parsing ipv6 doh error

This commit is contained in:
Skyxim 2023-02-17 23:30:38 +08:00
parent d6ff5f7d96
commit 59cd89a9c9

View file

@ -890,16 +890,10 @@ func parseNameServer(servers []string, preferH3 bool) ([]dns.NameServer, error)
addr, err = hostWithDefaultPort(u.Host, "853") addr, err = hostWithDefaultPort(u.Host, "853")
dnsNetType = "tcp-tls" // DNS over TLS dnsNetType = "tcp-tls" // DNS over TLS
case "https": case "https":
host := u.Host addr, err = hostWithDefaultPort(u.Host, "443")
if err == nil {
proxyAdapter = "" proxyAdapter = ""
if _, _, err := net.SplitHostPort(host); err != nil && strings.Contains(err.Error(), "missing port in address") { clearURL := url.URL{Scheme: "https", Host: addr, Path: u.Path}
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() addr = clearURL.String()
dnsNetType = "https" // DNS over HTTPS dnsNetType = "https" // DNS over HTTPS
if len(u.Fragment) != 0 { if len(u.Fragment) != 0 {
@ -916,6 +910,7 @@ func parseNameServer(servers []string, preferH3 bool) ([]dns.NameServer, error)
} }
} }
} }
}
case "dhcp": case "dhcp":
addr = u.Host addr = u.Host
dnsNetType = "dhcp" // UDP from DHCP dnsNetType = "dhcp" // UDP from DHCP