improve: 优化 ddns 触发逻辑

This commit is contained in:
Mmx233
2022-12-09 19:29:58 +08:00
parent 1cc47a39d0
commit b4f9b6d560
2 changed files with 33 additions and 18 deletions

View File

@@ -1,12 +1,16 @@
package dns
import (
"errors"
"fmt"
"github.com/Mmx233/BitSrunLoginGo/dns/aliyun"
"github.com/Mmx233/BitSrunLoginGo/dns/cloudflare"
log "github.com/sirupsen/logrus"
)
func Run(c *Config) error {
log.Debugln("开始 DDNS 流程")
if c.TTL == 0 {
c.TTL = 600
}
@@ -21,8 +25,14 @@ func Run(c *Config) error {
case "cloudflare":
dns, e = cloudflare.New(c.TTL, c.Conf, c.Http)
default:
log.Warnf("DDNS 模块 dns 运营商 %s 不支持", c.Provider)
return nil
var msg string
if c.Provider == "" {
msg = "DDNS 模块 dns 运营商不能为空"
} else {
msg = fmt.Sprintf("DDNS 模块 dns 运营商 %s 不支持", c.Provider)
}
log.Warnln(msg)
return errors.New(msg)
}
if e != nil {
log.Warnf("解析 DDNS 配置失败:%v", e)