From 9155d632f53bb2bed98906ac269d9825e35dfefe Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Fri, 31 Dec 2010 15:10:42 +0100 Subject: [PATCH] add TSIG as a type --- Makefile | 3 --- dns.go | 1 + resolver/resolver.go | 21 ++++++++++++++------- types.go | 25 +++++++++++++++++++++++++ 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index e8d9884f..32e3cb15 100644 --- a/Makefile +++ b/Makefile @@ -17,20 +17,17 @@ include $(GOROOT)/src/Make.pkg all: package gomake -C dnssec package gomake -C resolver package -# gomake -C xfr package # gomake -C strconv package install: $(INSTALLFILES) gomake -C dnssec install gomake -C resolver install -# gomake -C xfr package # gomake -C strconv install dnstest: gotest gomake -C dnssec test gomake -C resolver test -# gomake -C xfr test # gomake -C strconv test _examples: diff --git a/dns.go b/dns.go index 8a35310a..e2acdffc 100644 --- a/dns.go +++ b/dns.go @@ -10,6 +10,7 @@ // * 1876 - LOC record (incomplete) // * 1995 - IXFR // * 2671 - EDNS +// * 2845 - TSIG // * 2915 - NAPTR record (incomplete) // * 3225 - DO bit (DNSSEC OK) // * 4033/4034/4035 - DNSSEC + validation functions diff --git a/resolver/resolver.go b/resolver/resolver.go index 22ebbf51..e7703f91 100644 --- a/resolver/resolver.go +++ b/resolver/resolver.go @@ -58,13 +58,6 @@ func NewQuerier(res *Resolver) (ch chan DnsMsg) { return } -// Start a new xfr as a goroutine, return a channel. -// Channel will be closed when the axfr is finished, until -// that time new messages will appear on the channel -func NewXfer(res *Resolver) (ch chan DnsMsg) { - -} - // The query function. func query(res *Resolver, msg chan DnsMsg) { // TODO port number, error checking, robustness @@ -135,6 +128,20 @@ func query(res *Resolver, msg chan DnsMsg) { return } +// Start a new xfr as a goroutine, return a channel. +// Channel will be closed when the axfr is finished, until +// that time new messages will appear on the channel +func NewXfer(res *Resolver) (ch chan DnsMsg) { + ch = make(chan DnsMsg) + go axfr(res, ch) + return +} + +func axfr(res *Resolver, msg chan DnsMsg) { + return +} + + // Send a request on the connection and hope for a reply. // Up to res.Attempts attempts. func exchange_udp(c net.Conn, m []byte, r *Resolver) (*dns.Msg, os.Error) { diff --git a/types.go b/types.go index ebf1d6fb..de16086f 100644 --- a/types.go +++ b/types.go @@ -59,6 +59,7 @@ const ( TypeNSEC3 = 50 TypeNSEC3PARAM = 51 + TypeTSIG = 250 // valid Question.qtype only TypeIXFR = 251 TypeAXFR = 252 @@ -80,6 +81,10 @@ const ( RcodeNameError = 3 RcodeNotImplemented = 4 RcodeRefused = 5 + // Tsig errors + RcodeBadSig = 16 + RcodeBadKey = 17 + RcodeBadTime = 18 ) // The wire format for the DNS packet header. @@ -479,6 +484,26 @@ func (rr *RR_NSEC3PARAM) String() string { // Salt with strings.ToUpper() } +type RR_TSIG struct { + Hdr RR_Header + Algoritim string "domain-name" + TimeSigned [3]uint16 // uint48 *sigh* + Fudge uint16 + MACSize uint16 + MAC string + Error uint16 + OtherLen uint16 + OtherData string +} + +func (rr *RR_TSIG) Header() *RR_Header { + return &rr.Hdr +} + +func (rr *RR_TSIG) String() string { + return rr.Hdr.String() + "TODO" +} + // Translate the RRSIG's incep. and expir. time to the correct date. // Taking into account serial arithmetic (RFC 1982) func timeToDate(t uint32) string {