From 55eecaed16175e7ff8055c6f7998c617012e13cc Mon Sep 17 00:00:00 2001 From: j2rong4cn <36783515+j2rong4cn@users.noreply.github.com> Date: Thu, 29 Oct 2026 16:34:16 +0800 Subject: [PATCH] Config: Move inbound module initialization to the end (#7284) Fixes https://github.com/XTLS/Xray-core/pull/7284#issuecomment-6491545028 --------- Co-authored-by: Copilot --- infra/conf/xray.go | 4 +++- infra/conf/xray_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/infra/conf/xray.go b/infra/conf/xray.go index 2a477b897..2c94ce55c 100644 --- a/infra/conf/xray.go +++ b/infra/conf/xray.go @@ -609,7 +609,6 @@ func (c *Config) Build() (*core.Config, error) { config := &core.Config{ App: []*serial.TypedMessage{ serial.ToTypedMessage(&dispatcher.Config{}), - serial.ToTypedMessage(&proxyman.InboundConfig{}), serial.ToTypedMessage(&proxyman.OutboundConfig{}), }, } @@ -719,6 +718,9 @@ func (c *Config) Build() (*core.Config, error) { config.App = append(config.App, serial.ToTypedMessage(r)) } + // Initialize the inbound module last to ensure inbound connections are handled correctly. + config.App = append(config.App, serial.ToTypedMessage(&proxyman.InboundConfig{})) + var inbounds []InboundDetourConfig if len(c.InboundConfigs) > 0 { diff --git a/infra/conf/xray_test.go b/infra/conf/xray_test.go index d4ff7126a..3b7fcddcd 100644 --- a/infra/conf/xray_test.go +++ b/infra/conf/xray_test.go @@ -90,7 +90,6 @@ func TestXrayConfig(t *testing.T) { AccessLogPath: "/var/log/xray/access.log", }), serial.ToTypedMessage(&dispatcher.Config{}), - serial.ToTypedMessage(&proxyman.InboundConfig{}), serial.ToTypedMessage(&proxyman.OutboundConfig{}), serial.ToTypedMessage(&router.Config{ DomainStrategy: router.Config_AsIs, @@ -111,6 +110,7 @@ func TestXrayConfig(t *testing.T) { }, }, }), + serial.ToTypedMessage(&proxyman.InboundConfig{}), }, Inbound: []*core.InboundHandlerConfig{ {