Browse Source

Fix HTTPUpgrade init

风扇滑翔翼 1 year ago
parent
commit
021868afca
2 changed files with 13 additions and 0 deletions
  1. 2 0
      transport/internet/config.go
  2. 11 0
      transport/internet/httpupgrade/config.go

+ 2 - 0
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 {

+ 11 - 0
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)
+	}))
+}