github.com/Uhtred009/v2ray-core-1@v4.31.2+incompatible/main/json/config_json.go (about) 1 package json 2 3 //go:generate go run v2ray.com/core/common/errors/errorgen 4 5 import ( 6 "io" 7 8 "v2ray.com/core" 9 "v2ray.com/core/common" 10 "v2ray.com/core/common/cmdarg" 11 "v2ray.com/core/infra/conf/serial" 12 "v2ray.com/core/main/confloader" 13 ) 14 15 func init() { 16 common.Must(core.RegisterConfigLoader(&core.ConfigFormat{ 17 Name: "JSON", 18 Extension: []string{"json"}, 19 Loader: func(input interface{}) (*core.Config, error) { 20 switch v := input.(type) { 21 case cmdarg.Arg: 22 r, err := confloader.LoadExtConfig(v) 23 if err != nil { 24 return nil, newError("failed to execute v2ctl to convert config file.").Base(err).AtWarning() 25 } 26 return core.LoadConfig("protobuf", "", r) 27 case io.Reader: 28 return serial.LoadJSONConfig(v) 29 default: 30 return nil, newError("unknow type") 31 } 32 }, 33 })) 34 }