add glue detection

This commit is contained in:
Miek Gieben 2012-07-16 21:20:58 +02:00
parent f111fe57a1
commit e8ff9ea856
1 changed files with 14 additions and 12 deletions

26
zone.go
View File

@ -18,8 +18,8 @@ type ZoneData struct {
RR map[uint16][]RR // Map of the RR type to the RR
// DNSSEC signatures for the RRsets
Signatures []*RR_RRSIG
// Almost always true, except for non-origin NS records (and accompanying glue)
Authoritatve bool
// Always false, except for glue... TODO(mg)
NonAuth bool
}
// NewZone creates an initialized zone with Origin set origin.
@ -52,9 +52,14 @@ func (z *Zone) Insert(r RR) error {
switch t := r.Header().Rrtype; t {
case TypeRRSIG:
zd.Signatures = append(zd.Signatures, r.(*RR_RRSIG))
case TypeNS:
// NS records with other names than z.Origin are non-auth
if z.Header().Name != z.Origin {
zd.NonAuth = true
}
fallthrough
default:
zd.RR[t] = append(zd.RR[t], r)
glueCheck(r)
}
z.Radix.Insert(r.Header().Name, zd)
return
@ -63,21 +68,18 @@ func (z *Zone) Insert(r RR) error {
switch t := r.Header().Rrtype; t {
case TypeRRSIG:
zd.Value.(*ZoneData).Signatures = append(zd.Value.(*ZoneData).Signatures, r.(*RR_RRSIG))
case TypeNS:
// NS records with other names than z.Origin are non-auth
if z.Header().Name != z.Origin {
zd.NonAuth = true
}
fallthrough
default:
zd.Value.(*ZoneData).RR[t] = append(zd.Value.(*ZoneData).RR[t], r)
}
return
}
func glueCheck(r RR) {
if n, ok := r.(*RR_NS); ok {
// Check if glue would be needed
if CompareLabels(r.Header().Name, n.Ns) == LenLabels(r.Header().Name) {
println("glue needed?", r.Header().Name, n.Ns)
}
}
}
func (z *Zone) Remove(r RR) {
}