From b72bd5bb37977ef04886644afc62f742363252db Mon Sep 17 00:00:00 2001 From: Skyxim Date: Thu, 23 Feb 2023 14:13:27 +0800 Subject: [PATCH] chore: adjust the configuration loading order --- hub/executor/executor.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hub/executor/executor.go b/hub/executor/executor.go index ec6ee8ff..57a9ffe8 100644 --- a/hub/executor/executor.go +++ b/hub/executor/executor.go @@ -144,6 +144,10 @@ func updateListeners(general *config.General, listeners map[string]C.InboundList return } + if general.Interface == "" && (!general.Tun.Enable || !general.Tun.AutoDetectInterface) { + dialer.DefaultInterface.Store(general.Interface) + } + inbound.SetTfo(general.InboundTfo) allowLan := general.AllowLan listener.SetAllowLan(allowLan) @@ -339,9 +343,14 @@ func updateGeneral(general *config.General) { adapter.UnifiedDelay.Store(general.UnifiedDelay) // Avoid reload configuration clean the value, causing traffic loops - if general.Interface != "" && general.Tun.Enable && !general.Tun.AutoDetectInterface { + if listener.GetTunConf().Enable && listener.GetTunConf().AutoDetectInterface { + // changed only when the name is specified + // if name is empty, setting delay until after tun loaded + if general.Interface != "" && (!general.Tun.Enable || !general.Tun.AutoDetectInterface) { + dialer.DefaultInterface.Store(general.Interface) + } + } else { dialer.DefaultInterface.Store(general.Interface) - log.Infoln("Use interface name: %s", general.Interface) } dialer.DefaultRoutingMark.Store(int32(general.RoutingMark))