mirror of
https://github.com/taigrr/godns
synced 2025-01-18 04:03:25 -08:00
Duck Handler - Use Resolver
This commit is contained in:
parent
9397f6b272
commit
57ecf1f7bb
@ -35,8 +35,6 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns.
|
||||
}
|
||||
}()
|
||||
|
||||
var lastIP string
|
||||
|
||||
for {
|
||||
currentIP, err := godns.GetCurrentIP(handler.Configuration)
|
||||
|
||||
@ -47,10 +45,7 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns.
|
||||
log.Println("currentIP is:", currentIP)
|
||||
|
||||
//check against locally cached IP, if no change, skip update
|
||||
if currentIP == lastIP {
|
||||
log.Printf("IP is the same as cached one. Skip update.\n")
|
||||
} else {
|
||||
lastIP = currentIP
|
||||
|
||||
client := godns.GetHttpClient(handler.Configuration)
|
||||
var ip string
|
||||
|
||||
@ -61,6 +56,12 @@ func (handler *Handler) DomainLoop(domain *godns.Domain, panicChan chan<- godns.
|
||||
}
|
||||
|
||||
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 {
|
||||
log.Printf("IP is the same as cached one. Skip update.\n")
|
||||
} else {
|
||||
// update IP with HTTP GET request
|
||||
resp, err := client.Get(fmt.Sprintf(DuckUrl, subDomain, handler.Configuration.LoginToken, ip))
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user