From e8ff9ea8565c24e88e18ff35d338d492f235a012 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Mon, 16 Jul 2012 21:20:58 +0200 Subject: [PATCH] add glue detection --- zone.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/zone.go b/zone.go index d0e2acf8..94a451c6 100644 --- a/zone.go +++ b/zone.go @@ -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) { }