mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 04:30:08 +00:00
support core adaptive
This commit is contained in:
50
conf/node.go
50
conf/node.go
@@ -23,16 +23,6 @@ type ApiConfig struct {
|
||||
RuleListPath string `json:"RuleListPath"`
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
Core string `json:"Core"`
|
||||
ListenIP string `json:"ListenIP"`
|
||||
SendIP string `json:"SendIP"`
|
||||
LimitConfig LimitConfig `json:"LimitConfig"`
|
||||
XrayOptions *XrayOptions `json:"XrayOptions"`
|
||||
SingOptions *SingOptions `json:"SingOptions"`
|
||||
CertConfig *CertConfig `json:"CertConfig"`
|
||||
}
|
||||
|
||||
func (n *NodeConfig) UnmarshalJSON(data []byte) (err error) {
|
||||
r := rawNodeConfig{}
|
||||
err = json.Unmarshal(data, &r)
|
||||
@@ -46,6 +36,7 @@ func (n *NodeConfig) UnmarshalJSON(data []byte) (err error) {
|
||||
}
|
||||
} else {
|
||||
n.ApiConfig = ApiConfig{
|
||||
APIHost: "http://127.0.0.1",
|
||||
Timeout: 30,
|
||||
}
|
||||
err = json.Unmarshal(data, &n.ApiConfig)
|
||||
@@ -61,7 +52,6 @@ func (n *NodeConfig) UnmarshalJSON(data []byte) (err error) {
|
||||
}
|
||||
} else {
|
||||
n.Options = Options{
|
||||
Core: "xray",
|
||||
ListenIP: "0.0.0.0",
|
||||
SendIP: "0.0.0.0",
|
||||
}
|
||||
@@ -70,13 +60,35 @@ func (n *NodeConfig) UnmarshalJSON(data []byte) (err error) {
|
||||
return
|
||||
}
|
||||
}
|
||||
switch n.Options.Core {
|
||||
case "xray":
|
||||
n.Options.XrayOptions = NewXrayOptions()
|
||||
return json.Unmarshal(data, n.Options.XrayOptions)
|
||||
case "sing":
|
||||
n.Options.SingOptions = NewSingOptions()
|
||||
return json.Unmarshal(data, n.Options.SingOptions)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type Options struct {
|
||||
Core string `json:"Core"`
|
||||
ListenIP string `json:"ListenIP"`
|
||||
SendIP string `json:"SendIP"`
|
||||
LimitConfig LimitConfig `json:"LimitConfig"`
|
||||
RawOptions json.RawMessage `json:"RawOptions"`
|
||||
XrayOptions *XrayOptions `json:"XrayOptions"`
|
||||
SingOptions *SingOptions `json:"SingOptions"`
|
||||
CertConfig *CertConfig `json:"CertConfig"`
|
||||
}
|
||||
|
||||
func (o *Options) UnmarshalJSON(data []byte) error {
|
||||
type opt Options
|
||||
err := json.Unmarshal(data, (*opt)(o))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch o.Core {
|
||||
case "xray":
|
||||
o.XrayOptions = NewXrayOptions()
|
||||
return json.Unmarshal(data, o.XrayOptions)
|
||||
case "sing":
|
||||
o.SingOptions = NewSingOptions()
|
||||
return json.Unmarshal(data, o.SingOptions)
|
||||
default:
|
||||
o.RawOptions = data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user