Use strings.ToLower in server
Automatically submitted.
@@ -6,6 +6,7 @@ import (
"fmt"
"net"
"runtime"
+ "strings"
"sync"
"time"
@@ -217,27 +218,18 @@ func (s *Server) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg)
return
}
- q := r.Question[0].Name
- b := make([]byte, len(q))
- var off int
- var end bool
-
- var dshandler *Config
-
// Wrap the response writer in a ScrubWriter so we automatically make the reply fit in the client's buffer.
w = request.NewScrubWriter(r, w)
- for {
- l := len(q[off:])
- for i := 0; i < l; i++ {
- b[i] = q[off+i]
- // normalize the name for the lookup
- if b[i] >= 'A' && b[i] <= 'Z' {
- b[i] |= ('a' - 'A')
- }
- }
+ q := strings.ToLower(r.Question[0].Name)
+ var (
+ off int
+ end bool
+ dshandler *Config
+ )
- if h, ok := s.zones[string(b[:l])]; ok {
+ for {
+ if h, ok := s.zones[q[off:]]; ok {
if r.Question[0].Qtype != dns.TypeDS {
if h.FilterFunc == nil {
rcode, _ := h.pluginChain.ServeDNS(ctx, w, r)
