resolver

package
v0.0.0-...-8a2913d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 22, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 15 Imported by: 0

README

This is a goinstall-able mirror of modified code already published at:
http://git.nic.cz/redmine/projects/godns/repository/show/resolver

Online godoc documentation for this package (should be) available at:
http://gopkgdoc.appspot.com/pkg/github.com/cznic/dns/resolver

Documentation

Overview

Package resolver is a simple DNS resolver.

Index

Constants

This section is empty.

Variables

View Source
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

func New(hostsFName, resolvFName string, logger *dns.Logger) (r *Resolver, err error)

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) Cache

func (r *Resolver) Cache() *cache.Cache

Cache returns the Resolver's Cache

func (*Resolver) GetHostByAddr

func (r *Resolver) GetHostByAddr(ip net.IP) (hosts []string, err error)

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

func (r *Resolver) GetHostByNameIPv4(name string) (ipList []net.IP, redirects rr.RRs, err error)

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

func (r *Resolver) GetHostByNameIPv6(name string) (ipList []net.IP, redirects rr.RRs, err error)

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) Logger

func (r *Resolver) Logger() *dns.Logger

Logger returns the Resolver's Logger

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL