Documentation ¶
Overview ¶
Package resolver is a simple DNS resolver.
Index ¶
- Variables
- type LookupResult
- type Resolver
- func (r *Resolver) Cache() *cache.Cache
- func (r *Resolver) GetHostByAddr(ip net.IP) (hosts []string, err error)
- func (r *Resolver) GetHostByName(name string, preferIPv6 bool) (ipList []net.IP, redirects rr.RRs, err error)
- func (r *Resolver) GetHostByNameIPv4(name string) (ipList []net.IP, redirects rr.RRs, err error)
- func (r *Resolver) GetHostByNameIPv6(name string) (ipList []net.IP, redirects rr.RRs, err error)
- func (r *Resolver) Logger() *dns.Logger
- func (r *Resolver) Lookup(sname string, stype msg.QType, sclass rr.Class, rd bool) (answer, redirects rr.RRs, result LookupResult, err error)
Constants ¶
This section is empty.
Variables ¶
var LookupResultStr = map[LookupResult]string{ LookupOK: "Sucess", LookupAliased: "Sucess. QNAME is an alias and the result is for its canonical name", LookupNameError: "QNAME doesn't exist", LookupDataNotFound: "QNAME does exist, but no data for the combination of QTYPE and QCLASS were found", LookupFail: "Lookup fail. Could be also wrong resolver configuration or network communication error.", LookupAliasLoop: "Detected a cycle in the aliases chain", LookupAliasError: "QNAME is an alias to a non existing canonical name", }
Functions ¶
This section is empty.
Types ¶
type LookupResult ¶
type LookupResult int
LookupResult is the type of the Resolver.Lookup() result.
const ( LookupOK LookupResult = iota // Sucess LookupAliased // Sucess, but QNAME is an alias and the result is for its canonical name LookupNameError // QNAME doesn't exist LookupDataNotFound // QNAME does exist, but no data for the combination of QTYPE and QCLASS were found LookupFail // E.g. can't contact any DNS server (wrong conf or network communication error) LookupAliasLoop // Detected a cycle in the aliases chain LookupAliasError // QNAME is an alias to a non existing canonical name )
Values of LookupResult.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver is a DNS resolver.
func New ¶
New returns a new Resolver or an error if any.
'hostsFName' is like "/etc/hosts" and may be empty in which case hosts.Sys() will be used.
'resolvFName' is like "/etc/resolv.conf" and may again be empty in which case resolv.Sys() is used.
'logger' may be nil.
func (*Resolver) GetHostByAddr ¶
GetHostByAddr will try to resolve an IPv4 or IPv6 address to host name(s).
func (*Resolver) GetHostByName ¶
func (r *Resolver) GetHostByName(name string, preferIPv6 bool) (ipList []net.IP, redirects rr.RRs, err error)
GetHostByName will try to Lookup an IN A or AAAA address (i.e. IPv4 or IPv6) list for name. Used CNAMEs chain, if any, is returned in redirects. Initially an attempt for IPv4 addresses is performed. Query for the IPv6 addresses is afterwards invoked iff no IPv4 addresses were returned by the initial attempt. If preferIPv6 == true then the above query order is reversed.
func (*Resolver) GetHostByNameIPv4 ¶
GetHostByNameIPv4 will try to Lookup an IN A address (i.e. IPv4) list for name. Used CNAMEs chain, if any, is returned in redirects.
func (*Resolver) GetHostByNameIPv6 ¶
GetHostByNameIPv6 will try to Lookup an IN AAAA address (i.e. IPv6) list for name. Used CNAMEs chain, if any, is returned in redirects.
func (*Resolver) Lookup ¶
func (r *Resolver) Lookup(sname string, stype msg.QType, sclass rr.Class, rd bool) (answer, redirects rr.RRs, result LookupResult, err error)
Lookup is a general DNS lookup function (rfc1034/p.30). It attempts to retrieve arbitrary information from the DNS. The caller supplies a sname, stype and sclass, and wants all of the matching RRs. Lookup should normally report "DNS lookup error" results via the return result variable. A non-nil Error is returned for any non-lookup error event. The rd parameter is the msg.Messsage.Header "Recursion Desired" flag. Lookup CNAMEs chain walked, if any, is returned in redirects.