2016-08-17 21:30:15 +00:00
|
|
|
package registry
|
2016-06-10 20:26:39 +00:00
|
|
|
|
2016-08-20 18:55:45 +00:00
|
|
|
import "v2ray.com/core/common/loader"
|
2016-06-10 20:26:39 +00:00
|
|
|
|
|
|
|
var (
|
2016-09-21 12:39:07 +00:00
|
|
|
inboundConfigCreatorCache = loader.ConfigCreatorCache{}
|
|
|
|
inboundConfigCache loader.ConfigLoader
|
|
|
|
|
|
|
|
outboundConfigCreatorCache = loader.ConfigCreatorCache{}
|
|
|
|
outboundConfigCache loader.ConfigLoader
|
2016-06-10 20:26:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func RegisterInboundConfig(protocol string, creator loader.ConfigCreator) error {
|
2016-09-21 12:39:07 +00:00
|
|
|
return inboundConfigCreatorCache.RegisterCreator(protocol, creator)
|
2016-06-10 20:26:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func RegisterOutboundConfig(protocol string, creator loader.ConfigCreator) error {
|
2016-09-21 12:39:07 +00:00
|
|
|
return outboundConfigCreatorCache.RegisterCreator(protocol, creator)
|
2016-06-10 20:26:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func CreateInboundConfig(protocol string, data []byte) (interface{}, error) {
|
|
|
|
return inboundConfigCache.LoadWithID(data, protocol)
|
|
|
|
}
|
|
|
|
|
|
|
|
func CreateOutboundConfig(protocol string, data []byte) (interface{}, error) {
|
|
|
|
return outboundConfigCache.LoadWithID(data, protocol)
|
|
|
|
}
|