Documentation ¶
Overview ¶
Package doh implements client operations for DoH (DNS over HTTPS) lookups.
Index ¶
- Constants
- Variables
- type AAAARecord
- type ARecord
- type CNAMERecord
- type DNSClass
- type DNSType
- type MXRecord
- type NSRecord
- type PTRRecord
- type Resolver
- func (r *Resolver) LookupA(fqdn string) (recs []*ARecord, ttls []uint32, err error)
- func (r *Resolver) LookupAAAA(fqdn string) (recs []*AAAARecord, ttls []uint32, err error)
- func (r *Resolver) LookupCNAME(fqdn string) (recs []*CNAMERecord, ttls []uint32, err error)
- func (r *Resolver) LookupMX(fqdn string) (recs []*MXRecord, ttls []uint32, err error)
- func (r *Resolver) LookupNS(fqdn string) (recs []*NSRecord, ttls []uint32, err error)
- func (r *Resolver) LookupPTR(fqdn string) (recs []*PTRRecord, ttls []uint32, err error)
- func (r *Resolver) LookupSOA(fqdn string) (recs []*SOARecord, ttls []uint32, err error)
- func (r *Resolver) LookupSRV(fqdn string) (recs []*SRVRecord, ttls []uint32, err error)
- func (r *Resolver) LookupService(service, network, domain string) (recs []*SRVRecord, ttls []uint32, err error)
- func (r *Resolver) LookupTXT(fqdn string) (recs []*TXTRecord, ttls []uint32, err error)
- type SOARecord
- type SRVRecord
- type TXTRecord
Constants ¶
const ( // A implements the DNS A type. A DNSType = 1 // NS implements the DNS NS type. NS = 2 // CNAME implements the DNS CNAME type. CNAME = 5 // SOA implements the DNS SOA type. SOA = 6 // PTR implements the DNS PTR type. PTR = 12 // MX implements the DNS MX type. MX = 15 // TXT implements the DNS TXT type. TXT = 16 // AAAA implements the DNS AAAA type. AAAA = 28 // SRV implements the DNS SRV type. SRV = 33 )
const ( // IN implement the DNS Internet class. IN DNSClass = 1 // CS implements the DNS CSNET class. CS = 2 // CH implements the DNS CH class. CH = 3 // HS implements the DNS Hesiod class. HS = 4 // ANYCLASS implements the DNS * QCLASS. ANYCLASS = 255 )
Variables ¶
var ErrFormatError = errors.New("Format error")
ErrFormatError means that the name server was unable to interpret the query.
var ErrNameError = errors.New("Name error")
ErrNameError means that the domain name referenced in the query does not exist.
var ErrNotAResponse = errors.New("the message the server sent us isn't a response")
ErrNotAResponse means that the server responded with a message that isn't a response.
var ErrNotIN = errors.New("class must be IN (Internet) (or ANYCLASS (*), which includes IN)")
ErrNotIN means that the lookup can only be performed with the DNS class IN (e.g. A, AAAA).
var ErrNotImplemented = errors.New("Not implemented")
ErrNotImplemented means that the name server does not support the requested kind of query.
var ErrNotStandardQuery = errors.New("only standard queries are supported")
ErrNotStandardQuery means that the server responded with an OPCODE header that isn't a standard query, which is the only value currently supported.
var ErrRefused = errors.New("Refused")
ErrRefused means that The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data.
var ErrServerFailure = errors.New("Server failure")
ErrServerFailure means that The name server was unable to process this query due to a problem with the name server.
var ErrTruncated = errors.New("truncated messages aren't supported")
ErrTruncated means that the message is truncated, which isn't currently supported.
Functions ¶
This section is empty.
Types ¶
type CNAMERecord ¶
type CNAMERecord struct {
CNAME string
}
CNAMERecord implements the DNS CNAME record.
type Resolver ¶
type Resolver struct { // The host to send DoH requests to. Host string // The DNS class to lookup with, must be one of IN, CS, CH, HS or ANYCLASS. // As a hint, the most used class nowadays is IN (Internet). Class DNSClass Client *http.Client }
Resolver handles lookups.
func (*Resolver) LookupA ¶
LookupA performs a DoH lookup on A records for the given FQDN. Returns records and TTLs such that ttls[0] is the TTL for recs[0], and so on. Returns an error if something went wrong at the network level, or when parsing the response headers, or if the resolver's class isn't IN.
func (*Resolver) LookupAAAA ¶
func (r *Resolver) LookupAAAA(fqdn string) (recs []*AAAARecord, ttls []uint32, err error)
LookupAAAA performs a DoH lookup on AAAA records for the given FQDN. Returns records and TTLs such that ttls[0] is the TTL for recs[0], and so on. Returns an error if something went wrong at the network level, or when parsing the response headers, or if the resolver's class isn't IN.
func (*Resolver) LookupCNAME ¶
func (r *Resolver) LookupCNAME(fqdn string) (recs []*CNAMERecord, ttls []uint32, err error)
LookupCNAME performs a DoH lookup on CNAME records for the given FQDN. Returns records and TTLs such that ttls[0] is the TTL for recs[0], and so on. Returns an error if something went wrong at the network level, or when parsing the response headers.
func (*Resolver) LookupMX ¶
LookupMX performs a DoH lookup on CNAME records for the given FQDN. Returns records and TTLs such that ttls[0] is the TTL for recs[0], and so on. Returns an error if something went wrong at the network level, or when parsing the response headers.
func (*Resolver) LookupNS ¶
LookupNS performs a DoH lookup on CNAME records for the given FQDN. Returns records and TTLs such that ttls[0] is the TTL for recs[0], and so on. Returns an error if something went wrong at the network level, or when parsing the response headers.
func (*Resolver) LookupPTR ¶
LookupPTR performs a DoH lookup on PTR records for the given FQDN. Returns records and TTLs such that ttls[0] is the TTL for recs[0], and so on. Returns an error if something went wrong at the network level, or when parsing the response headers.
func (*Resolver) LookupSOA ¶
LookupSOA performs a DoH lookup on SOA records for the given FQDN. Returns records and TTLs such that ttls[0] is the TTL for recs[0], and so on. Returns an error if something went wrong at the network level, or when parsing the response headers.
func (*Resolver) LookupSRV ¶
LookupSRV performs a DoH lookup on SRV records for the given FQDN. Returns records and TTLs such that ttls[0] is the TTL for recs[0], and so on. Returns an error if something went wrong at the network level, or when parsing the response headers.
func (*Resolver) LookupService ¶
func (r *Resolver) LookupService(service, network, domain string) (recs []*SRVRecord, ttls []uint32, err error)
LookupService performs a DoH lookup on SRV records for the given service, network and domain. network's value is expected to be in the likes of "udp", "tcp" and so on. Under the hood, it builds a FQDN of the form _service._network.domain and calls r.LookupSRV with it. Returns records and TTLs such that ttls[0] is the TTL for recs[0], and so on. Returns an error if something went wrong at the network level, or when parsing the response headers.