diff options
Diffstat (limited to 'web/controllers/ddns.go')
-rw-r--r-- | web/controllers/ddns.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/web/controllers/ddns.go b/web/controllers/ddns.go index 692b59f..d476255 100644 --- a/web/controllers/ddns.go +++ b/web/controllers/ddns.go | |||
@@ -5,6 +5,7 @@ import ( | |||
5 | "net/http" | 5 | "net/http" |
6 | 6 | ||
7 | "github.com/gin-gonic/gin" | 7 | "github.com/gin-gonic/gin" |
8 | godns "github.com/miekg/dns" | ||
8 | 9 | ||
9 | "code.crute.me/mcrute/go_ddns_manager/dns" | 10 | "code.crute.me/mcrute/go_ddns_manager/dns" |
10 | "code.crute.me/mcrute/go_ddns_manager/util" | 11 | "code.crute.me/mcrute/go_ddns_manager/util" |
@@ -35,7 +36,17 @@ func UpdateDynamicDNS(c *gin.Context) { | |||
35 | return | 36 | return |
36 | } | 37 | } |
37 | 38 | ||
38 | txn := cfg.DNSClient.StartUpdate(zone).Upsert(&dns.A{ | 39 | txn := cfg.DNSClient.QueryRecursive(zone, res, godns.TypeA) |
40 | cur, err := cfg.DNSClient.SendQuery(txn) | ||
41 | if err == nil && len(cur) == 1 { | ||
42 | if cur[0].(*godns.A).A.Equal(inip) { | ||
43 | log.Printf("ddns: Update not required for '%s', IP %s", res, inip) | ||
44 | c.String(http.StatusNotModified, "") | ||
45 | return | ||
46 | } | ||
47 | } | ||
48 | |||
49 | txn = cfg.DNSClient.StartUpdate(zone).Upsert(&dns.A{ | ||
39 | Name: part, | 50 | Name: part, |
40 | Ttl: 60, | 51 | Ttl: 60, |
41 | A: inip, | 52 | A: inip, |