Browse Source

add auto register for transport

Shelikhoo 4 years ago
parent
commit
40db658135
1 changed files with 6 additions and 0 deletions
  1. 6 0
      transport/internet/config.go

+ 6 - 0
transport/internet/config.go

@@ -1,6 +1,8 @@
 package internet
 
 import (
+	"context"
+	"github.com/v2fly/v2ray-core/v4/common"
 	"github.com/v2fly/v2ray-core/v4/common/serial"
 	"github.com/v2fly/v2ray-core/v4/features"
 )
@@ -38,6 +40,10 @@ func RegisterProtocolConfigCreator(name string, creator ConfigCreator) error {
 		return newError("protocol ", name, " is already registered").AtError()
 	}
 	globalTransportConfigCreatorCache[name] = creator
+
+	common.RegisterConfig(creator(), func(ctx context.Context, config interface{}) (interface{}, error) {
+		return nil, newError("transport config should use CreateTransportConfig instead")
+	})
 	return nil
 }