zone

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package zone bridges miekg/dns RR types and pkg/object Blob payloads.

It owns:

  • The canonical RRset byte format (per docs/OBJECT_MODEL.md §4).
  • RFC 1035 zonefile import/export via miekg/dns.

Everything DNS-aware lives here. pkg/object is intentionally kept DNS-unaware so that the canonical-encoding rules can evolve without touching the hash/object machinery.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeRRset

func EncodeRRset(rrs []dns.RR) ([]byte, error)

EncodeRRset serializes the canonical bytes of an RRset.

Format (see docs/OBJECT_MODEL.md §4):

version  uint8
owner    DNS name in RFC 4034 canonical wire form (lowercased, length-prefixed)
class    uint16 BE
type     uint16 BE
ttl      uint32 BE
rr_count uint16 BE
rr_recs  sorted [count]{ length:uint16 BE, bytes:[]byte }

Sorting is by raw rdata bytes, lexicographically. This makes {1.2.3.4, 5.6.7.8} and {5.6.7.8, 1.2.3.4} hash identically.

func ExportZonefile

func ExportZonefile(w io.Writer, rrsets []RRset) error

ExportZonefile writes RRsets as a textual zonefile.

Types

type RRset

type RRset struct {
	Key RRsetKey
	TTL uint32
	RRs []dns.RR // all share the same Header() name/class/type
}

RRset is a logical grouping of RRs sharing (owner, class, type) plus a shared TTL. miekg/dns RR.Header().Ttl is the source of truth at encode time; we collapse to the first RR's TTL (callers must homogenize beforehand).

func BumpSOASerial added in v0.3.0

func BumpSOASerial(soa RRset) (RRset, error)

BumpSOASerial returns a new RRset identical to soa but with the SOA's Serial field incremented by 1 (mod 2^32 per RFC 1982 serial arithmetic).

The input must be an apex SOA RRset (exactly one RR, type SOA). Anything else is an error: SOA is by definition single-record, and bumping a non-SOA RRset makes no sense.

Callers re-encode the returned RRset via EncodeRRset and re-stage it on the next commit, which is what pkg/repo.Commit does automatically when other RRsets change.

func DecodeRRset

func DecodeRRset(payload []byte) (RRset, error)

DecodeRRset reverses EncodeRRset.

func ImportZonefile

func ImportZonefile(r io.Reader, origin string) ([]RRset, error)

ImportZonefile parses an RFC 1035 zonefile and groups its RRs into RRsets. `origin` is the default owner (e.g. "foo.com.") used for relative names.

All RRs sharing (owner, class, type) are merged into one RRset. If their TTLs differ, the smallest is chosen (matching common DNS server behavior).

type RRsetKey

type RRsetKey struct {
	Name  string
	Class uint16
	Type  uint16
}

RRsetKey identifies an RRset by (owner, class, type). Owner is canonical (lowercase, fully-qualified, trailing dot).

func (RRsetKey) String

func (k RRsetKey) String() string

String renders the key in dig-style: "api.foo.com. IN A".

Jump to

Keyboard shortcuts

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