Smaller tweaks

This commit is contained in:
Miek Gieben 2011-07-28 23:39:31 +02:00
parent caa1502c1e
commit 5df752fef7
3 changed files with 23 additions and 2 deletions

2
dns.go
View File

@ -91,7 +91,7 @@ func (s RRset) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s RRset) String() string {
str := ""
for _, r := range s {
str += r.String()
str += r.String() + "\n"
}
return str
}

22
zone.go
View File

@ -65,6 +65,16 @@ func (z Zone) Len() int {
return i
}
func (z Zone) String() string {
s := ""
for _, im := range z {
for _, s1 := range im {
s += s1.RRs.String()
}
}
return s
}
// Add a new RR to the zone. First we need to find out if the
// RR already lives inside it.
func (z Zone) PushRR(r RR) {
@ -72,13 +82,23 @@ func (z Zone) PushRR(r RR) {
if s == nil {
s = NewZRRset()
}
s.RRs.Push(r)
switch r.Header().Rrtype {
case TypeRRSIG: fallthrough
// If nsec/nsec3/rrsig comes first, tricky with allocation
// Need to always check all 4 item
// s.RRsigs.Push(r)
case TypeNSEC: fallthrough
case TypeNSEC3: fallthrough
default:
s.RRs.Push(r)
}
z.Push(s)
}
// Push a new ZRRset to the zone
func (z Zone) Push(s *ZRRset) {
i := intval(s.RRs[0].Header().Class, s.RRs[0].Header().Rrtype)
// Need to check the type covered as the RRsigs (if any)
if z[s.RRs[0].Header().Name] == nil {
im := make(map[int]*ZRRset) // intmap
im[i] = s

View File

@ -13,6 +13,7 @@ import (
"strconv"
)
// REALLY make haste with the window reading
const _IOBUF = MaxMsgSize
// A Parser represents a DNS parser for a