file

package module
v0.0.0-...-4f78afd Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

README

file

Name

file - enables serving zone data from an RFC 1035-style master file with semi-authoritative options.

Description

The file plugin 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 using DNSSEC), correct DNSSEC answers are returned. Only NSEC is supported! If you use this setup you are responsible for re-signing the zonefile.

Additionally, this modified plugin supports a semi-authoritative mode, where results not known by the nameserver are forwarded to the next chain, allowing for a horizon view if the record is not locally known for a particular record in a given zone.

Syntax

file DBFILE [ZONES...]
  • DBFILE the database file to read and parse. If the path is relative, the path from the root plugin will be prepended to it.
  • 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 plugin.

file DBFILE [ZONES... ] {
    reload DURATION
    fallthrough
}
  • reload interval to perform a reload of the zone if the SOA version changes. Default is one minute. Value of 0 means to not scan for changes and reload. For example, 30s checks the zonefile every 30 seconds and reloads the zone when serial changes.
  • fallthrough, if specified will allow NXDOMAIN and other failures to be forwarded to the next plugin chain.

If you need outgoing zone transfers, take a look at the transfer plugin.

Examples

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

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

Or use a single zone file for multiple zones:

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

Note that if you have a configuration like the following you may run into a problem of the origin not being correctly recognized:

. {
    file db.example.org
}

We omit the origin for the file db.example.org, so this references the zone in the server block, which, in this case, is the root zone. Any contents of db.example.org will then read with that origin set; this may or may not do what you want. It's better to be explicit here and specify the correct origin. This can be done in two ways:

. {
    file db.example.org example.org
}

Or

example.org {
    file db.example.org
}

See Also

See the loadbalance plugin if you need simple record shuffling. And the transfer plugin for zone transfers. Lastly the root plugin can help you specificy the location of the zone files.

Documentation

Overview

Package file implements a file backend. Modified for https://github.com/charlesportwoodii/coredns-partial`

Package file - Modified for https://github.com/charlesportwoodii/coredns-partial

Index

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

This section is empty.

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 plugin.Handler
	Zones
	// contains filtered or unexported fields
}

File is the plugin that reads zone data from disk.

func (File) Name

func (f File) Name() string

Name implements the Handler interface.

func (File) ServeDNS

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

ServeDNS implements the plugin.Handle interface.

func (File) Transfer

func (f File) Transfer(zone string, serial uint32) (<-chan []dns.RR, error)

Transfer implements the transfer.Transfer 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 Zone

type Zone struct {
	*tree.Tree
	Apex
	Expired bool

	sync.RWMutex

	StartupOnce  sync.Once
	TransferFrom []string

	ReloadInterval time.Duration

	Upstream *upstream.Upstream // Upstream for looking up external names during the resolution process.
	// contains filtered or unexported fields
}

Zone is 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, serial int64) (*Zone, error)

Parse parses the zone in filename and returns a new Zone or an error. If serial >= 0 it will reload the zone, if the SOA hasn't changed it returns an error indicating nothing was read.

func (*Zone) ApexIfDefined

func (z *Zone) ApexIfDefined() ([]dns.RR, error)

ApexIfDefined returns the apex nodes from z. The SOA record is the first record, if it does not exist, an error is returned.

func (*Zone) ClosestEncloser

func (z *Zone) ClosestEncloser(qname string) (*tree.Elem, bool)

ClosestEncloser returns the closest encloser for qname.

func (*Zone) Copy

func (z *Zone) Copy() *Zone

Copy copies a zone.

func (*Zone) CopyWithoutApex

func (z *Zone) CopyWithoutApex() *Zone

CopyWithoutApex copies zone z without the Apex records.

func (*Zone) File

func (z *Zone) File() string

File retrieves the file path in a safe way.

func (*Zone) Insert

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

Insert inserts r into z.

func (*Zone) Lookup

func (z *Zone) Lookup(ctx context.Context, state request.Request, qname string) ([]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) OnShutdown

func (z *Zone) OnShutdown() error

OnShutdown shuts down any running go-routines for this zone.

func (*Zone) Reload

func (z *Zone) Reload(t *transfer.Transfer) error

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

func (*Zone) SOASerialIfDefined

func (z *Zone) SOASerialIfDefined() int64

SOASerialIfDefined returns the SOA's serial if the zone has a SOA record in the Apex, or -1 otherwise.

func (*Zone) SetFile

func (z *Zone) SetFile(path string)

SetFile updates the file path in a safe way.

func (*Zone) Transfer

func (z *Zone) Transfer(serial uint32) (<-chan []dns.RR, error)

Transfer transfers a zone with serial in the returned channel and implements IXFR fallback, by just sending a single SOA record.

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 will 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 // A map mapping zone (origin) to the Zone's data
	Names       []string         // All the keys from the map Z as a string slice.
	Fallthrough map[string]bool
}

Zones maps zone names to a *Zone.

Directories

Path Synopsis
Package rrutil provides function to find certain RRs in slices.
Package rrutil provides function to find certain RRs in slices.
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