config_cache.go 443 B

1234567891011121314151617181920
  1. package json
  2. import (
  3. "github.com/v2ray/v2ray-core/config"
  4. )
  5. type ConfigObjectCreator func() interface{}
  6. var (
  7. configCache = make(map[string]ConfigObjectCreator)
  8. )
  9. func getConfigKey(protocol string, cType config.Type) string {
  10. return protocol + "_" + string(cType)
  11. }
  12. func RegisterConfigType(protocol string, cType config.Type, creator ConfigObjectCreator) {
  13. // TODO: check name
  14. configCache[getConfigKey(protocol, cType)] = creator
  15. }