mirror of
https://github.com/v2ray/v2ray-core.git
synced 2026-11-17 14:56:12 +00:00
extendable config format
This commit is contained in:
6 files changed
+129
-117
No files matched your search
+11
-7
@@ -45,7 +45,7 @@ func jsonToProto(input io.Reader) (*core.Config, error) {
|
||||
var config *core.Config
|
||||
|
||||
loadTask := signal.ExecuteAsync(func() error {
|
||||
c, err := core.LoadConfig(core.ConfigFormat_Protobuf, stdoutReader)
|
||||
c, err := core.LoadConfig("protobuf", "", stdoutReader)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -65,11 +65,15 @@ func jsonToProto(input io.Reader) (*core.Config, error) {
|
||||
}
|
||||
|
||||
func init() {
|
||||
common.Must(core.RegisterConfigLoader(core.ConfigFormat_JSON, func(input io.Reader) (*core.Config, error) {
|
||||
config, err := jsonToProto(input)
|
||||
if err != nil {
|
||||
return nil, newError("failed to execute v2ctl to convert config file.").Base(err).AtWarning()
|
||||
}
|
||||
return config, nil
|
||||
common.Must(core.RegisterConfigLoader(&core.ConfigFormat{
|
||||
Name: "JSON",
|
||||
Extension: []string{"json"},
|
||||
Loader: func(input io.Reader) (*core.Config, error) {
|
||||
config, err := jsonToProto(input)
|
||||
if err != nil {
|
||||
return nil, newError("failed to execute v2ctl to convert config file.").Base(err).AtWarning()
|
||||
}
|
||||
return config, nil
|
||||
},
|
||||
}))
|
||||
}
|
||||
Reference in new issue
Block a user