diff --git a/zone.go b/zone.go index 0352f46c..0c8d7b66 100644 --- a/zone.go +++ b/zone.go @@ -3,33 +3,50 @@ package dns // A structure for handling zone data import ( - "github.com/petar/GoLLRB/llrb" + "github.com/miekg/radix" ) type Zone struct { - Name string // Name of the zone - *llrb.Tree // Zone data + Name string // Name of the zone + *radix.Radix // Zone data } type ZoneData struct { - Name string // Domain name for this node - RR map[uint16][]RR // Map ... - Signatures map[uint16][]*RR_RRSIG // DNSSEC signatures - Glue bool // True if the A and AAAA record are glue + Name string // Domain name for this node + RR map[uint16][]RR // Map of the RR type to the RR + Signatures []*RR_RRSIG // DNSSEC signatures + Glue bool // True if the A and AAAA record are glue } -func lessZone(a, b interface{}) bool { return a.(string) < b.(string) } - // New ... func New(name string) *Zone { z := new(Zone) z.Name = name - z.Tree = llrb.New(lessZone) + z.Radix = radix.New() return z } func (z *Zone) Insert(r RR) { - zd := z.Tree.Get(r.Header().Name) + zd := z.Radix.Find(r.Header().Name) + if zd == nil { + zd := new(ZoneData) + zd.Name = r.Header().Name + switch t := r.Header().Rrtype; t { + case TypeRRSIG: + zd.Signatures = append(zd.Signatures, r.(*RR_RRSIG)) + default: + zd.RR[t] = append(zd.RR[t], r) + } + return + } + switch t := r.Header().Rrtype; t { + case TypeRRSIG: + zd.(*ZoneData).Signatures = append(zd.(*ZoneData).Signatures, r.(*RR_RRSIG)) + default: + zd.(*ZoneData).RR[t] = append(zd.(*ZoneData).RR[t], r) + } + // TODO(mg): Glue + return } func (z *Zone) Remove(r RR) {