resolv

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: 12 Imported by: 1

README

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

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

Documentation

Overview

Package resolv supports resolv.conf formatted data (see also `man resolv.conf`). Supported are conversions from a file or string to an internal representation and back to a string.

Index

Constants

This section is empty.

Variables

System resolv.conf name

Functions

This section is empty.

Types

type Cfg

type Cfg struct {
	// contains filtered or unexported fields
}

Cfg represents a resolv.conf with a change/modification guard/handler. Methods of Cfg are synchronized; multiple goroutines may invoke them concurrently.

func NewCfg

func NewCfg(fname string, logger *dns.Logger) (c *Cfg, err error)

NewCfg returns a newly created Cfg with resolv.Conf initialized from file fname of an Error of any. It binds the contained resolv.Conf to fname and on any changes to the fname file the Cfg resolv.Conf is reloaded on access via Cfg.Conf().

func (*Cfg) Conf

func (c *Cfg) Conf() (f *Conf, changed bool, err error)

Conf returns a resolv.Conf from Cfg and an indicator of its source file has been changed/modificated compared to the last invocation of this function or an Error if any.

func (*Cfg) SetChanged

func (c *Cfg) SetChanged()

SetChanged forces next Conf() to handle modification of the wrapped resolv.Conf.

type Conf

type Conf struct {
	// Internet address (in dot notation) of a name server that the resolver should query.
	Nameserver []net.IP
	// Local domain name.
	Domain string
	// Resolver queries having fewer than ndots dots (default  is  1)
	// in them will be attempted using each component of the search path
	// in turn until a match is found.
	Search []string
	// This option allows addresses returned by a resolver to be sorted.
	Sortlist []SortlistItem
	Opt      struct {
		Debug bool
		// The number of dots which must appear in a name before an initial absolute query will be made.
		// Default: 1
		Ndots uint
		// Amount of time the resolver will wait for a response from a remote name server before retry.
		// Default: 5
		TimeoutSecs uint
		// Number of times the resolver will send a query to its name servers before giving up.
		// Default: 2
		Attempts uint
		// Round robin selection of nameservers from among those listed.
		Rotate bool
		// Disables the modern BIND checking of incoming hostnames and mail names for invalid characters.
		NoCheckNames bool
		// Try an AAAA query before an A query.
		Inet6 bool
		// This causes reverse IPv6 lookups to be made using the bit-label format described in RFC 2673.
		Ip6ByteString bool
		// Reverse IPv6 lookups are made in the (deprecated) ip6.int zone.
		Ip6Dotint bool
		// Enables support for the DNS extensions described in RFC 2671.
		Edns0 bool
	}
}

A Conf holds the data found in a resolver configuration file, e.g. '/etc/resolv.conf'. See also resolv.conf(5)

func NewConf

func NewConf() (c *Conf)

Return a constructed Conf with sane defaults

func (*Conf) AppendNameserver

func (c *Conf) AppendNameserver(ip net.IP) (err error)

func (*Conf) AppendSearch

func (c *Conf) AppendSearch(s string) (err error)

func (*Conf) AppendSortlist

func (c *Conf) AppendSortlist(addr, mask net.IP) (err error)

func (*Conf) Load

func (c *Conf) Load(fname string) (err error)

Load Conf c from a resolv.conf format file fname. Return an Error, if any.

func (*Conf) LoadString

func (c *Conf) LoadString(fname, s string) (err error)

Load Conf c with from a resolv.conf format string s. Return an Error, if any.

func (*Conf) String

func (c *Conf) String() string

type GoCfg

type GoCfg struct {
	// contains filtered or unexported fields
}

GoCfg is a Cfg wrapped in a goroutine allowing for concurrent access.

func NewGoCfg

func NewGoCfg(fname string, logger *dns.Logger) (c *GoCfg, err error)

NewGoCfg returns a newly created GoCfg or an Error if any. It is assumed there will be only one/few GoCfg instance(s) in an application. The instance(s) and its associated goroutine(s) will never be released. This is by design in an atempt to avoid some possibly nasty races on finalization. The "impossible to release" doesn't apply when NewGoCfg returns an Error.

func (*GoCfg) Conf

func (c *GoCfg) Conf() (f *Conf, changed bool, err error)

Conf returns a Conf from GoCfg and an indicator if its source file has been changed/modificated compared to the last invocation of this function or an Error if any. Invocations of Conf are concurrent safe.

type SortlistItem

type SortlistItem struct {
	Addr, NetMask net.IP // The netmask is optional and defaults to the natural netmask of the net.
}

'sortlist' Conf option

func (*SortlistItem) String

func (i *SortlistItem) String() string

Jump to

Keyboard shortcuts

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