fix: parse error

This commit is contained in:
Skyxim 2023-01-28 16:09:14 +08:00
parent a06b387acc
commit 2cf66f41cb

View File

@ -841,15 +841,14 @@ func parseHosts(cfg *RawConfig) (*trie.DomainTrie[netip.Addr], error) {
func hostWithDefaultPort(host string, defPort string) (string, error) {
hostname, port, err := net.SplitHostPort(host)
if err != nil&&!strings.Contains(err.Error(),"missing port in address") {
if err != nil {
if !strings.Contains(err.Error(), "missing port in address") {
return "", err
}
if port == "" {
port = defPort
host = host + ":" + defPort
if hostname, port, err = net.SplitHostPort(host); err != nil {
return "", err
}
if hostname==""{
hostname=host
}
return net.JoinHostPort(hostname, port), nil