From 7c2de14b8d151cda8a41a4a247186879eda352e7 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Sat, 1 Jan 2011 19:26:08 +0100 Subject: [PATCH] add TKEY and finalize TSIG No crypto validation ofcourse... only the definition of the RRs --- README | 4 ++- TODO | 1 - msg.go | 2 ++ types.go | 82 +++++++++++++++++++++++++++++++++++++------------------- 4 files changed, 60 insertions(+), 29 deletions(-) diff --git a/README b/README index 8514a055..226a31a0 100644 --- a/README +++ b/README @@ -2,7 +2,8 @@ Alternative (more granular) approach to a DNS library. Completely usable as a DNS client library. Most widely used Resource Records are supported. DNSSEC types are too (except NSEC/NSEC3, for now). EDNS0 -is supported (see edns.go). +is (see edns.go), UDP/TCP queries, AXFR (and IXFR probably +too) supported. Sample programs can be found in the _examples directory. @@ -17,6 +18,7 @@ Implemented RFCS: * RFC 1034/1035 * RFC 4033/4034/4035 * RFC 5155 (NSEC3) +* And all that I forgot Loosely based upon: * ldns diff --git a/TODO b/TODO index 2b5d82d6..a0bf12ae 100644 --- a/TODO +++ b/TODO @@ -14,7 +14,6 @@ Todo: Issues: * Better sized buffers * Make the testsuite work with public DNS servers -* TC bit handling * shortened ipv6 addresses are not parsed correctly * quoted quotes in txt records * Convience functions? diff --git a/msg.go b/msg.go index 4c82b660..a4a1124e 100644 --- a/msg.go +++ b/msg.go @@ -87,6 +87,8 @@ var Rr_str = map[uint16]string{ TypeDNSKEY: "DNSKEY", TypeNSEC3: "NSEC3", TypeNSEC3PARAM: "NSEC3PARAM", + TypeTKEY: "TKEY", + TypeTSIG: "TSIG", TypeAXFR: "AXFR", // Not real RRs TypeIXFR: "IXFR", } diff --git a/types.go b/types.go index 5bfc333d..828279ef 100644 --- a/types.go +++ b/types.go @@ -40,7 +40,7 @@ const ( TypeMX = 15 TypeTXT = 16 TypeAAAA = 28 - TypeLOC = 29 + TypeLOC = 29 TypeSRV = 33 TypeNAPTR = 35 @@ -59,9 +59,10 @@ const ( TypeNSEC3 = 50 TypeNSEC3PARAM = 51 - TypeTSIG = 250 + TypeTKEY = 249 + TypeTSIG = 250 // valid Question.qtype only - TypeIXFR = 251 + TypeIXFR = 251 TypeAXFR = 252 TypeMAILB = 253 TypeMAILA = 254 @@ -81,10 +82,14 @@ const ( RcodeNameError = 3 RcodeNotImplemented = 4 RcodeRefused = 5 - // Tsig errors - TsigBadSig = 16 - TsigBadKey = 17 - TsigBadTime = 18 + // Tsig errors + TsigBadSig = 16 + TsigBadKey = 17 + TsigBadTime = 18 + // Tkey errors + TkeyBadMode = 19 + TkeyBadName = 20 + TKeyBadAlg = 21 ) // The wire format for the DNS packet header. @@ -342,14 +347,14 @@ func (rr *RR_AAAA) String() string { } type RR_LOC struct { - Hdr RR_Header - Version uint8 - Size uint8 - HorizPre uint8 - VertPre uint8 - Latitude uint32 - Longitude uint32 - Altitude uint32 + Hdr RR_Header + Version uint8 + Size uint8 + HorizPre uint8 + VertPre uint8 + Latitude uint32 + Longitude uint32 + Altitude uint32 } func (rr *RR_LOC) Header() *RR_Header { @@ -484,24 +489,45 @@ func (rr *RR_NSEC3PARAM) String() string { // Salt with strings.ToUpper() } +type RR_TKEY struct { + Hdr RR_Header + Algoritim string "domain-name" + Inception uint32 + Expiration uint32 + Mode uint16 + Error uint16 + KeySize uint16 + Key string + Otherlen uint16 + OtherData string +} + +func (rr *RR_TKEY) Header() *RR_Header { + return &rr.Hdr +} + +func (rr *RR_TKEY) String() string { + return rr.Hdr.String() + "BLAHBLAH" +} + 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 + 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 + return &rr.Hdr } func (rr *RR_TSIG) String() string { - return rr.Hdr.String() + "TODO" + return rr.Hdr.String() + "TODO" } // Translate the RRSIG's incep. and expir. time to the correct date. @@ -532,7 +558,7 @@ var rr_mk = map[int]func() RR{ TypeNAPTR: func() RR { return new(RR_NAPTR) }, TypeA: func() RR { return new(RR_A) }, TypeAAAA: func() RR { return new(RR_AAAA) }, - TypeLOC: func() RR { return new(RR_LOC) }, + TypeLOC: func() RR { return new(RR_LOC) }, TypeOPT: func() RR { return new(RR_OPT) }, TypeDS: func() RR { return new(RR_DS) }, TypeRRSIG: func() RR { return new(RR_RRSIG) }, @@ -540,4 +566,6 @@ var rr_mk = map[int]func() RR{ TypeDNSKEY: func() RR { return new(RR_DNSKEY) }, TypeNSEC3: func() RR { return new(RR_NSEC3) }, TypeNSEC3PARAM: func() RR { return new(RR_NSEC3PARAM) }, + TypeTKEY: func() RR { return new(RR_TKEY) }, + TypeTSIG: func() RR { return new(RR_TSIG) }, }