mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
Optimize variable names.
This commit is contained in:
parent
47f4ccd08d
commit
033ba4a4af
20
godns.go
20
godns.go
@ -49,26 +49,26 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
dns_loop()
|
dnsLoop()
|
||||||
}
|
}
|
||||||
|
|
||||||
func dns_loop() {
|
func dnsLoop() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if err := recover(); err != nil {
|
||||||
panicCount++
|
panicCount++
|
||||||
log.Printf("Recovered in %v: %v\n", err, debug.Stack())
|
log.Printf("Recovered in %v: %v\n", err, debug.Stack())
|
||||||
if panicCount < PANIC_MAX {
|
if panicCount < PANIC_MAX {
|
||||||
log.Println("Got panic in goroutine, will start a new one... :", panicCount)
|
log.Println("Got panic in goroutine, will start a new one... :", panicCount)
|
||||||
go dns_loop()
|
go dnsLoop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
|
|
||||||
domain_id := getDomain(configuration.Domain)
|
domainID := getDomain(configuration.Domain)
|
||||||
|
|
||||||
if domain_id == -1 {
|
if domainID == -1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,10 +79,10 @@ func dns_loop() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_domain_id, ip := getSubDomain(domain_id, configuration.Sub_domain)
|
subDomainID, ip := getSubDomain(domainID, configuration.Sub_domain)
|
||||||
|
|
||||||
if sub_domain_id == "" || ip == "" {
|
if subDomainID == "" || ip == "" {
|
||||||
log.Println("sub_domain:", sub_domain_id, ip)
|
log.Println("sub_domain:", subDomainID, ip)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ func dns_loop() {
|
|||||||
//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.Println("Start to update record IP...")
|
log.Println("Start to update record IP...")
|
||||||
updateIP(domain_id, sub_domain_id, configuration.Sub_domain, currentIP)
|
updateIP(domainID, subDomainID, configuration.Sub_domain, currentIP)
|
||||||
} else {
|
} else {
|
||||||
log.Println("Current IP is same as domain IP, no need to update...")
|
log.Println("Current IP is same as domain IP, no need to update...")
|
||||||
}
|
}
|
||||||
@ -99,6 +99,4 @@ func dns_loop() {
|
|||||||
//Interval is 5 minutes
|
//Interval is 5 minutes
|
||||||
time.Sleep(time.Minute * INTERVAL)
|
time.Sleep(time.Minute * INTERVAL)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("Loop %d exited...\n", panicCount)
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user