Browse Source

add auto register hook

Shelikhoo 4 years ago
parent
commit
98bf3dc79a
1 changed files with 4 additions and 0 deletions
  1. 4 0
      common/type.go

+ 4 - 0
common/type.go

@@ -3,6 +3,8 @@ package common
 import (
 import (
 	"context"
 	"context"
 	"reflect"
 	"reflect"
+
+	"github.com/v2fly/v2ray-core/v4/common/registry"
 )
 )
 
 
 // ConfigCreator is a function to create an object by a config.
 // ConfigCreator is a function to create an object by a config.
@@ -17,6 +19,8 @@ func RegisterConfig(config interface{}, configCreator ConfigCreator) error {
 		return newError(configType.Name() + " is already registered").AtError()
 		return newError(configType.Name() + " is already registered").AtError()
 	}
 	}
 	typeCreatorRegistry[configType] = configCreator
 	typeCreatorRegistry[configType] = configCreator
+
+	registry.RegisterImplementation(config, nil)
 	return nil
 	return nil
 }
 }