1
0
mirror of https://github.com/taigrr/godns synced 2025-01-18 04:03:25 -08:00

DNSPod Handler - Use Resolver

This commit is contained in:
Eri Bastos 2020-04-19 15:26:10 -04:00
parent 68b729e635
commit 9397f6b272

View File

@ -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
}