Add DDNS support (#324)

* feat: add ddns updater framework

Note: no functionality implemented yet

* feat: add webhook ddns provider

* feat: update dashboard template

* fix: check nil and cron task string

* fix: webhook string formated with unexcepted param

* fix: webhook header split error

* feat: cloudflare ddns provider

* refract: move ddns update trigger into ReportSystemInfo

* lang: update other languages text

* fix: clear codes and logics

* fix: move update ddns to goroutine to avoid blocking

* fix: clear unused codes

* fix: update timestamp to prevent cache
This commit is contained in:
Darc Z
2024-02-24 21:10:27 +08:00
committed by GitHub
parent c4b2c47beb
commit 3b5ee464a7
16 changed files with 439 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
package singleton
import (
"fmt"
"log"
"time"
@@ -46,6 +47,21 @@ func InitConfigFromPath(path string) {
if err != nil {
panic(err)
}
ValidateConfig()
}
// ValidateConfig 验证配置文件有效性
func ValidateConfig() {
// 如果DDNS启用则检查Provider是否存在, 不存在直接退出
if Conf.DDNS.Enable {
_, err := GetDDNSProviderFromString(Conf.DDNS.Provider)
if err != nil {
panic(err)
}
if Conf.DDNS.MaxRetries < 1 || Conf.DDNS.MaxRetries > 10 {
panic(fmt.Errorf("DDNS.MaxRetries值域为[1, 10]的整数, 当前为 %d", Conf.DDNS.MaxRetries))
}
}
}
// InitDBFromPath 从给出的文件路径中加载数据库