From 021868afcaa93ea94fed323782807ce4232fef57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=8E=E6=89=87=E6=BB=91=E7=BF=94=E7=BF=BC?= <45535409+Fangliding@users.noreply.github.com> Date: Sun, 7 Apr 2024 15:53:34 +0000 Subject: [PATCH] Fix HTTPUpgrade init --- transport/internet/config.go | 2 ++ transport/internet/httpupgrade/config.go | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/transport/internet/config.go b/transport/internet/config.go index a2091f5c..dc0b95e5 100644 --- a/transport/internet/config.go +++ b/transport/internet/config.go @@ -58,6 +58,8 @@ func RegisterProtocolConfigCreator(name string, creator ConfigCreator) error { return nil } +// Note: Each new transport needs to add init() func in transport/internet/xxx/config.go +// Otherwise, it will cause #3244 func CreateTransportConfig(name string) (interface{}, error) { creator, ok := globalTransportConfigCreatorCache[name] if !ok { diff --git a/transport/internet/httpupgrade/config.go b/transport/internet/httpupgrade/config.go index 21841bfd..3404930e 100644 --- a/transport/internet/httpupgrade/config.go +++ b/transport/internet/httpupgrade/config.go @@ -1,5 +1,10 @@ package httpupgrade +import ( + "github.com/xtls/xray-core/common" + "github.com/xtls/xray-core/transport/internet" +) + func (c *Config) GetNormalizedPath() string { path := c.Path if path == "" { @@ -10,3 +15,9 @@ func (c *Config) GetNormalizedPath() string { } return path } + +func init() { + common.Must(internet.RegisterProtocolConfigCreator(protocolName, func() interface{} { + return new(Config) + })) +}