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

Replaced cached IP with remote resolver

This commit is contained in:
Eri Bastos
2020-04-18 12:51:50 -04:00
parent 41d54f1354
commit f0a6291406
4 changed files with 45 additions and 16 deletions

View File

@@ -37,24 +37,21 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns.
}
}()
var lastIP string
for {
currentIP, err := godns.GetCurrentIP(handler.Configuration)
if err != nil {
log.Println("get_currentIP:", err)
continue
}
log.Println("currentIP is:", currentIP)
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 {
//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 {
log.Printf("%s.%s Start to update record IP...\n", subDomain, domain.DomainName)
handler.UpdateIP(domain.DomainName, subDomain, currentIP)