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:
parent
9a20a5354d
commit
21ea4f905f
30
godns.go
30
godns.go
@ -28,25 +28,27 @@ func main() {
|
||||
}
|
||||
|
||||
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)
|
||||
sub_domain_id, ip := get_subdomain(domain_id, Configuration.Sub_domain)
|
||||
domain_id := get_domain(Configuration.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
|
||||
if len(ip) > 0 && !strings.Contains(currentIP, ip) {
|
||||
fmt.Printf("currentIp is:%s\n", currentIP)
|
||||
|
||||
fmt.Println("Start to update record IP...")
|
||||
update_ip(domain_id, sub_domain_id, Configuration.Sub_domain, currentIP)
|
||||
//Continue to check the IP of sub-domain
|
||||
if len(ip) > 0 && !strings.Contains(currentIP, ip) {
|
||||
|
||||
} else {
|
||||
fmt.Println("Current IP is same as domain IP, no need to update...")
|
||||
fmt.Println("Start to update record IP...")
|
||||
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user