From b2f459b7fab5574820e0f5df6e8a18bc5b718139 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Fri, 1 Jun 2012 18:29:07 +0200 Subject: [PATCH] fixes --- TODO.markdown | 3 ++- edns.go | 8 ++++++-- types.go | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/TODO.markdown b/TODO.markdown index 849adb46..f0cdb88f 100644 --- a/TODO.markdown +++ b/TODO.markdown @@ -11,9 +11,10 @@ * Speed, we can always go faster. A simple reflect server now hits 35/45K qps * go test; only works correct on my machine * privatekey.Precompute() when signing? -* RRs: WKS (1183) ## Examples to add * Nameserver, with a small zone, 1 KSK and online signing; * Recursor - ala FunkenSturm? + +WKS: net.LookupPort("tcp", service") diff --git a/edns.go b/edns.go index b7bf9c50..abc53a8f 100644 --- a/edns.go +++ b/edns.go @@ -229,7 +229,9 @@ func (e *EDNS0_SUBNET) Pack() ([]byte, error) { } func (e *EDNS0_SUBNET) Unpack(b []byte) { - // TODO: length of b (overflow) + if len(b) < 8 { + return + } e.Family, _ = unpackUint16(b, 0) e.SourceNetmask = b[2] e.SourceScope = b[3] @@ -249,7 +251,9 @@ func (e *EDNS0_SUBNET) Unpack(b []byte) { } func (e *EDNS0_SUBNET) String() (s string) { - if e.Address.To4() != nil { + if e.Address == nil { + s = "" + } else if e.Address.To4() != nil { s = e.Address.String() } else { s = "[" + e.Address.String() + "]" diff --git a/types.go b/types.go index eb0a939f..9364e31e 100644 --- a/types.go +++ b/types.go @@ -1150,6 +1150,26 @@ func (rr *RR_HIP) Len() int { return l } +type RR_WKS struct { + Hdr RR_Header + Address net.IP `dns:"a"` + Protocol uint8 + Bitmap []uint16 `dns:"wks"` +} + +func (rr *RR_WKS) Header() *RR_Header { + return &rr.Hdr +} + +func (rr *RR_WKS) String() string { + return rr.Hdr.String() + + " " + rr.Address.String() +} + +func (rr *RR_WKS) Len() int { + return rr.Hdr.Len() + net.IPv4len + 1 +} + // TimeToDate translates the RRSIG's incep. and expir. times to the // string representation used when printing the record. // It takes serial arithmetic (RFC 1982) into account. @@ -1224,6 +1244,7 @@ var rr_mk = map[uint16]func() RR{ TypeNAPTR: func() RR { return new(RR_NAPTR) }, TypeDNAME: func() RR { return new(RR_DNAME) }, TypeA: func() RR { return new(RR_A) }, + TypeWKS: func() RR { return new(RR_WKS) }, TypeAAAA: func() RR { return new(RR_AAAA) }, TypeLOC: func() RR { return new(RR_LOC) }, TypeOPT: func() RR { return new(RR_OPT) },