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