From 107613f0f6bf291b61a47bc0e2871d855767f4bd Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Tue, 15 Aug 2023 09:10:41 +0800 Subject: [PATCH] Improve: nicer tun info for RESTful api Let the restful api still get TunConf even when tun is off. Otherwise the api will return the default values, instead of the values that actually take effect after enable. * Due to this problem, yacd changes the displayed value back to gvisor immediately after the user selects tun stack. --- hub/executor/executor.go | 2 +- listener/listener.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/hub/executor/executor.go b/hub/executor/executor.go index f4cda47a..6d542f60 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -129,7 +129,7 @@ func GetGeneral() *config.General { RedirPort: ports.RedirPort, TProxyPort: ports.TProxyPort, MixedPort: ports.MixedPort, - Tun: listener.GetTunConf(), + Tun: listener.LastTunConf, TuicServer: listener.GetTuicConf(), ShadowSocksConfig: ports.ShadowSocksConfig, VmessConfig: ports.VmessConfig, diff --git a/listener/listener.go b/listener/listener.go index 8f0088db..7b513fa7 100644 --- a/listener/listener.go +++ b/listener/listener.go @@ -516,6 +516,7 @@ func ReCreateTun(tunConf LC.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- C.Pack defer func() { if err != nil { log.Errorln("Start TUN listening error: %s", err.Error()) + tunConf.Enable = false Cleanup(false) } }()