mirror of
https://github.com/wyx2685/V2bX.git
synced 2025-02-02 06:48:14 -05:00
chore: refine config unmarshal
This commit is contained in:
parent
cb868c7411
commit
bb16015dab
28
conf/node.go
28
conf/node.go
@ -33,9 +33,9 @@ type Options struct {
|
|||||||
CertConfig *CertConfig `json:"CertConfig"`
|
CertConfig *CertConfig `json:"CertConfig"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *NodeConfig) UnmarshalJSON(b []byte) (err error) {
|
func (n *NodeConfig) UnmarshalJSON(data []byte) (err error) {
|
||||||
r := rawNodeConfig{}
|
r := rawNodeConfig{}
|
||||||
err = json.Unmarshal(b, &r)
|
err = json.Unmarshal(data, &r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -48,14 +48,14 @@ func (n *NodeConfig) UnmarshalJSON(b []byte) (err error) {
|
|||||||
n.ApiConfig = ApiConfig{
|
n.ApiConfig = ApiConfig{
|
||||||
Timeout: 30,
|
Timeout: 30,
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(b, &n.ApiConfig)
|
err = json.Unmarshal(data, &n.ApiConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if r.OptRaw != nil {
|
if r.OptRaw != nil {
|
||||||
err = json.Unmarshal(*r.OptRaw, &n.Options)
|
data = *r.OptRaw
|
||||||
|
err = json.Unmarshal(data, &n.Options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -65,18 +65,18 @@ func (n *NodeConfig) UnmarshalJSON(b []byte) (err error) {
|
|||||||
ListenIP: "0.0.0.0",
|
ListenIP: "0.0.0.0",
|
||||||
SendIP: "0.0.0.0",
|
SendIP: "0.0.0.0",
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(b, &n.Options)
|
err = json.Unmarshal(data, &n.Options)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
switch n.Options.Core {
|
}
|
||||||
case "xray":
|
switch n.Options.Core {
|
||||||
n.Options.XrayOptions = NewXrayOptions()
|
case "xray":
|
||||||
return json.Unmarshal(b, n.Options.XrayOptions)
|
n.Options.XrayOptions = NewXrayOptions()
|
||||||
case "sing":
|
return json.Unmarshal(data, n.Options.XrayOptions)
|
||||||
n.Options.SingOptions = NewSingOptions()
|
case "sing":
|
||||||
return json.Unmarshal(b, n.Options.SingOptions)
|
n.Options.SingOptions = NewSingOptions()
|
||||||
}
|
return json.Unmarshal(data, n.Options.SingOptions)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user