Remove radix from core go dns

This commit is contained in:
Miek Gieben 2013-05-04 23:21:01 +02:00
parent 45775dff76
commit 07d0e08366
1 changed files with 7 additions and 5 deletions

View File

@ -169,14 +169,14 @@ func (mux *ServeMux) match(q string, t uint16) Handler {
defer mux.m.RUnlock()
var (
handler Handler
lastdot int
lastdot int = -1
lastbyte byte
seendot bool = true
)
// TODO(mg): check for .
for i := 0; i < len(q); i++ {
if seendot {
if h, ok := mux.z[q[lastdot:]]; ok {
if h, ok := mux.z[q[lastdot+1:]]; ok {
if t != TypeDS {
return h
} else {
@ -194,10 +194,12 @@ func (mux *ServeMux) match(q string, t uint16) Handler {
}
lastbyte = q[i]
}
if handler != nil {
return handler
// Check for the root zone too, this only delays NXDOMAIN, because if we serve . it
// will be catched above.
if h, ok := mux.z["."]; ok {
return h
}
return nil
return handler
}
// Handle adds a handler to the ServeMux for pattern.