Skip to content

Commit

Permalink
better tun config passing
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Nov 3, 2022
1 parent dc44598 commit a92438b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion adapter/provider/healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (hc *HealthCheck) lazyCheck() bool {
hc.check()
return true
} else {
log.Infoln("Skip once health check because we are lazy (%s)", hc.gName)
log.Debugln("Skip once health check because we are lazy (%s)", hc.gName)
return false
}
}
Expand Down
2 changes: 1 addition & 1 deletion hub/route/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func patchConfigs(w http.ResponseWriter, r *http.Request) {
P.ReCreateRedir(pointerOrDefault(general.RedirPort, ports.RedirPort), tcpIn, udpIn)
P.ReCreateTProxy(pointerOrDefault(general.TProxyPort, ports.TProxyPort), tcpIn, udpIn)
P.ReCreateMixed(pointerOrDefault(general.MixedPort, ports.MixedPort), tcpIn, udpIn)
P.ReCreateTun(pointerOrDefaultTun(general.Tun, P.Tun()), tcpIn, udpIn)
P.ReCreateTun(pointerOrDefaultTun(general.Tun, P.LastTunConf), tcpIn, udpIn)
P.ReCreateMixEC(pointerOrDefaultString(general.MixECConfig, ports.MixECConfig), tcpIn, udpIn)
P.ReCreateShadowSocks(pointerOrDefaultString(general.ShadowSocksConfig, ports.ShadowSocksConfig), tcpIn, udpIn)
P.ReCreateVmess(pointerOrDefaultString(general.VmessConfig, ports.VmessConfig), tcpIn, udpIn)
Expand Down
8 changes: 4 additions & 4 deletions listener/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ var (
udpTunMux sync.Mutex
mtpMux sync.Mutex

tunConfig config.Tun
LastTunConf config.Tun
)

type Ports struct {
Expand All @@ -80,7 +80,7 @@ type Ports struct {

func Tun() config.Tun {
if tunLister == nil {
return tunConfig
return LastTunConf
}
return tunLister.Config()
}
Expand Down Expand Up @@ -504,7 +504,7 @@ func ReCreateTun(conf config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbo
shouldIgnore := false

if tunLister != nil {
if tunLister.Config().String() != conf.String() {
if LastTunConf.String() != conf.String() {
tunLister.Close()
tunLister = nil
} else {
Expand All @@ -517,7 +517,7 @@ func ReCreateTun(conf config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbo
return
}

tunConfig = conf
LastTunConf = conf

generalInterface := dialer.GeneralInterface.Load()
defaultInterface := dialer.DefaultInterface.Load()
Expand Down
1 change: 1 addition & 0 deletions listener/sing_tun/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func New(options config.Tun, tcpIn chan<- C.ConnContext, udpIn chan<- *inbound.P
tunName := options.InterfaceName
if tunName == "" {
tunName = tun.CalculateInterfaceName(InterfaceName)
options.InterfaceName = tunName
}
tunMTU := options.MTU
if tunMTU == 0 {
Expand Down

0 comments on commit a92438b

Please sign in to comment.