func ExamplePrivateHandle() {
	dns.PrivateHandle("APAIR", TypeAPAIR, NewAPAIR)
	defer dns.PrivateHandleRemove(TypeAPAIR)

	rr, err := dns.NewRR("miek.nl. APAIR (1.2.3.4    1.2.3.5)")
	if err != nil {
		log.Fatal("could not parse APAIR record: ", err)
	}
	fmt.Println(rr)
	// Output: miek.nl.	3600	IN	APAIR	1.2.3.4 1.2.3.5

	m := new(dns.Msg)
	m.Id = 12345
	m.SetQuestion("miek.nl.", TypeAPAIR)
	m.Answer = append(m.Answer, rr)

	fmt.Println(m)
	// ;; opcode: QUERY, status: NOERROR, id: 12345
	// ;; flags: rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
	//
	// ;; QUESTION SECTION:
	// ;miek.nl.	IN	 APAIR
	//
	// ;; ANSWER SECTION:
	// miek.nl.	3600	IN	APAIR	1.2.3.4 1.2.3.5
}
// Retrieve the MX records for miek.nl.
func ExampleMX() {
	config, _ := dns.ClientConfigFromFile("/etc/resolv.conf")
	c := new(dns.Client)
	m := new(dns.Msg)
	m.SetQuestion("miek.nl.", dns.TypeMX)
	m.RecursionDesired = true
	r, _, err := c.Exchange(m, config.Servers[0]+":"+config.Port)
	if err != nil {
		return
	}
	if r.Rcode != dns.RcodeSuccess {
		return
	}
	for _, a := range r.Answer {
		if mx, ok := a.(*dns.MX); ok {
			fmt.Printf("%s\n", mx.String())
		}
	}
}
// Retrieve the DNSKEY records of a zone and convert them
// to DS records for SHA1, SHA256 and SHA384.
func ExampleDS(zone string) {
	config, _ := dns.ClientConfigFromFile("/etc/resolv.conf")
	c := new(dns.Client)
	m := new(dns.Msg)
	if zone == "" {
		zone = "miek.nl"
	}
	m.SetQuestion(dns.Fqdn(zone), dns.TypeDNSKEY)
	m.SetEdns0(4096, true)
	r, _, err := c.Exchange(m, config.Servers[0]+":"+config.Port)
	if err != nil {
		return
	}
	if r.Rcode != dns.RcodeSuccess {
		return
	}
	for _, k := range r.Answer {
		if key, ok := k.(*dns.DNSKEY); ok {
			for _, alg := range []uint8{dns.SHA1, dns.SHA256, dns.SHA384} {
				fmt.Printf("%s; %d\n", key.ToDS(alg).String(), key.Flags)
			}
		}
	}
}
func (wb *workbench) dnsHandler(w dns.ResponseWriter, r *dns.Msg) {
	wb.mu.RLock()
	defer wb.mu.RUnlock()
	defer w.Close()
	m := new(dns.Msg)
	m.SetReply(r)
	m.Compress = wb.compression

	if len(r.Question) > 1 || r.Rcode != dns.OpcodeQuery {
		m.Rcode = dns.RcodeNotImplemented
	} else if len(r.Question) == 0 {
		m.Rcode = dns.RcodeFormatError
	}
	if m.Rcode == dns.RcodeFormatError || m.Rcode == dns.RcodeNotImplemented {
		w.WriteMsg(m)
		return
	}

	q := &r.Question[0]

	wb.l.Printf("Received query for [%s] %s\n", dns.TypeToString[q.Qtype], q.Name)
	allRecords, present := wb.z[q.Name]
	if !present {
		m.Rcode = dns.RcodeNameError
		w.WriteMsg(m)
		return
	}

	if auth, present := wb.a[q.Name]; present {
		m.Authoritative = true
		m.Ns = append(m.Ns, *auth)
	}

	qRecords, present := allRecords[q.Qtype]
	if !present {
		m.Rcode = dns.RcodeNXRrset
		w.WriteMsg(m)
		return
	}

	m.Answer = append(m.Answer, qRecords...)
	w.WriteMsg(m)
	return
}