config_cache.go 858 B

123456789101112131415161718192021222324252627
  1. package registry
  2. import "v2ray.com/core/common/loader"
  3. var (
  4. inboundConfigCreatorCache = loader.ConfigCreatorCache{}
  5. inboundConfigCache loader.ConfigLoader
  6. outboundConfigCreatorCache = loader.ConfigCreatorCache{}
  7. outboundConfigCache loader.ConfigLoader
  8. )
  9. func RegisterInboundConfig(protocol string, creator loader.ConfigCreator) error {
  10. return inboundConfigCreatorCache.RegisterCreator(protocol, creator)
  11. }
  12. func RegisterOutboundConfig(protocol string, creator loader.ConfigCreator) error {
  13. return outboundConfigCreatorCache.RegisterCreator(protocol, creator)
  14. }
  15. func CreateInboundConfig(protocol string, data []byte) (interface{}, error) {
  16. return inboundConfigCache.LoadWithID(data, protocol)
  17. }
  18. func CreateOutboundConfig(protocol string, data []byte) (interface{}, error) {
  19. return outboundConfigCache.LoadWithID(data, protocol)
  20. }