mirror of
https://github.com/XTLS/Xray-core.git
synced 2025-04-30 01:08:33 +00:00
v1.0.0
This commit is contained in:
parent
47d23e9972
commit
c7f7c08ead
711 changed files with 82154 additions and 2 deletions
38
main/jsonem/jsonem.go
Normal file
38
main/jsonem/jsonem.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package jsonem
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"github.com/xtls/xray-core/v1/common"
|
||||
"github.com/xtls/xray-core/v1/common/cmdarg"
|
||||
"github.com/xtls/xray-core/v1/core"
|
||||
"github.com/xtls/xray-core/v1/infra/conf"
|
||||
"github.com/xtls/xray-core/v1/infra/conf/serial"
|
||||
"github.com/xtls/xray-core/v1/main/confloader"
|
||||
)
|
||||
|
||||
func init() {
|
||||
common.Must(core.RegisterConfigLoader(&core.ConfigFormat{
|
||||
Name: "JSON",
|
||||
Extension: []string{"json"},
|
||||
Loader: func(input interface{}) (*core.Config, error) {
|
||||
switch v := input.(type) {
|
||||
case cmdarg.Arg:
|
||||
cf := &conf.Config{}
|
||||
for _, arg := range v {
|
||||
newError("Reading config: ", arg).AtInfo().WriteToLog()
|
||||
r, err := confloader.LoadConfig(arg)
|
||||
common.Must(err)
|
||||
c, err := serial.DecodeJSONConfig(r)
|
||||
common.Must(err)
|
||||
cf.Override(c, arg)
|
||||
}
|
||||
return cf.Build()
|
||||
case io.Reader:
|
||||
return serial.LoadJSONConfig(v)
|
||||
default:
|
||||
return nil, newError("unknow type")
|
||||
}
|
||||
},
|
||||
}))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue