func (d MiekgDecoder) Decode(qtype uint16, data []byte) ([]string, error) {
	reply := new(dns.Msg)
	if err := reply.Unpack(data); err != nil {
		return nil, err
	}
	switch reply.Rcode {
	case dns.RcodeSuccess:
	case dns.RcodeNameError:
		return nil, errors.New("ooniresolver: no such host")
	default:
		return nil, errors.New("ooniresolver: query failed")
	}
	var addrs []string
	for _, answer := range reply.Answer {
		switch qtype {
		case dns.TypeA:
			if rra, ok := answer.(*dns.A); ok {
				ip := rra.A
				addrs = append(addrs, ip.String())
			}
		case dns.TypeAAAA:
			if rra, ok := answer.(*dns.AAAA); ok {
				ip := rra.AAAA
				addrs = append(addrs, ip.String())
			}
		}
	}
	if len(addrs) <= 0 {
		return nil, errors.New("ooniresolver: no response returned")
	}
	return addrs, nil
}
Decode implements Decoder.Decode.
package resolver
import (
	"errors"
	"github.com/miekg/dns"
)
type Decoder interface {
	Decode(qtype uint16, data []byte) ([]string, error)
}
type MiekgDecoder struct{}