mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
ddns: store configuation in database (#435)
* ddns: store configuation in database Co-authored-by: nap0o <144927971+nap0o@users.noreply.github.com> * feat: split domain with soa lookup * switch to libdns interface * ddns: add unit test * ddns: skip TestSplitDomainSOA on ci network is not steady * fix error handling * fix error handling --------- Co-authored-by: nap0o <144927971+nap0o@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package singleton
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
@@ -39,6 +38,7 @@ func LoadSingleton() {
|
||||
loadCronTasks() // 加载定时任务
|
||||
loadAPI()
|
||||
initNAT()
|
||||
initDDNS()
|
||||
}
|
||||
|
||||
// InitConfigFromPath 从给出的文件路径中加载配置
|
||||
@@ -48,25 +48,6 @@ func InitConfigFromPath(path string) {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
validateConfig()
|
||||
}
|
||||
|
||||
// validateConfig 验证配置文件有效性
|
||||
func validateConfig() {
|
||||
var err error
|
||||
if Conf.DDNS.Provider == "" {
|
||||
err = ValidateDDNSProvidersFromProfiles()
|
||||
} else {
|
||||
_, err = GetDDNSProviderFromString(Conf.DDNS.Provider)
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if Conf.DDNS.Enable {
|
||||
if Conf.DDNS.MaxRetries < 1 || Conf.DDNS.MaxRetries > 10 {
|
||||
panic(fmt.Errorf("DDNS.MaxRetries值域为[1, 10]的整数, 当前为 %d", Conf.DDNS.MaxRetries))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// InitDBFromPath 从给出的文件路径中加载数据库
|
||||
@@ -84,7 +65,7 @@ func InitDBFromPath(path string) {
|
||||
err = DB.AutoMigrate(model.Server{}, model.User{},
|
||||
model.Notification{}, model.AlertRule{}, model.Monitor{},
|
||||
model.MonitorHistory{}, model.Cron{}, model.Transfer{},
|
||||
model.ApiToken{}, model.NAT{})
|
||||
model.ApiToken{}, model.NAT{}, model.DDNSProfile{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user