zone

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2025 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package implement a DNS zone, held in a binary tree. Each RR(set) that gets inserted will need to create any empty non-terminals (ENT) it possesses. I.e. inserting www.example.org into example.org is easy, but when www.a.b.c.example.org inserts we need to make sure that 'c.example.org', 'b.c.example.org' and 'a.b.c.example.org' also exist and are ENTs (have no actual RRs). For deleted the opposite must happen. As an example from RFC 4592, the record: sub.*.example. TXT "this is not a wildcard" is a fun one. As this means the '*.example' ENT exists meaning that bogus.example. gets a NODATA response instead of NXDOMAIN.

Doing this on insert sucks a bit, but makes the lookup code much more simple (and correct), which is more important for a DNS server.

CNAME, DNSSEC, wildcards, etc. are all supported. Not supported is: DNAME (RFC 6672), the server will just return the DNAME without any of the (in the RFC required) post-processing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Zone

type Zone struct {
	Path string
	Tree *btree.BTreeG[dnszone.Node]
	// contains filtered or unexported fields
}

Zone holds the main zone and some meta data of the DNS zone we are serving. There is no locking, because after creation this structure is basically read-only. Tree will be used to write, but that has its own locking.

func New

func New(origin, path string) *Zone

func (*Zone) Apex

func (z *Zone) Apex() dnszone.Node

func (*Zone) AuthoritativeWalk

func (z *Zone) AuthoritativeWalk(fn func(dnszone.Node, bool) bool)

AuthoritativeWalk walks the the zone, but keeps track of authoritative names and call fn auth a boolean indicating is the name is considered that.

func (*Zone) Get

func (z *Zone) Get(name string) (dnszone.Node, bool)

Get gets the node under name from z.

func (*Zone) Labels

func (z *Zone) Labels() int

func (*Zone) Load

func (z *Zone) Load() error

Load loads a new zone with origin from path from z. Load also sets the apex, so the z.Apex can return that.

func (*Zone) Origin

func (z *Zone) Origin() string

func (*Zone) Previous

func (z *Zone) Previous(name string) dnszone.Node

Previous returns the logical previous name from name.

func (*Zone) Set

func (z *Zone) Set(node dnszone.Node) string

Set sets the RRs in the zone. It needs to create any empty non-terminals it has. Meaning for each label a lookup is done if there already is an empty non-terminal, if not an empty set is inserted. We should never be called to insert ENT (or names without RRs attached to them.

func (*Zone) Walk

func (z *Zone) Walk(fn func(dnszone.Node) bool)

Walk walks the zone and calls fn on each element found, as long as f returns true the walk is continued. The order of the walk is ascending order: from apex to longest child.

Jump to

Keyboard shortcuts

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