server

package
v0.0.0-...-3d5472b Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckConfig

func CheckConfig(config *Config) error

func Fit

func Fit(m *dns.Msg, size int, tcp bool) (*dns.Msg, bool)

Fit will make m fit the size. If a message is larger than size then entire additional section is dropped. If it is still to large and the transport is udp we return a truncated message. If the transport is tcp we are going to drop RR from the answer section until it fits. When this is case the returned bool is true.

func New

func New(hostfile Hostfile, config *Config, v string) *server

New returns a new server.

func ResolvConf

func ResolvConf(config *Config, ctx *cli.Context) error

Types

type Config

type Config struct {
	// The ip:port go-dnsmasq should be listening on for incoming DNS requests.
	DnsAddr string `json:"dns_addr,omitempty"`
	// bind to port(s) activated by systemd. If set to true, this overrides DnsAddr.
	Systemd bool `json:"systemd,omitempty"`
	// Rewrite host's network config making go-dnsmasq the default resolver
	DefaultResolver bool `json:"default_resolver,omitempty"`
	// Search domains used to qualify queries
	SearchDomains []string `json:"search_domains,omitempty"`
	// Replicates GNU libc's use of /etc/resolv.conf search domains
	EnableSearch bool `json:"append_domain,omitempty"`
	// Path to the hostfile
	Hostsfile string `json:"hostfile,omitempty"`
	// Hostfile Polling
	PollInterval int `json:"poll_interval,omitempty"`
	// Round robin A/AAAA replies. Default is true.
	RoundRobin bool `json:"round_robin,omitempty"`
	// List of ip:port, seperated by commas of recursive nameservers to forward queries to.
	Nameservers []string `json:"nameservers,omitempty"`
	// Never provide a recursive service.
	NoRec       bool          `json:"no_rec,omitempty"`
	ReadTimeout time.Duration `json:"read_timeout,omitempty"`
	// Default TTL, in seconds. Defaults to 360.
	Ttl uint32 `json:"ttl,omitempty"`
	// Default TTL for Hostfile records, in seconds. Defaults to 30.
	HostsTtl uint32 `json:"hostfile_ttl,omitempty"`
	// RCache, capacity of response cache in resource records stored.
	RCache int `json:"rcache,omitempty"`
	// RCacheTtl, how long to cache in seconds.
	RCacheTtl int `json:"rcache_ttl,omitempty"`
	// How many dots a name must have before we allow to forward the query as-is. Defaults to 1.
	FwdNdots int `json:"fwd_ndots,omitempty"`
	// How many dots a name must have before we do an initial absolute query. Defaults to 1.
	Ndots int `json:"ndots,omitempty"`

	Verbose bool `json:"-"`

	// Stub zones support. Map contains domainname -> nameserver:port
	Stub *map[string][]string
}

Config provides options to the go-dnsmasq resolver

type Counter

type Counter interface {
	Inc(i int64)
}

Counter is the metric interface used by this package

var (
	StatsForwardCount     Counter = nopCounter{}
	StatsStubForwardCount Counter = nopCounter{}
	StatsLookupCount      Counter = nopCounter{}
	StatsRequestCount     Counter = nopCounter{}
	StatsDnssecOkCount    Counter = nopCounter{}
	StatsNameErrorCount   Counter = nopCounter{}
	StatsNoDataCount      Counter = nopCounter{}

	StatsDnssecCacheMiss Counter = nopCounter{}

	StatsCacheMiss Counter = nopCounter{}
	StatsCacheHit  Counter = nopCounter{}
)

type Hostfile

type Hostfile interface {
	FindHosts(name string) ([]net.IP, error)
	FindReverse(name string) (string, error)
}

Jump to

Keyboard shortcuts

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