mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
bug fix for sleeping
This commit is contained in:
parent
4b69c69f34
commit
9020971add
@ -57,30 +57,30 @@ func (handler *DNSPodHandler) DomainLoop(domain *godns.Domain, panicChan chan<-
|
|||||||
|
|
||||||
if savedIP != "" && strings.TrimRight(currentIP, "\n") == strings.TrimRight(savedIP, "\n") {
|
if savedIP != "" && strings.TrimRight(currentIP, "\n") == strings.TrimRight(savedIP, "\n") {
|
||||||
log.Printf("Current IP is not changed, no need to update...")
|
log.Printf("Current IP is not changed, no need to update...")
|
||||||
continue
|
|
||||||
} else {
|
} else {
|
||||||
godns.SaveCurrentIP(currentIP)
|
godns.SaveCurrentIP(currentIP)
|
||||||
}
|
|
||||||
|
|
||||||
for _, subDomain := range domain.SubDomains {
|
for _, subDomain := range domain.SubDomains {
|
||||||
|
|
||||||
subDomainID, ip := handler.GetSubDomain(domainID, subDomain)
|
subDomainID, ip := handler.GetSubDomain(domainID, subDomain)
|
||||||
|
|
||||||
if subDomainID == "" || ip == "" {
|
if subDomainID == "" || ip == "" {
|
||||||
log.Printf("domain: %s.%s subDomainID: %s ip: %s\n", subDomain, domain.DomainName, subDomainID, ip)
|
log.Printf("domain: %s.%s subDomainID: %s ip: %s\n", subDomain, domain.DomainName, subDomainID, ip)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
//Continue to check the IP of sub-domain
|
//Continue to check the IP of sub-domain
|
||||||
if len(ip) > 0 && !strings.Contains(currentIP, ip) {
|
if len(ip) > 0 && !strings.Contains(currentIP, ip) {
|
||||||
log.Printf("%s.%s Start to update record IP...\n", subDomain, domain.DomainName)
|
log.Printf("%s.%s Start to update record IP...\n", subDomain, domain.DomainName)
|
||||||
handler.UpdateIP(domainID, subDomainID, subDomain, currentIP)
|
handler.UpdateIP(domainID, subDomainID, subDomain, currentIP)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("%s.%s Current IP is same as domain IP, no need to update...\n", subDomain, domain.DomainName)
|
log.Printf("%s.%s Current IP is same as domain IP, no need to update...\n", subDomain, domain.DomainName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Interval is 5 minutes
|
//Interval is 5 minutes
|
||||||
|
log.Printf("Going to sleep, will start next checking in %d minutes...\r\n", godns.INTERVAL)
|
||||||
time.Sleep(time.Minute * godns.INTERVAL)
|
time.Sleep(time.Minute * godns.INTERVAL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,17 +53,16 @@ func (handler *HEHandler) DomainLoop(domain *godns.Domain, panicChan chan<- godn
|
|||||||
|
|
||||||
if savedIP != "" && currentIP == savedIP {
|
if savedIP != "" && currentIP == savedIP {
|
||||||
log.Printf("Current IP is not changed, no need to update...")
|
log.Printf("Current IP is not changed, no need to update...")
|
||||||
continue
|
|
||||||
} else {
|
} else {
|
||||||
godns.SaveCurrentIP(currentIP)
|
godns.SaveCurrentIP(currentIP)
|
||||||
}
|
for _, subDomain := range domain.SubDomains {
|
||||||
|
log.Printf("%s.%s Start to update record IP...\n", subDomain, domain.DomainName)
|
||||||
for _, subDomain := range domain.SubDomains {
|
handler.UpdateIP(domain.DomainName, subDomain, currentIP)
|
||||||
log.Printf("%s.%s Start to update record IP...\n", subDomain, domain.DomainName)
|
}
|
||||||
handler.UpdateIP(domain.DomainName, subDomain, currentIP)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Interval is 5 minutes
|
// Interval is 5 minutes
|
||||||
|
log.Printf("Going to sleep, will start next checking in %d minutes...\r\n", godns.INTERVAL)
|
||||||
time.Sleep(time.Minute * godns.INTERVAL)
|
time.Sleep(time.Minute * godns.INTERVAL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user