func handleQuery(w dns.ResponseWriter, req *dns.Msg) { var dnssec bool m := new(dns.Msg) if req.Question[0].Qclass != dns.ClassINET { m.SetRcode(req, dns.RcodeServerFailure) send(w, m) return } m.SetReply(req) m.Ns = ns m.Extra = make([]dns.RR, 1) m.Extra[0] = spamIN // Check DNSSEC OK for _, v := range req.Extra { if o, ok := v.(*dns.RR_OPT); ok { if dnssec = o.Do(); dnssec { m.Extra = append(m.Extra, o) m.Ns = nsDNSSEC break } } } //m.Answer = make([]dns.RR, 0) s, _ := zone.LookupQuestion(req.Question[0]) if s == nil { // Authority section should only contain the SOA record for NXDOMAIN m.Ns = m.Ns[:1] m.Ns[0] = soa m.MsgHdr.Rcode = dns.RcodeNameError send(w, m) // Lookup the previous name in the Nxt list for this zone // and insert the nsec/nsec3 from that. Also give the nsec // that proofs there is no wildcard return } // TODO CNAME //cname: switch req.Question[0].Qtype { case dns.TypeRRSIG: m.Answer = s.RRsigs case dns.TypeNSEC, dns.TypeNSEC3: m.Answer = []dns.RR{s.Nxt} default: m.Answer = s.RRs } if dnssec && req.Question[0].Qtype != dns.TypeRRSIG && len(s.RRsigs) > 0 { for _, r := range s.RRsigs { m.Answer = append(m.Answer, r) } } if *debug { println(m.Question[0].String()) } send(w, m) }