improve: 优化 DDNS 配置读取形式
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/Mmx233/BitSrunLoginGo/dns"
|
||||
"github.com/Mmx233/BitSrunLoginGo/global"
|
||||
"github.com/Mmx233/BitSrunLoginGo/util"
|
||||
BitSrun "github.com/Mmx233/BitSrunLoginGo/v1"
|
||||
@@ -59,29 +58,23 @@ func Login(localAddr net.Addr, debugOutput bool) error {
|
||||
}
|
||||
|
||||
log.Infoln("登录成功~")
|
||||
}
|
||||
|
||||
// DDNS
|
||||
|
||||
enable, _ := global.Config.Settings.DDNS["enable"]
|
||||
if open, _ := enable.(bool); open {
|
||||
if global.Config.Settings.DDNS.Enable {
|
||||
log.Debugln("开始 DDNS 设置流程")
|
||||
|
||||
provider, _ := global.Config.Settings.DDNS["provider"]
|
||||
providerStr, _ := provider.(string)
|
||||
if providerStr == "" {
|
||||
if global.Config.Settings.DDNS.Provider == "" {
|
||||
log.Warnln("DDNS 模块 dns 运营商不能为空")
|
||||
return nil
|
||||
}
|
||||
|
||||
delete(global.Config.Settings.DDNS, "provider")
|
||||
|
||||
_ = dns.Run(&dns.Config{
|
||||
/*_ = dns.Run(&dns.Config{
|
||||
Provider: providerStr,
|
||||
IP: ip,
|
||||
Conf: global.Config.Settings.DDNS,
|
||||
Http: httpClient,
|
||||
})
|
||||
})*/
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -39,11 +39,10 @@ func readConfig() {
|
||||
Log: srunModels.Log{
|
||||
FilePath: "./",
|
||||
},
|
||||
DDNS: map[string]interface{}{
|
||||
"enable": false,
|
||||
"domain": "www.example.com",
|
||||
"ttl": 600,
|
||||
"provider": "",
|
||||
DDNS: srunModels.DDNS{
|
||||
Enable: false,
|
||||
TTL: 600,
|
||||
Domain: "www.example.com",
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -29,12 +29,20 @@ type Log struct {
|
||||
FileName string `json:"log_name" yaml:"log_name" mapstructure:"log_name"`
|
||||
}
|
||||
|
||||
type DDNS struct {
|
||||
Enable bool `json:"enable" yaml:"enable" mapstructure:"enable"`
|
||||
TTL uint `json:"ttl" yaml:"ttl" mapstructure:"ttl"`
|
||||
Domain string `json:"domain" yaml:"domain" mapstructure:"domain"`
|
||||
Provider string `json:"provider" yaml:"provider" mapstructure:"provider"`
|
||||
Config map[string]interface{} `mapstructure:",remain"`
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
Basic Basic `json:"basic" yaml:"basic" mapstructure:"basic"`
|
||||
Guardian Guardian `json:"guardian" yaml:"guardian" mapstructure:"guardian"`
|
||||
Daemon Daemon `json:"daemon" yaml:"daemon" mapstructure:"daemon"`
|
||||
Log Log `json:"log" yaml:"log" mapstructure:"log"`
|
||||
DDNS map[string]interface{} `json:"ddns" yaml:"ddns" mapstructure:"ddns"`
|
||||
DDNS DDNS `json:"ddns" yaml:"ddns" mapstructure:"ddns"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
|
||||
Reference in New Issue
Block a user