diff options
| author | Tero Marttila <[email protected]> | 2016-06-19 19:33:25 +0300 |
|---|---|---|
| committer | Tero Marttila <[email protected]> | 2016-06-19 19:33:25 +0300 |
| commit | adab1510c992ba09983f6cbeebe46fe07eedaa5d (patch) | |
| tree | ca335a3b45639e03e044bdca76d003b2d1981d11 /addr.go | |
scan interface addresses, and send nsupdate
Diffstat (limited to 'addr.go')
| -rw-r--r-- | addr.go | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -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 +} + |
