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

add the infinite loop

This commit is contained in:
Timothy 2014-05-13 23:24:19 +08:00
parent 9a20a5354d
commit 21ea4f905f

View File

@ -28,25 +28,27 @@ func main() {
} }
func dns_loop(loop chan bool) { func dns_loop(loop chan bool) {
fmt.Println("Inside the loop...")
time.Sleep(time.Second * 2)
domain_id := get_domain(Configuration.Domain) for {
currentIP, _ := get_currentIP(Configuration.IP_Url) domain_id := get_domain(Configuration.Domain)
sub_domain_id, ip := get_subdomain(domain_id, Configuration.Sub_domain)
fmt.Printf("currentIp is:%s\n", currentIP) currentIP, _ := get_currentIP(Configuration.IP_Url)
sub_domain_id, ip := get_subdomain(domain_id, Configuration.Sub_domain)
//Continue to check the IP of sub-domain fmt.Printf("currentIp is:%s\n", currentIP)
if len(ip) > 0 && !strings.Contains(currentIP, ip) {
fmt.Println("Start to update record IP...") //Continue to check the IP of sub-domain
update_ip(domain_id, sub_domain_id, Configuration.Sub_domain, currentIP) if len(ip) > 0 && !strings.Contains(currentIP, ip) {
} else { fmt.Println("Start to update record IP...")
fmt.Println("Current IP is same as domain IP, no need to update...") update_ip(domain_id, sub_domain_id, Configuration.Sub_domain, currentIP)
} else {
fmt.Println("Current IP is same as domain IP, no need to update...")
}
//Interval is 5 minutes
time.Sleep(time.Second * 60 * 5)
} }
loop <- false
} }