mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
DNSPod Handler - Use Resolver
This commit is contained in:
parent
68b729e635
commit
9397f6b272
@ -36,7 +36,6 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns.
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var lastIP string
|
|
||||||
for {
|
for {
|
||||||
log.Printf("Checking IP for domain %s \r\n", domain.DomainName)
|
log.Printf("Checking IP for domain %s \r\n", domain.DomainName)
|
||||||
domainID := handler.GetDomain(domain.DomainName)
|
domainID := handler.GetDomain(domain.DomainName)
|
||||||
@ -53,14 +52,15 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns.
|
|||||||
}
|
}
|
||||||
log.Println("currentIP is:", currentIP)
|
log.Println("currentIP is:", currentIP)
|
||||||
|
|
||||||
//check against locally cached IP, if no change, skip update
|
for _, subDomain := range domain.SubDomains {
|
||||||
|
hostname := subDomain + "." + domain.DomainName
|
||||||
|
lastIP := godns.ResolveDNS(hostname, handler.Configuration.Resolver)
|
||||||
|
//check against currently known IP, if no change, skip update
|
||||||
if currentIP == lastIP {
|
if currentIP == lastIP {
|
||||||
log.Printf("IP is the same as cached one. Skip update.\n")
|
log.Printf("IP is the same as cached one. Skip update.\n")
|
||||||
} else {
|
} else {
|
||||||
lastIP = currentIP
|
lastIP = currentIP
|
||||||
|
|
||||||
for _, subDomain := range domain.SubDomains {
|
|
||||||
|
|
||||||
subDomainID, ip := handler.GetSubDomain(domainID, subDomain)
|
subDomainID, ip := handler.GetSubDomain(domainID, subDomain)
|
||||||
|
|
||||||
if subDomainID == "" || ip == "" {
|
if subDomainID == "" || ip == "" {
|
||||||
@ -213,7 +213,7 @@ func (handler *Handler) UpdateIP(domainID int64, subDomainID string, subDomainNa
|
|||||||
} else if strings.ToUpper(handler.Configuration.IPType) == godns.IPV6 {
|
} else if strings.ToUpper(handler.Configuration.IPType) == godns.IPV6 {
|
||||||
value.Add("record_type", "AAAA")
|
value.Add("record_type", "AAAA")
|
||||||
} else {
|
} else {
|
||||||
log.Println("Error: must specify \"ip_type\" in config for DNSPod.");
|
log.Println("Error: must specify \"ip_type\" in config for DNSPod.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user