diff --git a/internal/dnsforward/dns.go b/internal/dnsforward/dns.go index c6c5a6b6..4a47cdc1 100644 --- a/internal/dnsforward/dns.go +++ b/internal/dnsforward/dns.go @@ -41,6 +41,12 @@ func (s *Server) handleDNSRequest(_ *proxy.Proxy, d *proxy.DNSContext) error { ctx.startTime = time.Now() type modProcessFunc func(ctx *dnsContext) int + + // Since (*dnsforward.Server).handleDNSRequest(...) is used as + // proxy.(Config).RequestHandler, there is no need for additional index + // out of range checking in any of the following functions, because the + // (*proxy.Proxy).handleDNSRequest method performs it before calling the + // appropriate handler. mods := []modProcessFunc{ processInitial, processInternalHosts, diff --git a/internal/dnsforward/msg.go b/internal/dnsforward/msg.go index 28a8ac3a..71497a6c 100644 --- a/internal/dnsforward/msg.go +++ b/internal/dnsforward/msg.go @@ -11,7 +11,8 @@ import ( "github.com/miekg/dns" ) -// Create a DNS response by DNS request and set necessary flags +// makeResponse creates a DNS response by req and sets necessary flags. It also +// guarantees that req.Question will be not empty. func (s *Server) makeResponse(req *dns.Msg) (resp *dns.Msg) { resp = &dns.Msg{ MsgHdr: dns.MsgHdr{