mirror of
https://github.com/miekg/dns.git
synced 2025-10-12 02:11:13 +02:00
Add nsec3 search functions
This commit is contained in:
parent
e6fb6095c4
commit
7e644793fe
29
zone.go
29
zone.go
@ -172,3 +172,32 @@ func (z Zone) LookupName(qname string, qclass, qtype uint16) (*ZRRset, os.Error)
|
|||||||
func intval(c, t uint16) int {
|
func intval(c, t uint16) int {
|
||||||
return int(c)*_CLASS + int(t)
|
return int(c)*_CLASS + int(t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Needed for NSEC/NSEC3 in DNSSEC
|
||||||
|
// SortInsert insert the string s in the already sorted
|
||||||
|
// vector p. If s is already present it is not inserted again.
|
||||||
|
func SortInsert(p *vector.StringVector, s string) {
|
||||||
|
sa := sort.StringArray(*p)
|
||||||
|
i := sa.Search(s)
|
||||||
|
if i < p.Len() && p.At(i) == s {
|
||||||
|
// element already there
|
||||||
|
return
|
||||||
|
}
|
||||||
|
p.Insert(i, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Search searches the sorted vector p using binary search. If
|
||||||
|
// the element s can not be found, the previous element is returned.
|
||||||
|
func SortSearch(p *vector.StringVector, s string) string {
|
||||||
|
sa := sort.StringArray(*p)
|
||||||
|
i := sa.Search(s)
|
||||||
|
// with zones there must always be one before
|
||||||
|
if p.At(i) == s {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
if i > 0 {
|
||||||
|
i--
|
||||||
|
}
|
||||||
|
return p.At(i)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user