mirror of
https://github.com/miekg/dns.git
synced 2025-08-18 23:41:00 +02:00
Check the NSEC type bitmap once
It's still timeconsuming, but the only way to check the type bitmap is to iterate over the slice...
This commit is contained in:
parent
25e58e4edd
commit
3e29cce3ba
43
zone.go
43
zone.go
@ -494,32 +494,43 @@ func (node *ZoneData) Sign(next string, keys map[*RR_DNSKEY]PrivateKey, keytags
|
|||||||
node.Lock()
|
node.Lock()
|
||||||
defer node.Unlock()
|
defer node.Unlock()
|
||||||
|
|
||||||
bitmap := make([]uint16, 0)
|
n, nsecok := node.RR[TypeNSEC]
|
||||||
r, n := false, false
|
bitmap := []uint16{TypeNSEC, TypeRRSIG}
|
||||||
|
bitmapEqual := true
|
||||||
for t, _ := range node.RR {
|
for t, _ := range node.RR {
|
||||||
if t == TypeRRSIG {
|
if nsecok {
|
||||||
r = true
|
// Check if the current (if available) nsec has these types too
|
||||||
|
// Grr O(n^2)
|
||||||
|
found := false
|
||||||
|
for _, v := range n[0].(*RR_NSEC).TypeBitMap {
|
||||||
|
if v == t {
|
||||||
|
found = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if v > t { // It is sorted, so by now we haven't found it
|
||||||
|
found = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !found {
|
||||||
|
bitmapEqual = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if t == TypeNSEC {
|
if t == TypeNSEC || t == TypeRRSIG {
|
||||||
n = true
|
continue
|
||||||
}
|
}
|
||||||
bitmap = append(bitmap, t)
|
bitmap = append(bitmap, t)
|
||||||
}
|
|
||||||
if r == false {
|
|
||||||
bitmap = append(bitmap, TypeRRSIG) // Add sig too
|
|
||||||
}
|
|
||||||
if n == false {
|
|
||||||
bitmap = append(bitmap, TypeNSEC) // Add me too!
|
|
||||||
}
|
}
|
||||||
sort.Sort(uint16Slice(bitmap))
|
sort.Sort(uint16Slice(bitmap))
|
||||||
|
|
||||||
if v, ok := node.RR[TypeNSEC]; ok {
|
if nsecok {
|
||||||
// There is an NSEC, check if it still points to the correct next node.
|
// There is an NSEC, check if it still points to the correct next node.
|
||||||
// Secondly the type bitmap may have changed.
|
// Secondly the type bitmap may have changed.
|
||||||
// TODO(mg): actually checked the types in the map
|
// TODO(mg): actually checked the types in the map
|
||||||
if v[0].(*RR_NSEC).NextDomain != next || len(v[0].(*RR_NSEC).TypeBitMap) != len(bitmap) {
|
if n[0].(*RR_NSEC).NextDomain != next || !bitmapEqual {
|
||||||
v[0].(*RR_NSEC).NextDomain = next
|
n[0].(*RR_NSEC).NextDomain = next
|
||||||
v[0].(*RR_NSEC).TypeBitMap = bitmap
|
n[0].(*RR_NSEC).TypeBitMap = bitmap
|
||||||
node.Signatures[TypeNSEC] = nil // drop all sigs
|
node.Signatures[TypeNSEC] = nil // drop all sigs
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user