mirror of
https://gitclone.com/github.com/MetaCubeX/Clash.Meta
synced 2025-02-23 20:52:15 +08:00
fix: a temporary solution for error reporting when enabling tun for devices that do not have an ipv6 environment.
This commit is contained in:
parent
654cdf3d5b
commit
cf5709aab1
@ -1289,6 +1289,10 @@ func parseTun(rawTun RawTun, general *General) error {
|
|||||||
}
|
}
|
||||||
tunAddressPrefix = netip.PrefixFrom(tunAddressPrefix.Addr(), 30)
|
tunAddressPrefix = netip.PrefixFrom(tunAddressPrefix.Addr(), 30)
|
||||||
|
|
||||||
|
if !general.IPv6 || !verifyIP6() {
|
||||||
|
rawTun.Inet6Address = nil
|
||||||
|
}
|
||||||
|
|
||||||
general.Tun = Tun{
|
general.Tun = Tun{
|
||||||
Enable: rawTun.Enable,
|
Enable: rawTun.Enable,
|
||||||
Device: rawTun.Device,
|
Device: rawTun.Device,
|
||||||
|
@ -2,6 +2,7 @@ package config
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/Dreamacro/clash/adapter/outboundgroup"
|
"github.com/Dreamacro/clash/adapter/outboundgroup"
|
||||||
@ -146,3 +147,25 @@ func proxyGroupsDagSort(groupsConfig []map[string]any) error {
|
|||||||
}
|
}
|
||||||
return fmt.Errorf("loop is detected in ProxyGroup, please check following ProxyGroups: %v", loopElements)
|
return fmt.Errorf("loop is detected in ProxyGroup, please check following ProxyGroups: %v", loopElements)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user