mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
479 B
26 lines
479 B
package json
|
|
|
|
type ConfigObjectCreator func() interface{}
|
|
|
|
var (
|
|
configCache map[string]ConfigObjectCreator
|
|
)
|
|
|
|
func RegisterRouterConfig(strategy string, creator ConfigObjectCreator) error {
|
|
// TODO: check strategy
|
|
configCache[strategy] = creator
|
|
return nil
|
|
}
|
|
|
|
func CreateRouterConfig(strategy string) interface{} {
|
|
creator, found := configCache[strategy]
|
|
if !found {
|
|
return nil
|
|
}
|
|
return creator()
|
|
}
|
|
|
|
func init() {
|
|
configCache = make(map[string]ConfigObjectCreator)
|
|
}
|