zone

package
v0.0.0-...-8a2913d Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 16 Imported by: 0

README

This is a goinstall-able mirror of modified code already published at:
http://git.nic.cz/redmine/projects/godns/repository/show/zone

Online godoc documentation for this package (should be) available at:
http://gopkgdoc.appspot.com/pkg/github.com/cznic/dns/zone

Documentation

Overview

Package zone handles master files which may be textual data formated as per RFC 1035 chapter 5 or binary data produced by Compiler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load(fname string, errHandler func(e string) bool, rrHandler func(rr *rr.RR) bool) (err error)

Load attempts to load a zone/master (RFC1034/5.1) file from fname. On syntax error the errHandler is invoked if it's not nil, otherwise the loading is aborted and Error returned. If errHandler is not nil and returns false the loading is also aborted. On unrecoverable errors like file not found the load is aborted and Error returned. rrHandler is invoked for every resource record found in the zone file. If rrHandler returns false the loading is aborted and returns nil Error.

func LoadBinary

func LoadBinary(r io.Reader, rrHandler func(rr.Bytes) bool) (err error)

Load attempts to load compiled RRs from r. rrHandler is invoked for every RRs pack found in the data. If rrHandler returns false the loading is aborted without error.

Types

type Compiler

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

Compiler is an object for compiling (large amounts of) DNS resource records to binary data for faster loading (no tokenizing/parsing).

func NewCompiler

func NewCompiler(w io.Writer) (c *Compiler)

NewCompiler returns a newly created Compiler writing to w. The produced binary data may be embeded in another data as their end (a logical EOF) is marked on creation and detected on loading. Compiled RRs are also smaller than the original textual data. The data compression ratio on some measured real world sample of cca 3.5 million RRs was about 60% (i.e. space savings were about 40%).

func (*Compiler) Done

func (c *Compiler) Done() (err error)

Done marks the logical EOF of the compiled RRs block. After calling Done the Compiler is no more usable and will panic on attempts to use it. If the io.Writer passed to NewCompiler is an bufio.Writer then the user of Compiler is responsible for calling Writer.Flush and possibly Writer.Close after calling Compiler.Done. The semantics of Done are like os.File.Close except that no io.Writer closing is performed and the closed entity is the Compiler per se.

Warning: Failure to invoke Done as a last task of a compilation causes loss and/or corruption of the produced binary data.

func (*Compiler) Write

func (c *Compiler) Write(r *rr.RR) (err error)

Write appends r to the "compilation".

Jump to

Keyboard shortcuts

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