From 06a7d2384a9ddaea13c4b919ae98975395022f11 Mon Sep 17 00:00:00 2001 From: Rick Lei Date: Sat, 8 Feb 2020 20:30:51 +0100 Subject: [PATCH] Better DNSPod error message handling and ip_type checking DNSPod API now requires record type to be specified, so the "ip_type" setting becomes a must in config.json. --- README.md | 1 + handler/dnspod/dnspod_handler.go | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/README.md b/README.md index cd313cb..55f0568 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,7 @@ For DNSPod, you need to provide your API Token(you can create it [here](https:// } ], "ip_url": "https://myip.biturl.top", + "ip_type": "IPV4", "interval": 300, "socks5_proxy": "" } diff --git a/handler/dnspod/dnspod_handler.go b/handler/dnspod/dnspod_handler.go index 79f1a2e..678945a 100644 --- a/handler/dnspod/dnspod_handler.go +++ b/handler/dnspod/dnspod_handler.go @@ -216,6 +216,9 @@ func (handler *Handler) UpdateIP(domainID int64, subDomainID string, subDomainNa value.Add("record_type", "A") } else if strings.ToUpper(handler.Configuration.IPType) == godns.IPV6 { value.Add("record_type", "AAAA") + } else { + log.Println("Error: must specify \"ip_type\" in config for DNSPod."); + return } value.Add("record_line", "默认") @@ -238,6 +241,8 @@ func (handler *Handler) UpdateIP(domainID int64, subDomainID string, subDomainNa if sjson.Get("status").Get("code").MustString() == "1" { log.Println("New IP updated!") + } else { + log.Println("Failed to update IP record:", sjson.Get("status").Get("message").MustString()) } }