mirror of
https://github.com/v2fly/v2ray-core.git
synced 2026-06-09 04:29:17 -04:00
protobuf for kcp config
This commit is contained in:
@@ -21,9 +21,10 @@ func (this *Config) UnmarshalJSON(data []byte) error {
|
||||
|
||||
this.Response = new(NoneResponse)
|
||||
if jsonConfig.Response != nil {
|
||||
loader := loader.NewJSONConfigLoader(loader.ConfigCreatorCache{}, "type", "")
|
||||
loader.RegisterCreator("none", func() interface{} { return new(NoneResponse) })
|
||||
loader.RegisterCreator("http", func() interface{} { return new(HTTPResponse) })
|
||||
cache := loader.ConfigCreatorCache{}
|
||||
loader := loader.NewJSONConfigLoader(cache, "type", "")
|
||||
cache.RegisterCreator("none", func() interface{} { return new(NoneResponse) })
|
||||
cache.RegisterCreator("http", func() interface{} { return new(HTTPResponse) })
|
||||
response, _, err := loader.Load(jsonConfig.Response)
|
||||
if err != nil {
|
||||
return errors.New("Blackhole: Failed to parse response config: " + err.Error())
|
||||
|
||||
@@ -3,16 +3,19 @@ package registry
|
||||
import "v2ray.com/core/common/loader"
|
||||
|
||||
var (
|
||||
inboundConfigCache loader.ConfigLoader
|
||||
outboundConfigCache loader.ConfigLoader
|
||||
inboundConfigCreatorCache = loader.ConfigCreatorCache{}
|
||||
inboundConfigCache loader.ConfigLoader
|
||||
|
||||
outboundConfigCreatorCache = loader.ConfigCreatorCache{}
|
||||
outboundConfigCache loader.ConfigLoader
|
||||
)
|
||||
|
||||
func RegisterInboundConfig(protocol string, creator loader.ConfigCreator) error {
|
||||
return inboundConfigCache.RegisterCreator(protocol, creator)
|
||||
return inboundConfigCreatorCache.RegisterCreator(protocol, creator)
|
||||
}
|
||||
|
||||
func RegisterOutboundConfig(protocol string, creator loader.ConfigCreator) error {
|
||||
return outboundConfigCache.RegisterCreator(protocol, creator)
|
||||
return outboundConfigCreatorCache.RegisterCreator(protocol, creator)
|
||||
}
|
||||
|
||||
func CreateInboundConfig(protocol string, data []byte) (interface{}, error) {
|
||||
|
||||
@@ -7,6 +7,6 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
inboundConfigCache = loader.NewJSONConfigLoader(loader.ConfigCreatorCache{}, "protocol", "settings")
|
||||
outboundConfigCache = loader.NewJSONConfigLoader(loader.ConfigCreatorCache{}, "protocol", "settings")
|
||||
inboundConfigCache = loader.NewJSONConfigLoader(inboundConfigCreatorCache, "protocol", "settings")
|
||||
outboundConfigCache = loader.NewJSONConfigLoader(outboundConfigCreatorCache, "protocol", "settings")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user