chore: rewrite verifyIP6
This commit is contained in:
parent
47df97322d
commit
4ef99294e7
1 changed files with 6 additions and 14 deletions
|
@ -3,6 +3,7 @@ package config
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"net/netip"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Dreamacro/clash/adapter/outboundgroup"
|
"github.com/Dreamacro/clash/adapter/outboundgroup"
|
||||||
|
@ -149,20 +150,11 @@ func proxyGroupsDagSort(groupsConfig []map[string]any) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyIP6() bool {
|
func verifyIP6() bool {
|
||||||
addrs, err := net.InterfaceAddrs()
|
if iAddrs, err := net.InterfaceAddrs(); err == nil {
|
||||||
if err != nil {
|
for _, addr := range iAddrs {
|
||||||
return false
|
if prefix, err := netip.ParsePrefix(addr.String()); err == nil {
|
||||||
}
|
if addr := prefix.Addr().Unmap(); addr.Is6() && addr.IsGlobalUnicast() {
|
||||||
for _, addr := range addrs {
|
return true
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue