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

View File

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