feat: 重构配置层,添加 json 支持

This commit is contained in:
Mmx233
2023-08-28 22:03:03 +08:00
parent 2a098e00dd
commit 6f283a93f5
19 changed files with 318 additions and 272 deletions

37
internal/config/models.go Normal file
View File

@@ -0,0 +1,37 @@
package config
type (
GuardianConf struct {
Enable bool `json:"enable" yaml:"enable"`
Duration uint `json:"duration" yaml:"duration"`
}
BasicConf struct {
Https bool `json:"https" yaml:"https"`
SkipCertVerify bool `json:"skip_cert_verify" yaml:"skip_cert_verify"`
Timeout uint `json:"timeout" yaml:"timeout"`
Interfaces string `json:"interfaces" yaml:"interfaces"`
}
LogConf struct {
DebugLevel bool `json:"debug_level" yaml:"debug_level"`
WriteFile bool `json:"write_file" yaml:"write_file"`
FilePath string `json:"file_path" yaml:"log_path"`
FileName string `json:"file_name" yaml:"log_name"`
}
DdnsConf struct {
Enable bool `json:"enable" yaml:"enable"`
TTL uint `json:"ttl" yaml:"ttl"`
Domain string `json:"domain" yaml:"domain"`
Provider string `json:"provider" yaml:"provider"`
Config map[string]interface{} `json:"config" json:"config" yaml:"config"`
}
)
type SettingsConf struct {
Basic BasicConf `json:"basic" yaml:"basic"`
Guardian GuardianConf `json:"guardian" yaml:"guardian"`
Log LogConf `json:"log" yaml:"log"`
DDNS DdnsConf `json:"ddns" yaml:"ddns"`
}