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 { for {
log.Printf("Checking IP for domain %s \r\n", domain.DomainName) log.Printf("Checking IP for domain %s \r\n", domain.DomainName)
domainID := handler.GetDomain(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) log.Println("currentIP is:", currentIP)
//check against locally cached IP, if no change, skip update for _, subDomain := range domain.SubDomains {
if currentIP == lastIP { hostname := subDomain + "." + domain.DomainName
log.Printf("IP is the same as cached one. Skip update.\n") lastIP := godns.ResolveDNS(hostname, handler.Configuration.Resolver)
} else { //check against currently known IP, if no change, skip update
lastIP = currentIP if currentIP == lastIP {
log.Printf("IP is the same as cached one. Skip update.\n")
for _, subDomain := range domain.SubDomains { } else {
lastIP = currentIP
subDomainID, ip := handler.GetSubDomain(domainID, subDomain) 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 { } else if strings.ToUpper(handler.Configuration.IPType) == godns.IPV6 {
value.Add("record_type", "AAAA") value.Add("record_type", "AAAA")
} else { } else {
log.Println("Error: must specify \"ip_type\" in config for DNSPod."); log.Println("Error: must specify \"ip_type\" in config for DNSPod.")
return return
} }