zonefile

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: Apache-2.0, LGPL-3.0 Imports: 7 Imported by: 1

README

go-zonefile

Go package to edit DNS/Bind zone files (preserving formatting & comments)

go-zonefile is not finished: interfaces, documentation and convenience functions are missing. All the lexing and parsing is finished, though.

Online documentation and examples

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fqdn

func Fqdn(name []byte) []byte

func Load

func Load(data []byte) (r *Zonefile, e *ParsingError)

Parse bytestring containing a zonefile

func StringToTTL

func StringToTTL(token string) (uint32, bool)

StringToTTL parses things like 2w, 2m, etc, and returns the time in seconds.

Types

type Entry

type Entry struct {
	IsControl bool // is this a ($INCLUDE, $TTL, ...) directive?
	IsComment bool // is this a comment
	// contains filtered or unexported fields
}

Represents an entry in the zonefile

func (Entry) Class

func (e Entry) Class() []byte

Class returns the class for the entry.

func (Entry) Command

func (e Entry) Command() []byte

For a control entry, returns its command (e.g. $TTL, $ORIGIN, ...)

func (Entry) Comments

func (e Entry) Comments() (ret [][]byte)

Comments returns the comments for the entry.

func (Entry) Domain

func (e Entry) Domain() []byte

Domain returns the owner name for the entry.

func (Entry) Equal

func (e Entry) Equal(e2 Entry) bool

func (Entry) RRType

func (e Entry) RRType() uint16

RRType returns the dns.RRType for the entry.

func (*Entry) SetDomain

func (e *Entry) SetDomain(v []byte) error

Changes the domain in the entry

func (*Entry) SetValue

func (e *Entry) SetValue(i int, v []byte) error

Set the the ith value of the entry

func (Entry) TTL

func (e Entry) TTL() *int

TTL returns the TTL for the entry (if specified).

func (Entry) Type

func (e Entry) Type() []byte

Type returns the RR Type for the entry.

func (Entry) Value

func (e Entry) Value(use tokenUse, transfunc func([]byte) []byte) []byte

func (Entry) Values

func (e Entry) Values() (ret [][]byte)

Values returns the fields for the entry.

func (Entry) ValuesStrings

func (e Entry) ValuesStrings() []string

type ParsingError

type ParsingError struct {
	LineNo int
	ColNo  int
	// contains filtered or unexported fields
}

func (*ParsingError) Error

func (e *ParsingError) Error() string

type Zonefile

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

Represents a DNS masterfile a.k.a. a zonefile

func (*Zonefile) Entries

func (z *Zonefile) Entries() (r []Entry)

List entries in the zonefile

Jump to

Keyboard shortcuts

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