Workaround a bug causing Unbound to refuse returning anything about the root

This commit is contained in:
Star Brilliant
2018-06-26 03:04:34 +08:00
parent 06ce104d2a
commit 82fe91395d

View File

@@ -164,6 +164,8 @@ func (s *Server) handlerFunc(w http.ResponseWriter, r *http.Request) {
return
}
req = s.patchRootRD(req)
var err error
req, err = s.doDNSQuery(req)
if err != nil {
@@ -209,6 +211,16 @@ func (s *Server) findClientIP(r *http.Request) net.IP {
return nil
}
// Workaround a bug causing Unbound to refuse returning anything about the root
func (s *Server) patchRootRD(req *DNSRequest) *DNSRequest {
for _, question := range req.request.Question {
if question.Name == "." {
req.request.RecursionDesired = true
}
}
return req
}
func (s *Server) doDNSQuery(req *DNSRequest) (resp *DNSRequest, err error) {
numServers := len(s.conf.Upstream)
for i := uint(0); i < s.conf.Tries; i++ {