present

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 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 present turns DNS presentation form (RFC 1035 master file syntax) into bdns leaves and back. It is the one place a DNS library is used: the command and the renderer import it, the codec and the module never do.

A name in a record's data is written as a name part (docs/spec.md section 3), never as bytes: relative to the origin when it is written without a trailing dot, absolute when it ends in one. A type that carries a name and that this package has no layout for is refused, so no name is ever copied into a byte part.

Index

Constants

This section is empty.

Variables

View Source
var ErrNamedType = errors.New("present: the type's data carries a name bdns has no layout for yet")

ErrNamedType is a record type whose data carries a name in a layout this package does not know.

Functions

func Leaf

func Leaf(name, ttl, typ string, records []string, domain string) (*zonerec.Leaf, error)

Leaf reads one record set from its presentation form: a name, a TTL, a type, and one argument for each record's data, as in

www 300 A 192.0.2.1 192.0.2.2
@ 3600 MX "10 mail"

A name in the data is relative to the origin unless it ends in a dot. domain, when set, lets the leaf's own name be written in full.

func Master

func Master(typ uint16, d zonerec.Data, origin []string) (typeText, text string, ok bool)

Master is one record as an RFC 1035 master file holds it under origin, the origin's labels leftmost first: the type as the file names it and the data after it. It is Record's form (a relative name stays relative, for a file that sets $ORIGIN) only when that text, read back as one line of a master file under origin, is exactly the data's wire bytes. Any other data is written in RFC 3597 form, TYPE<n> and \# <length> <hex> over the wire bytes with each name in full: nothing a leaf holds reaches the file as text unless a parser gives the same bytes back.

It is false when a name would pass 255 bytes under origin, and when the data is not data of its type, for a type this package knows the layout of (WellFormed): a server that knows the type refuses such a record in any form, and with it the whole file.

func Owner

func Owner(name, domain string) (zonerec.Name, error)

Owner reads a leaf's name: "@" is the apex, a name without a trailing dot is relative to the origin, and a name with one must be at or under domain, which is then needed.

func Record

func Record(typ uint16, d zonerec.Data) string

Record is one record's data in presentation form, as Leaf reads it.

func Records

func Records(l *zonerec.Leaf) []string

Records are a leaf's records in presentation form, in the leaf's order.

func Type

func Type(s string) (uint16, error)

Type reads a record type: a mnemonic (A, MX) or TYPE<n>.

func TypeName

func TypeName(t uint16) string

TypeName is a type's mnemonic, or TYPE<n>.

func WellFormed

func WellFormed(typ uint16, d zonerec.Data, origin []string) bool

WellFormed reports whether the data, on the wire under origin, is data of its type: for a type with a layout in the DNS library, the bytes read as that layout and write back the same. Data of a type the library does not know is always well formed. False too when a name would pass 255 bytes under origin.

func Zone

func Zone(r io.Reader, domain, file string) (leaves []*zonerec.Leaf, notes []string, err error)

Zone reads an RFC 1035 master file for domain into leaves in key order. Names at or under domain, a leaf's own and those in data, are written relative to the origin; any other name in data stays absolute. SOA and DNSSEC records are left out, one note for each type. $INCLUDE is not followed.

Types

This section is empty.

Jump to

Keyboard shortcuts

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