summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2020-08-11 05:11:29 +0000
committerMike Crute <mike@crute.us>2020-08-11 05:30:28 +0000
commit52eb9dc9fc1e0472aea4fd5bd0bb7ea259431d41 (patch)
tree98dd05b7aaee29e692bd42d4873c84d6d53abe6e /web
parentd7fec42036b331a8966efcc85e59b8dafea725ae (diff)
downloadgo_ddns_manager-52eb9dc9fc1e0472aea4fd5bd0bb7ea259431d41.tar.bz2
go_ddns_manager-52eb9dc9fc1e0472aea4fd5bd0bb7ea259431d41.tar.xz
go_ddns_manager-52eb9dc9fc1e0472aea4fd5bd0bb7ea259431d41.zip
Do not do ddns update if ip is same
Diffstat (limited to 'web')
-rw-r--r--web/controllers/ddns.go13
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,