mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
send mail notify if IP is changed
This commit is contained in:
parent
ccbdf4e31d
commit
4c4f34c55b
@ -51,7 +51,7 @@ func (handler *DNSPodHandler) DomainLoop(domain *godns.Domain, panicChan chan<-
|
|||||||
}
|
}
|
||||||
log.Println("currentIP is:", currentIP)
|
log.Println("currentIP is:", currentIP)
|
||||||
|
|
||||||
//Compare currentIP with saved IP
|
// Compare currentIP with saved IP
|
||||||
savedIP := godns.LoadCurrentIP()
|
savedIP := godns.LoadCurrentIP()
|
||||||
log.Println("savedIP is:", savedIP)
|
log.Println("savedIP is:", savedIP)
|
||||||
|
|
||||||
@ -69,17 +69,23 @@ func (handler *DNSPodHandler) DomainLoop(domain *godns.Domain, panicChan chan<-
|
|||||||
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)
|
||||||
|
|
||||||
|
// Send mail notification if notify is enabled
|
||||||
|
if handler.Configuration.Notify.Enabled {
|
||||||
|
godns.SendNotify(handler.Configuration, 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)
|
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)
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,11 @@ func (handler *HEHandler) DomainLoop(domain *godns.Domain, panicChan chan<- godn
|
|||||||
for _, subDomain := range domain.SubDomains {
|
for _, subDomain := range domain.SubDomains {
|
||||||
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(domain.DomainName, subDomain, currentIP)
|
handler.UpdateIP(domain.DomainName, subDomain, currentIP)
|
||||||
|
|
||||||
|
// Send mail notification if notify is enabled
|
||||||
|
if handler.Configuration.Notify.Enabled {
|
||||||
|
godns.SendNotify(handler.Configuration, currentIP)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user