本文整理汇总了Golang中dns.Msg.Ns方法的典型用法代码示例。如果您正苦于以下问题:Golang Msg.Ns方法的具体用法?Golang Msg.Ns怎么用?Golang Msg.Ns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dns.Msg
的用法示例。
在下文中一共展示了Msg.Ns方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleQuery
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)
}