1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-04-18 11:39:11 -04:00

revert back to multiconfig

This commit is contained in:
vcptr
2020-01-03 09:26:48 +08:00
committed by kslr
parent 5d13ec9196
commit 0d71d3dcf8
19 changed files with 557 additions and 83 deletions

View File

@@ -7,22 +7,28 @@ import (
"v2ray.com/core"
"v2ray.com/core/common"
"v2ray.com/core/common/buf"
"v2ray.com/core/common/platform/ctlcmd"
"v2ray.com/core/common/cmdarg"
"v2ray.com/core/infra/conf/serial"
"v2ray.com/core/main/confloader"
)
func init() {
common.Must(core.RegisterConfigLoader(&core.ConfigFormat{
Name: "JSON",
Extension: []string{"json"},
Loader: func(input io.Reader) (*core.Config, error) {
jsonContent, err := ctlcmd.Run([]string{"config"}, input)
if err != nil {
return nil, newError("failed to execute v2ctl to convert config file.").Base(err).AtWarning()
Loader: func(input interface{}) (*core.Config, error) {
switch v := input.(type) {
case cmdarg.Arg:
r, err := confloader.LoadExtConfig(v)
if err != nil {
return nil, newError("failed to execute v2ctl to convert config file.").Base(err).AtWarning()
}
return core.LoadConfig("protobuf", "", r)
case io.Reader:
return serial.LoadJSONConfig(v)
default:
return nil, newError("unknow type")
}
return core.LoadConfig("protobuf", "", &buf.MultiBufferContainer{
MultiBuffer: jsonContent,
})
},
}))
}