Documentation ¶
Index ¶
- Constants
- Variables
- func AddEDNS0NSID(m *dns.Msg)
- func AddEDNS0Subnet(m *dns.Msg, prefix netip.Prefix)
- func CollectRRs[T dns.RR](rrs []dns.RR) []T
- func GetResolverARPA(nameserverAddr string) []*dns.SVCB
- func OrderCNAMEs(a []*dns.CNAME) bool
- func ParseInstanceServiceDomain(name string) (instance string, service string, domain string)
- type Client
- func (c *Client) Close() error
- func (c *Client) Exchange(req *dns.Msg) (*dns.Msg, error)
- func (c *Client) GetAllServiceBrowserDomains(domain string) ([]string, error)
- func (c *Client) GetApexDomain(name string) (string, error)
- func (c *Client) GetDefaultServiceBrowserDomain(domain string) (string, error)
- func (c *Client) GetDesignatedResolvers(domainname string) []*DesignatedResolver
- func (c *Client) GetIP4s(domain string) ([]netip.Addr, error)
- func (c *Client) GetIP6s(domain string) ([]netip.Addr, error)
- func (c *Client) GetIPs(name string) ([]netip.Addr, error)
- func (c *Client) GetLegacyServiceBrowserDomains(domain string) ([]string, error)
- func (c *Client) GetNameservers(name string) ([]*Nameserver, error)
- func (c *Client) GetParentZoneApexDomain(name string) (string, error)
- func (c *Client) GetServiceBrowserDomains(domain string) ([]string, error)
- func (c *Client) GetServiceInstanceInfo(domain string) (*ServiceInstanceInfo, error)
- func (c *Client) GetServiceInstances(serviceDomain string) ([]string, error)
- func (c *Client) GetServices(domain string) ([]string, error)
- func (c *Client) Lookup(name string, qtype uint16) (*dns.Msg, error)
- func (c *Client) NewMsg(name string, qtype uint16) *dns.Msg
- type DesignatedResolver
- type Do53TCP
- type Do53UDP
- type DoH
- type DoT
- type Error
- type Nameserver
- type ServiceInstanceInfo
- type Transport
Constants ¶
const ( MinUDPBufSize = 0 MaxUDPBufSize = 65535 MinMaxCNAMEs = 0 MaxMaxCNAMEs = 10 DefaultDoTPort = "853" DefaultDoQPort = "853" DefaultHTTPEndpoint = "/dns-query" DefaultTimeout = 5 * time.Second DefaultUDPBufSize = 4096 // in the EDNS0 opt record )
Variables ¶
var ( // ErrRcode indicates that the DNS response has an RCODE that is not // NOERROR ([github.com/miekg/dns.RcodeSuccess]). ErrRcode error = &Error{err: "response rcode is not success"} // DNS response's rcode is something other than Sucess // ErrNoData represents the NODATA pseudo RCODE. NODATA is not a real // RCODE, but rather describes a response with an RCODE of NOERROR and zero // answers. A DNS server sends such a response when it has records for the // domain, but not of the type the client requested. ErrNoData error = &Error{err: "response has a NODATA pseudo RCODE"} // ErrInvalidCNAMEChain indicates that the response's answer contains // an invalid set of CNAMEs. There are several ways that the CNAME(s) // could be invalid, such as if the CNAMEs cannot be ordered to form a // logical chain, or if the first CNAME record's name does not match // the query's QNAME. This type of error should be rare. ErrInvalidCNAMEs error = &Error{err: "response contains an invalid CNAME chain"} // ErrBadName indicates that the response's answer contains records that // match the query's QTYPE, but none of the records match the QNAME or one // of the QNAME's CNAME aliases. This type of error should be rare. ErrBadName error = &Error{err: "response has an answer that matches neither the qname nor one of its aliases"} // ErrBadAnswer indicates that the response's answer contains data that does not conform to // its RR type. This type of error should be rare. ErrBadData error = &Error{err: "response has an answer the data does not conform to the RR type"} // ErrMaxCNAMEs indicates that the client followed its configurd maximum number of // CNAMEs without resolving the query. ErrMaxCNAMEs error = &Error{err: "query followed max number of CNAMEs"} )
These are errors that a client's Exchange method may return.
Functions ¶
func AddEDNS0NSID ¶
func CollectRRs ¶
CollectRRs takes a slice of [github.com/miekg/dns.RR]s and returns a slice of with the [github.com/miekg/dns.RR]s of type T. If not such records exist, the function returns a zero-length slice.
func GetResolverARPA ¶
func OrderCNAMEs ¶
Types ¶
type Client ¶
type Client struct { // Set the AD ("authentic data") bit in queries. Note that DNS only uses // this bit in responses; setting the bit in a query is undefined, though // harmless. Per RFC 3655, a response sets the AD if the DNS server // successfully validated the response as per DNSSEC. If the server did // not attempt to validate the records in the response, or validation // failed, the bit is 0. AD bool // Set the CD ("checking disabled") bit in queries. If the CD bit is set, // then the DNS server may omit DNSSEC validation. A client would // generally set the CD bit when it intends to perform DNSSEC validation // itself. If the query clears the bit, the server may perform perform // DNSSEC validation. CD bool // Set the DO ("DNSSEC OK") bit in queries. The DO bit indicates that the // client is DNSSEC-aware and it is OK for the DNS server to return DNSSEC // records in a response. If the bit is cleared, and the server should // not return DNSSEC records in the response. DO bool // DNSSEC // Set the RD ("recursion deisred") bit in queries. This indicates that // the DNS server should follow all delegations and resolve the query on // behalf of the client. RD bool // Send an EDNS0 Client Subnet option (RFC 7871) in queries. Either // clients or recursive resolvers may add this option. A prefix with // length 0 is indicates a client opt-opt: the recursive resolvers must not // add the this option when serviving the client's request. ClientSubnet netip.Prefix // Send the ENDS0 Name Server Identifier (NSID) option (RFC 5001) in // queries. If a server supports the option, it will return its unique // server identifer in the response. Per RFC 5001, "The semantics of an // NSID request are not transitive. That is: the presence of an NSID // option in a query is a request that the name server which receives the // query identify itself." NSID bool // The maximum number of times the client may issue a new query when // resolving a chain of CNAMEs. The client always inspects the CNAMES in a // given response to determine if these CNAMEs resolve to the requested record // type. If the chain of CNAMEs in a response terminates in a CNAME // record, only then does the client re-issue the query, replacing the // original QNAME with the last CNAME target in the chain. MaxCNAMEs int // The underlying tranport (e.g., [Do53UDP], [Do53TCP], [DoT], [DoH]) Transport Transport }
A Client defines the settings for a DNS client: the tranport, and the query settings that are agnostic to the choice of transport.
A program can modify a Client's settings in between queries. If a program wants to modify the Tranport, it should first call the Client's Close method, modify (or assign a new Transport), and then resume using the Client.
func (*Client) Exchange ¶
Exchange performs a synchronous DNS query: it sends the message req and waits for a response. The client settings (along with the client's transport's settings) determine whether (and how) to retry a query in case of an error response.
If there is a va
func (*Client) GetAllServiceBrowserDomains ¶
func (*Client) GetDefaultServiceBrowserDomain ¶
func (*Client) GetDesignatedResolvers ¶
func (c *Client) GetDesignatedResolvers(domainname string) []*DesignatedResolver
TODO: return an error
func (*Client) GetLegacyServiceBrowserDomains ¶
func (*Client) GetNameservers ¶
func (c *Client) GetNameservers(name string) ([]*Nameserver, error)
func (*Client) GetParentZoneApexDomain ¶
func (*Client) GetServiceBrowserDomains ¶
func (*Client) GetServiceInstanceInfo ¶
func (c *Client) GetServiceInstanceInfo(domain string) (*ServiceInstanceInfo, error)
func (*Client) GetServiceInstances ¶
func (*Client) Lookup ¶
Lookup is convenience method that creates a new message and then issues a synchronous query with that message.
func (*Client) NewMsg ¶
NewMsg creates a new *github.com/miekg/dns.Msg based on the client's settings. The name parameter is the query's QNAME (a domainname), and qtype is the query type (e.g., github.com/miekg/dns.TypeA). NewMSG fully-qualifies the name before constructing the query message, if it is not already fully-qualified.
type DesignatedResolver ¶
type DesignatedResolver struct { Nameserver *Nameserver ARPA []*dns.SVCB Under []*dns.SVCB }
type Do53TCP ¶
type Do53UDP ¶
type DoH ¶
type DoT ¶
type Nameserver ¶
func (*Nameserver) String ¶
func (ns *Nameserver) String() string