From f7acbfb3b6ccd7ca1bd93950eebaa0eecfc36924 Mon Sep 17 00:00:00 2001 From: 5aaee9 <7685264+5aaee9@users.noreply.github.com> Date: Tue, 21 May 2024 18:03:49 +0800 Subject: [PATCH] fix(tun/darwin): calculate correct tunIndex --- listener/sing_tun/server.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/listener/sing_tun/server.go b/listener/sing_tun/server.go index 2dc6524e..b1be5dfb 100644 --- a/listener/sing_tun/server.go +++ b/listener/sing_tun/server.go @@ -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 + } } } }