diff --git a/config/utils.go b/config/utils.go index 2c470618..799082c4 100644 --- a/config/utils.go +++ b/config/utils.go @@ -3,6 +3,7 @@ package config import ( "fmt" "net" + "net/netip" "strings" "github.com/Dreamacro/clash/adapter/outboundgroup" @@ -149,20 +150,11 @@ func proxyGroupsDagSort(groupsConfig []map[string]any) error { } func verifyIP6() bool { - addrs, err := net.InterfaceAddrs() - if err != nil { - return false - } - for _, addr := range addrs { - ipNet, isIpNet := addr.(*net.IPNet) - if isIpNet && !ipNet.IP.IsLoopback() { - if ipNet.IP.To16() != nil { - s := ipNet.IP.String() - for i := 0; i < len(s); i++ { - switch s[i] { - case ':': - return true - } + if iAddrs, err := net.InterfaceAddrs(); err == nil { + for _, addr := range iAddrs { + if prefix, err := netip.ParsePrefix(addr.String()); err == nil { + if addr := prefix.Addr().Unmap(); addr.Is6() && addr.IsGlobalUnicast() { + return true } } }