mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2024-11-16 03:32:33 +08:00
fix: parse error
This commit is contained in:
parent
a06b387acc
commit
2cf66f41cb
|
@ -4,7 +4,7 @@ import (
|
|||
"container/list"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net"
|
||||
"net/netip"
|
||||
"net/url"
|
||||
"os"
|
||||
|
@ -841,17 +841,16 @@ 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") {
|
||||
return "", err
|
||||
if err != nil {
|
||||
if !strings.Contains(err.Error(), "missing port in address") {
|
||||
return "", err
|
||||
}
|
||||
host = host + ":" + defPort
|
||||
if hostname, port, err = net.SplitHostPort(host); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
||||
if port == "" {
|
||||
port = defPort
|
||||
}
|
||||
if hostname==""{
|
||||
hostname=host
|
||||
}
|
||||
|
||||
return net.JoinHostPort(hostname, port), nil
|
||||
}
|
||||
|
||||
|
@ -940,17 +939,17 @@ func parsePureDNSServer(server string) string {
|
|||
return "udp://" + server
|
||||
}
|
||||
|
||||
if ip,err := netip.ParseAddr(server); err != nil {
|
||||
if ip, err := netip.ParseAddr(server); err != nil {
|
||||
if strings.Contains(server, "://") {
|
||||
return server
|
||||
}
|
||||
return addPre(server)
|
||||
return addPre(server)
|
||||
} else {
|
||||
if ip.Is4(){
|
||||
return addPre(server)
|
||||
}else{
|
||||
return addPre("["+server+"]")
|
||||
}
|
||||
if ip.Is4() {
|
||||
return addPre(server)
|
||||
} else {
|
||||
return addPre("[" + server + "]")
|
||||
}
|
||||
}
|
||||
}
|
||||
func parseNameServerPolicy(nsPolicy map[string]string, preferH3 bool) (map[string]dns.NameServer, error) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user