mirror of
https://github.com/MetaCubeX/Clash.Meta.git
synced 2025-04-18 08:20:53 +00:00
fix(tun/darwin): calculate correct tunIndex
This commit is contained in:
parent
3195c678c7
commit
f7acbfb3b6
1 changed files with 4 additions and 2 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue