summaryrefslogtreecommitdiff
path: root/addr.go
diff options
context:
space:
mode:
authorTero Marttila <[email protected]>2016-06-19 19:33:25 +0300
committerTero Marttila <[email protected]>2016-06-19 19:33:25 +0300
commitadab1510c992ba09983f6cbeebe46fe07eedaa5d (patch)
treeca335a3b45639e03e044bdca76d003b2d1981d11 /addr.go
scan interface addresses, and send nsupdate
Diffstat (limited to 'addr.go')
-rw-r--r--addr.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/addr.go b/addr.go
new file mode 100644
index 0000000..080f11b
--- /dev/null
+++ b/addr.go
@@ -0,0 +1,29 @@
+package main
+
+import (
+ "net"
+ "github.com/miekg/dns"
+)
+
+type Addr struct {
+ IP net.IP
+}
+
+func (addr Addr) buildRR(name string, ttl int) dns.RR {
+ if ip4 := addr.IP.To4(); ip4 != nil {
+ return &dns.A{
+ Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeA, Class: dns.ClassINET, Ttl: uint32(ttl)},
+ A: ip4,
+ }
+ }
+
+ if ip6 := addr.IP.To16(); ip6 != nil {
+ return &dns.AAAA{
+ Hdr: dns.RR_Header{Name: name, Rrtype: dns.TypeAAAA, Class: dns.ClassINET, Ttl: uint32(ttl)},
+ AAAA: ip6,
+ }
+ }
+
+ return nil
+}
+