Beispiel #1
0
func newConnMsg(qname, nameserver string, attempts int, qtype, qclass uint16, aa, ad, cd, rd, dnssec, nsid bool) (*dns.Conn, *dns.Msg) {
	d := new(dns.Conn)
	d.RemoteAddr = nameserver
	d.Attempts = attempts

	m := new(dns.Msg)
	m.MsgHdr.Authoritative = aa
	m.MsgHdr.AuthenticatedData = ad
	m.MsgHdr.CheckingDisabled = cd
	m.MsgHdr.RecursionDesired = rd
	m.Question = make([]dns.Question, 1)
	if dnssec || nsid {
		opt := new(dns.RR_OPT)
		opt.SetDo()
		opt.SetVersion(0)
		opt.SetUDPSize(dns.DefaultMsgSize)
		if nsid {
			opt.SetNsid("")
		}
		m.Extra = make([]dns.RR, 1)
		m.Extra[0] = opt
	}
	m.Question[0] = dns.Question{qname, qtype, qclass}
	m.Id = dns.Id()
	return d, m
}