fix(tun/darwin): calculate correct tunIndex

This commit is contained in:
5aaee9 2024-05-21 18:03:49 +08:00
parent 3195c678c7
commit f7acbfb3b6

View file

@ -59,12 +59,14 @@ func CalculateInterfaceName(name string) (tunName string) {
if err != nil {
return
}
var tunIndex int
var tunIndex int = 0
for _, netInterface := range interfaces {
if strings.HasPrefix(netInterface.Name, tunName) {
index, parseErr := strconv.ParseInt(netInterface.Name[len(tunName):], 10, 16)
if parseErr == nil {
tunIndex = int(index) + 1
if int(index)+1 > tunIndex {
tunIndex = int(index) + 1
}
}
}
}