mirror of
https://github.com/xjasonlyu/tun2socks.git
synced 2025-10-06 09:16:58 +08:00
Improve: use interface index for macos
This commit is contained in:
@@ -3,6 +3,7 @@ package engine
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
"github.com/xjasonlyu/tun2socks/v2/component/dialer"
|
||||
@@ -97,7 +98,12 @@ func general(k *Key) error {
|
||||
log.SetLevel(level)
|
||||
|
||||
if k.Interface != "" {
|
||||
dialer.DefaultInterfaceName.Store(k.Interface)
|
||||
iface, err := net.InterfaceByName(k.Interface)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dialer.DefaultInterfaceName.Store(iface.Name)
|
||||
dialer.DefaultInterfaceIndex.Store(int32(iface.Index))
|
||||
log.Infof("[DIALER] bind to interface: %s", k.Interface)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user