authenticator_json.go 613 B

123456789101112131415161718192021222324252627
  1. // +build json
  2. package internet
  3. import (
  4. "v2ray.com/core/common"
  5. "v2ray.com/core/common/loader"
  6. )
  7. func RegisterAuthenticatorConfig(name string, configCreator loader.ConfigCreator) error {
  8. if _, found := authenticatorCache[name]; found {
  9. return common.ErrDuplicatedName
  10. }
  11. return configCache.RegisterCreator(name, configCreator)
  12. }
  13. func CreateAuthenticatorConfig(rawConfig []byte) (string, AuthenticatorConfig, error) {
  14. config, name, err := configCache.Load(rawConfig)
  15. if err != nil {
  16. return name, nil, err
  17. }
  18. return name, config, nil
  19. }
  20. var (
  21. configCache = loader.NewJSONConfigLoader("type", "")
  22. )