Create qnamelist for nsec/nsec3 handling
This commit is contained in:
parent
e016536cdc
commit
05b7ac53dd
1
Makefile
1
Makefile
|
@ -22,6 +22,7 @@ GOFILES=\
|
||||||
types.go\
|
types.go\
|
||||||
xfr.go\
|
xfr.go\
|
||||||
zone.go\
|
zone.go\
|
||||||
|
qnamestring.go\
|
||||||
zparse.go\
|
zparse.go\
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,9 @@ func handleQuery(w dns.ResponseWriter, req *dns.Msg) {
|
||||||
m.Ns[0] = soa
|
m.Ns[0] = soa
|
||||||
m.MsgHdr.Rcode = dns.RcodeNameError
|
m.MsgHdr.Rcode = dns.RcodeNameError
|
||||||
send(w, m)
|
send(w, m)
|
||||||
|
// Lookup the previous name in the Nxt list for this zone
|
||||||
|
// and insert the nsec/nsec3 from that. Also give the nsec
|
||||||
|
// that proofs there is no wildcard
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -175,6 +175,6 @@ func TestZoneParsing(t *testing.T) {
|
||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
delta := time.Nanoseconds() - start
|
delta := time.Nanoseconds() - start
|
||||||
t.Logf("%v", z.Nxt)
|
t.Logf("%s", z.Nxt)
|
||||||
t.Logf("%d RRs parsed in %.2f s (%.2f RR/s)", z.Len(), float32(delta)/1e9, float32(z.Len())/(float32(delta)/1e9))
|
t.Logf("%d RRs parsed in %.2f s (%.2f RR/s)", z.Len(), float32(delta)/1e9, float32(z.Len())/(float32(delta)/1e9))
|
||||||
}
|
}
|
||||||
|
|
23
zone.go
23
zone.go
|
@ -7,7 +7,6 @@ package dns
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"container/vector"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,14 +36,14 @@ func NewZRRset() *ZRRset {
|
||||||
// This will be converted to some kind of tree structure
|
// This will be converted to some kind of tree structure
|
||||||
type Zone struct {
|
type Zone struct {
|
||||||
Zone map[string]map[int]*ZRRset // the contents of the zone
|
Zone map[string]map[int]*ZRRset // the contents of the zone
|
||||||
Nxt *vector.StringVector // sorted list of owernames in the zone
|
Nxt *QnameString // sorted list of owernames in the zone
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewZone returns a new *Zone
|
// NewZone returns a new *Zone
|
||||||
func NewZone() *Zone {
|
func NewZone() *Zone {
|
||||||
z := new(Zone)
|
z := new(Zone)
|
||||||
z.Zone = make(map[string]map[int]*ZRRset)
|
z.Zone = make(map[string]map[int]*ZRRset)
|
||||||
z.Nxt = new(vector.StringVector)
|
z.Nxt = NewQnameString()
|
||||||
return z
|
return z
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +108,7 @@ func (z *Zone) PushRR(r RR) {
|
||||||
if s == nil {
|
if s == nil {
|
||||||
s = NewZRRset()
|
s = NewZRRset()
|
||||||
}
|
}
|
||||||
// Add the sorted ownernames list
|
// Add to the sorted ownernames list
|
||||||
SortInsert(z.Nxt, r.Header().Name)
|
SortInsert(z.Nxt, r.Header().Name)
|
||||||
|
|
||||||
switch r.Header().Rrtype {
|
switch r.Header().Rrtype {
|
||||||
|
@ -188,10 +187,9 @@ func intval(c, t uint16) int {
|
||||||
|
|
||||||
// SortInsert insert the string s in the already sorted
|
// SortInsert insert the string s in the already sorted
|
||||||
// vector p. If s is already present it is not inserted again.
|
// vector p. If s is already present it is not inserted again.
|
||||||
func SortInsert(p *vector.StringVector, s string) {
|
func SortInsert(p *QnameString, s string) {
|
||||||
sa := sort.StringArray(*p)
|
i := sort.Search(len(*p), func(i int) bool { return (*p)[i] >= s })
|
||||||
i := sa.Search(s)
|
if i < len(*p) && (*p)[i] == s {
|
||||||
if i < p.Len() && p.At(i) == s {
|
|
||||||
// element already there
|
// element already there
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -200,15 +198,14 @@ func SortInsert(p *vector.StringVector, s string) {
|
||||||
|
|
||||||
// Search searches the sorted vector p using binary search. If
|
// Search searches the sorted vector p using binary search. If
|
||||||
// the element s can not be found, the previous element is returned.
|
// the element s can not be found, the previous element is returned.
|
||||||
func SortSearch(p *vector.StringVector, s string) string {
|
func SortSearch(p *QnameString, s string) string {
|
||||||
sa := sort.StringArray(*p)
|
i := sort.Search(len(*p), func(i int) bool { return (*p)[i] >= s })
|
||||||
i := sa.Search(s)
|
|
||||||
// with zones there must always be one before
|
// with zones there must always be one before
|
||||||
if p.At(i) == s {
|
if (*p)[i] == s {
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
i--
|
i--
|
||||||
}
|
}
|
||||||
return p.At(i)
|
return (*p)[i]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue