本文整理匯總了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)
}