add default CertConfig

This commit is contained in:
yuzuki999 2023-09-03 02:59:54 +08:00
parent c22efb1917
commit e28a7e00b9
2 changed files with 16 additions and 8 deletions

View File

@ -10,3 +10,9 @@ type CertConfig struct {
Email string `json:"Email"`
DNSEnv map[string]string `json:"DNSEnv"`
}
func NewCertConfig() *CertConfig {
return &CertConfig{
CertMode: "none",
}
}

View File

@ -29,31 +29,33 @@ func (n *NodeConfig) UnmarshalJSON(data []byte) (err error) {
if err != nil {
return err
}
n.ApiConfig = ApiConfig{
APIHost: "http://127.0.0.1",
Timeout: 30,
}
if len(r.ApiRaw) > 0 {
err = json.Unmarshal(r.ApiRaw, &n.ApiConfig)
if err != nil {
return
}
} else {
n.ApiConfig = ApiConfig{
APIHost: "http://127.0.0.1",
Timeout: 30,
}
err = json.Unmarshal(data, &n.ApiConfig)
if err != nil {
return
}
}
n.Options = Options{
ListenIP: "0.0.0.0",
SendIP: "0.0.0.0",
CertConfig: NewCertConfig(),
}
if len(r.OptRaw) > 0 {
err = json.Unmarshal(r.OptRaw, &n.Options)
if err != nil {
return
}
} else {
n.Options = Options{
ListenIP: "0.0.0.0",
SendIP: "0.0.0.0",
}
err = json.Unmarshal(data, &n.Options)
if err != nil {
return