Skip to content

Commit

Permalink
fix: new tun with fd unneeded calculate interface name
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Sep 11, 2024
1 parent 910f236 commit f305e44
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions listener/sing_tun/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis
options.AutoRedirect = false
}
tunName := options.Device
if tunName == "" || !checkTunName(tunName) {
if options.FileDescriptor == 0 && (tunName == "" || !checkTunName(tunName)) {
tunName = CalculateInterfaceName(InterfaceName)
options.Device = tunName
}
routeAddress := options.RouteAddress
if len(options.Inet4RouteAddress) > 0 {
Expand Down Expand Up @@ -440,6 +439,9 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis

//l.openAndroidHotspot(tunOptions)

if options.FileDescriptor != 0 {
tunName = fmt.Sprintf("%s(fd=%d)", tunName, options.FileDescriptor)
}
l.addrStr = fmt.Sprintf("%s(%s,%s), mtu: %d, auto route: %v, auto redir: %v, ip stack: %s",
tunName, tunOptions.Inet4Address, tunOptions.Inet6Address, tunMTU, options.AutoRoute, options.AutoRedirect, options.Stack)
return
Expand Down

0 comments on commit f305e44

Please sign in to comment.