secondary

package
v0.8.43 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: MIT Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package secondary keeps locally-served copies of zones transferred from a primary server (RFC 5936 AXFR, RFC 1995 IXFR, RFC 9103 over TLS, RFC 8945 TSIG), including zones discovered through a catalog zone (RFC 9432).

This is what makes the xfr package reachable. Labyrinth had a correct AXFR-over-TLS client for some time that nothing called: the transfer code existed, the compliance matrix claimed RFC 9103, and no configuration could cause a single byte to be transferred. A zone transfer is only useful if something serves the result, and that is this package's job.

What a secondary zone is here

Labyrinth is a recursive resolver, not an authoritative server. A secondary zone is served from the local zone table — the same mechanism that answers operator-configured static records — so queries for names inside it are answered from the transferred copy instead of being resolved iteratively. It does not make Labyrinth authoritative for the zone on the public internet: there is no AA-bit authority delegation, no NOTIFY listener, and no onward transfer to other secondaries.

The use case it serves is the common internal one: an organisation runs a private zone on a primary, and wants every resolver in the fleet to answer from a local copy rather than forwarding each query.

Refresh strategy

The zone's own SOA governs when to re-transfer (RFC 1035 §3.3.13): REFRESH between successful checks, RETRY after a failure, and EXPIRE as the point past which the copy must not be served at all. Honouring EXPIRE matters more than it looks — a secondary that keeps answering from a copy whose primary vanished a month ago is serving data the zone owner believes they retired.

Index

Constants

View Source
const CatalogVersion = "2"

CatalogVersion is the only catalog schema version defined (RFC 9432 §4.2.2).

Variables

View Source
var (
	// ErrCatalogNoVersion is returned when the version property is missing.
	// Distinct from a parse failure: a catalog with no version is
	// well-formed DNS that must not be acted on.
	ErrCatalogNoVersion = errors.New("catalog: no version property — RFC 9432 §4.2.2 requires version.<catalog> TXT")
	// ErrCatalogBadVersion is returned for a version this build does not
	// implement.
	ErrCatalogBadVersion = errors.New("catalog: unsupported catalog version")
)

Functions

This section is empty.

Types

type CatalogConfig

type CatalogConfig struct {
	Name          string
	PrimaryAddr   string
	UseTLS        bool
	TLSServerName string
	TSIGKey       dns.TSIGKey
}

CatalogConfig describes a catalog zone (RFC 9432) whose members are provisioned automatically.

Members inherit this catalog's transfer parameters — same primary, same TSIG key, same transport. RFC 9432 §5.1 leaves the mapping from catalog entries to transfer configuration implementation-defined, and inheritance is the only mapping that needs no second configuration surface: the catalog says *which* zones, the catalog's own settings say *how*.

type Manager

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

Manager transfers and refreshes secondary zones, republishing the resolver's local zone table after each successful transfer.

func NewManager

func NewManager(res *resolver.Resolver, static []resolver.LocalZone, zones []ZoneConfig, catalogs []CatalogConfig, logger *slog.Logger) *Manager

NewManager creates a secondary-zone manager.

`static` is the set of locally-configured zones that must survive every republish. The manager rebuilds the whole table each time a transfer completes — the table is immutable by design — so it has to hold onto the zones it did not create, or the first successful transfer would silently delete every operator-configured local zone.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context)

Run transfers every configured zone, follows every catalog, and keeps them refreshed until ctx is cancelled.

type MemberZone

type MemberZone struct {
	// Name is the member zone's name, from the PTR record's target.
	Name string
	// UniqueID is the opaque label the entry lives under. Kept for logging
	// and for change-of-ownership handling; it carries no meaning and must
	// not be parsed (RFC 9432 §4.3.1).
	UniqueID string
	// Group is the optional group property (RFC 9432 §5.1). The RFC leaves
	// its use implementation-defined; here it is surfaced for logging and
	// for operators to key their own conventions on.
	Group string
}

MemberZone is one zone listed by a catalog.

func ParseCatalog

func ParseCatalog(catalogName string, records []dns.ResourceRecord) ([]MemberZone, error)

ParseCatalog extracts the member zones from a transferred catalog zone.

`catalogName` is the catalog zone's own apex, needed because every owner name in the zone is interpreted relative to it.

Returns an error rather than an empty list when the catalog cannot be processed. The distinction matters to the caller: "this catalog lists no zones" is an instruction to withdraw everything, while "this catalog cannot be understood" must leave the current provisioning alone.

type ZoneConfig

type ZoneConfig struct {
	// Name is the zone apex, e.g. "internal.example".
	Name string
	// PrimaryAddr is the primary server to transfer from.
	PrimaryAddr string
	// UseTLS enables XFR-over-TLS (RFC 9103).
	UseTLS bool
	// TLSServerName is the name the primary's certificate must match.
	TLSServerName string
	// TSIGKey authenticates the transfer. Strongly recommended: without it
	// the only thing standing between this resolver and a substituted zone
	// is whatever address filtering the primary happens to do.
	TSIGKey dns.TSIGKey
}

ZoneConfig describes one secondary zone.

Jump to

Keyboard shortcuts

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