mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-04-24 20:28:11 +08:00
fix: parse error
This commit is contained in:
parent
a06b387acc
commit
2cf66f41cb
@ -841,15 +841,14 @@ func parseHosts(cfg *RawConfig) (*trie.DomainTrie[netip.Addr], error) {
|
|||||||
|
|
||||||
func hostWithDefaultPort(host string, defPort string) (string, error) {
|
func hostWithDefaultPort(host string, defPort string) (string, error) {
|
||||||
hostname, port, err := net.SplitHostPort(host)
|
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
|
return "", err
|
||||||
}
|
}
|
||||||
|
host = host + ":" + defPort
|
||||||
if port == "" {
|
if hostname, port, err = net.SplitHostPort(host); err != nil {
|
||||||
port = defPort
|
return "", err
|
||||||
}
|
}
|
||||||
if hostname==""{
|
|
||||||
hostname=host
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return net.JoinHostPort(hostname, port), nil
|
return net.JoinHostPort(hostname, port), nil
|
||||||
@ -940,16 +939,16 @@ func parsePureDNSServer(server string) string {
|
|||||||
return "udp://" + server
|
return "udp://" + server
|
||||||
}
|
}
|
||||||
|
|
||||||
if ip,err := netip.ParseAddr(server); err != nil {
|
if ip, err := netip.ParseAddr(server); err != nil {
|
||||||
if strings.Contains(server, "://") {
|
if strings.Contains(server, "://") {
|
||||||
return server
|
return server
|
||||||
}
|
}
|
||||||
return addPre(server)
|
return addPre(server)
|
||||||
} else {
|
} else {
|
||||||
if ip.Is4(){
|
if ip.Is4() {
|
||||||
return addPre(server)
|
return addPre(server)
|
||||||
}else{
|
} else {
|
||||||
return addPre("["+server+"]")
|
return addPre("[" + server + "]")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user