file

package
v0.0.0-...-15297c8 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

README

file

file enables serving zone data from an RFC 1035-style master file.

The file middleware is used for an "old-style" DNS server. It serves from a preloaded file that exists on disk. If the zone file contains signatures (i.e. is signed, i.e. DNSSEC) correct DNSSEC answers are returned. Only NSEC is supported! If you use this setup you are responsible for resigning the zonefile.

Syntax

file dbfile [zones...]
  • dbfile the database file to read and parse.
  • zones zones it should be authoritative for. If empty, the zones from the configuration block are used.

If you want to round robin A and AAAA responses look at the loadbalance middleware.

TSIG key configuration is TODO; directive format for transfer will probably be extended with TSIG key information, something like transfer out [address...] key [name] [base64]

file dbfile [zones... ] {
    transfer from [address...]
    transfer to [address...]
    no_reload
}
  • transfer enables zone transfers. It may be specified multiples times. To or from signals the direction. Addresses must be denoted in CIDR notation (127.0.0.1/32 etc.) or just as plain addresses. The special wildcard * means: the entire internet (only valid for 'transfer to'). When an address is specified a notify message will be send whenever the zone is reloaded.
  • no_reload by default CoreDNS will reload a zone from disk whenever it detects a change to the file. This option disables that behavior.

Examples

Load the example.org zone from example.org.signed and allow transfers to the internet, but send notifies to 10.240.1.1

file example.org.signed example.org {
    transfer to *
    transfer to 10.240.1.1
}

Documentation

Index

Examples

Constants

View Source
const MaxSerialIncrement uint32 = 2147483647

MaxSerialIncrement is the maximum difference between two serial numbers. If the difference between two serials is greater than this number, the smaller one is considered greater.

Variables

This section is empty.

Functions

func TransferParse

func TransferParse(c *caddy.Controller) (tos, froms []string, err error)

TransferParse parses transfer statements: 'transfer to [address...]'. Exported so secondary can use this as well.

Types

type Apex

type Apex struct {
	SOA    *dns.SOA
	NS     []dns.RR
	SIGSOA []dns.RR
	SIGNS  []dns.RR
}

Apex contains the apex records of a zone: SOA, NS and their potential signatures.

type File

type File struct {
	Next  middleware.Handler
	Zones Zones
}

File is the middleware that reads zone data from disk.

func (File) ServeDNS

func (f File) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the middleware.Handle interface.

type Result

type Result int

Result is the result of a Lookup

const (
	// Success is a successful lookup.
	Success Result = iota
	// NameError indicates a nameerror
	NameError
	// Delegation indicates the lookup resulted in a delegation.
	Delegation
	// NoData indicates the lookup resulted in a NODATA.
	NoData
	// ServerFailure indicates a server failure during the lookup.
	ServerFailure
)

type Xfr

type Xfr struct {
	*Zone
}

Xfr serves up an AXFR.

func (Xfr) ServeDNS

func (x Xfr) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the middleware.Handler interface.

type Zone

type Zone struct {
	*tree.Tree
	Apex Apex

	TransferTo   []string
	StartupOnce  sync.Once
	TransferFrom []string
	Expired      *bool

	NoReload bool
	// contains filtered or unexported fields
}

Zone defines a structure that contains all data related to a DNS zone.

func NewZone

func NewZone(name, file string) *Zone

NewZone returns a new zone.

func Parse

func Parse(f io.Reader, origin, fileName string) (*Zone, error)

Parse parses the zone in filename and returns a new Zone or an error.

func (*Zone) All

func (z *Zone) All() []dns.RR

All returns all records from the zone, the first record will be the SOA record, otionally followed by all RRSIG(SOA)s.

Example
zone, err := Parse(strings.NewReader(dbMiekNL), testzone, "stdin")
if err != nil {
	return
}
records := zone.All()
for _, r := range records {
	fmt.Printf("%+v\n", r)
}
// Output
// xfr_test.go:15: miek.nl.	1800	IN	SOA	linode.atoom.net. miek.miek.nl. 1282630057 14400 3600 604800 14400
// xfr_test.go:15: www.miek.nl.	1800	IN	CNAME	a.miek.nl.
// xfr_test.go:15: miek.nl.	1800	IN	NS	linode.atoom.net.
// xfr_test.go:15: miek.nl.	1800	IN	NS	ns-ext.nlnetlabs.nl.
// xfr_test.go:15: miek.nl.	1800	IN	NS	omval.tednet.nl.
// xfr_test.go:15: miek.nl.	1800	IN	NS	ext.ns.whyscream.net.
// xfr_test.go:15: miek.nl.	1800	IN	MX	1 aspmx.l.google.com.
// xfr_test.go:15: miek.nl.	1800	IN	MX	5 alt1.aspmx.l.google.com.
// xfr_test.go:15: miek.nl.	1800	IN	MX	5 alt2.aspmx.l.google.com.
// xfr_test.go:15: miek.nl.	1800	IN	MX	10 aspmx2.googlemail.com.
// xfr_test.go:15: miek.nl.	1800	IN	MX	10 aspmx3.googlemail.com.
// xfr_test.go:15: miek.nl.	1800	IN	A	139.162.196.78
// xfr_test.go:15: miek.nl.	1800	IN	AAAA	2a01:7e00::f03c:91ff:fef1:6735
// xfr_test.go:15: archive.miek.nl.	1800	IN	CNAME	a.miek.nl.
// xfr_test.go:15: a.miek.nl.	1800	IN	A	139.162.196.78
// xfr_test.go:15: a.miek.nl.	1800	IN	AAAA	2a01:7e00::f03c:91ff:fef1:6735
Output:

func (*Zone) ClosestEncloser

func (z *Zone) ClosestEncloser(qname string, qtype uint16) string

ClosestEncloser returns the closest encloser for rr.

func (*Zone) Copy

func (z *Zone) Copy() *Zone

Copy copies a zone *without* copying the zone's content. It is not a deep copy.

func (*Zone) Delete

func (z *Zone) Delete(r dns.RR)

Delete deletes r from z.

func (*Zone) Insert

func (z *Zone) Insert(r dns.RR) error

Insert inserts r into z.

func (*Zone) Lookup

func (z *Zone) Lookup(qname string, qtype uint16, do bool) ([]dns.RR, []dns.RR, []dns.RR, Result)

Lookup looks up qname and qtype in the zone. When do is true DNSSEC records are included. Three sets of records are returned, one for the answer, one for authority and one for the additional section.

func (*Zone) Notify

func (z *Zone) Notify()

Notify will send notifies to all configured TransferTo IP addresses.

func (*Zone) Reload

func (z *Zone) Reload(shutdown chan bool) error

Reload reloads a zone when it is changed on disk. If z.NoRoload is true, no reloading will be done.

func (*Zone) TransferAllowed

func (z *Zone) TransferAllowed(req request.Request) bool

TransferAllowed checks if incoming request for transferring the zone is allowed according to the ACLs.

func (*Zone) TransferIn

func (z *Zone) TransferIn() error

TransferIn retrieves the zone from the masters, parses it and sets it live.

func (*Zone) Update

func (z *Zone) Update() error

Update updates the secondary zone according to its SOA. It will run for the life time of the server and uses the SOA parameters. Every refresh it will check for a new SOA number. If that fails (for all server) it wil retry every retry interval. If the zone failed to transfer before the expire, the zone will be marked expired.

type Zones

type Zones struct {
	Z     map[string]*Zone
	Names []string
}

Zones maps zone names to a *Zone.

Directories

Path Synopsis
Package tree implements Left-Leaning Red Black trees as described by Robert Sedgewick.
Package tree implements Left-Leaning Red Black trees as described by Robert Sedgewick.

Jump to

Keyboard shortcuts

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