From 1b0d09068b746308de3b854e487c12c4ceac0871 Mon Sep 17 00:00:00 2001 From: adlyq Date: Thu, 3 Nov 2022 18:04:22 +0800 Subject: [PATCH] fix: RESTful API empty tun device name --- listener/listener.go | 2 +- listener/sing_tun/server.go | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/listener/listener.go b/listener/listener.go index d13093e3..2d95ed95 100644 --- a/listener/listener.go +++ b/listener/listener.go @@ -363,7 +363,7 @@ func ReCreateTun(tunConf *config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- * return } - tunLister, err = sing_tun.New(*tunConf, tcpIn, udpIn) + tunLister, err = sing_tun.New(tunConf, tcpIn, udpIn) } func ReCreateRedirToTun(ifaceNames []string) { diff --git a/listener/sing_tun/server.go b/listener/sing_tun/server.go index 83d38e28..23774683 100644 --- a/listener/sing_tun/server.go +++ b/listener/sing_tun/server.go @@ -65,10 +65,11 @@ func CalculateInterfaceName(name string) (tunName string) { return } -func New(options config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (l *Listener, err error) { +func New(options *config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.PacketAdapter) (l *Listener, err error) { tunName := options.Device if tunName == "" { tunName = CalculateInterfaceName(InterfaceName) + options.Device = tunName } tunMTU := options.MTU if tunMTU == 0 { @@ -121,7 +122,7 @@ func New(options config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.P } l = &Listener{ closed: false, - options: options, + options: *options, handler: handler, } defer func() {