From 9397f6b27203df9ad89a246c95d61b5b1ba26c11 Mon Sep 17 00:00:00 2001 From: Eri Bastos Date: Sun, 19 Apr 2020 15:26:10 -0400 Subject: [PATCH] DNSPod Handler - Use Resolver --- handler/dnspod/dnspod_handler.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/handler/dnspod/dnspod_handler.go b/handler/dnspod/dnspod_handler.go index 1df4d74..901f573 100644 --- a/handler/dnspod/dnspod_handler.go +++ b/handler/dnspod/dnspod_handler.go @@ -36,7 +36,6 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns. } }() - var lastIP string for { log.Printf("Checking IP for domain %s \r\n", domain.DomainName) domainID := handler.GetDomain(domain.DomainName) @@ -53,13 +52,14 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns. } log.Println("currentIP is:", currentIP) - //check against locally cached IP, if no change, skip update - if currentIP == lastIP { - log.Printf("IP is the same as cached one. Skip update.\n") - } else { - lastIP = currentIP - - for _, subDomain := range domain.SubDomains { + for _, subDomain := range domain.SubDomains { + hostname := subDomain + "." + domain.DomainName + lastIP := godns.ResolveDNS(hostname, handler.Configuration.Resolver) + //check against currently known IP, if no change, skip update + if currentIP == lastIP { + log.Printf("IP is the same as cached one. Skip update.\n") + } else { + lastIP = currentIP subDomainID, ip := handler.GetSubDomain(domainID, subDomain) @@ -213,7 +213,7 @@ func (handler *Handler) UpdateIP(domainID int64, subDomainID string, subDomainNa } 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."); + log.Println("Error: must specify \"ip_type\" in config for DNSPod.") return }