packers

package
v0.0.0-...-5abfbfe Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoBody          = errors.New("no body data")
	ErrUnpackpingQName = errors.New("error while unpacking QNAME")
)

Functions

This section is empty.

Types

type DefaultPacker

type DefaultPacker struct {
}

DefaultPacker is the default packer implementation which follows the specs RFC 1034 and 1035

func (*DefaultPacker) Pack

func (p *DefaultPacker) Pack(message *dns.Message) ([]byte, error)

Packs packs a single DNS message by converting the provided message to the wire format

func (*DefaultPacker) PackHeader

func (p *DefaultPacker) PackHeader(header dns.Header, buf []byte, offset int) (int, error)

PackHeader packs header data by converting the provided header to the wire format

func (*DefaultPacker) PackQuestion

func (p *DefaultPacker) PackQuestion(question dns.Question, buf []byte, offset int) (int, error)

PackQuestion packs a question by converting the provided question to the wire format

func (*DefaultPacker) PackRR

func (p *DefaultPacker) PackRR(rr rr.RR, buf []byte, offset int) (int, error)

PackRR packs a single resource record by converting the provided data to the wire format

func (*DefaultPacker) PackRRHeader

func (p *DefaultPacker) PackRRHeader(header *rr.Header, buf []byte, offset int) (int, error)

PackRRHeader packs a resource record header by converting the provided data to the wire format

func (*DefaultPacker) PackRRList

func (p *DefaultPacker) PackRRList(rrs []rr.RR, buf []byte, offset int) (int, error)

PackRRList packs a slice of resource records by converting the provided records to the wire format

type DefaultUnpacker

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

DefaultWrapper describes the default wrapper to unwrap / wrap DNS messages. It is based on a regular byte Reader to read bytes into a pre-defined struct

func (*DefaultUnpacker) Unpack

func (p *DefaultUnpacker) Unpack(header dns.Header, data []byte, offset int) (*dns.Message, error)

Unpack unpacks a single complete DNS message from the received byte slice

func (*DefaultUnpacker) UnpackHeader

func (p *DefaultUnpacker) UnpackHeader(data []byte) (dns.Header, int, error)

UnpackHeader unpacks header data from the received byte slice

func (*DefaultUnpacker) UnpackQuestion

func (p *DefaultUnpacker) UnpackQuestion(data []byte, offset int) (dns.Question, int, error)

UnpackQuestion unpacks a question from the received byte slice

func (*DefaultUnpacker) UnpackRR

func (p *DefaultUnpacker) UnpackRR(data []byte, offset int) (rr.RR, int, error)

UnpackRR unpacks a single resource record from the received byte slice

func (*DefaultUnpacker) UnpackRRHeader

func (p *DefaultUnpacker) UnpackRRHeader(data []byte, offset int) (rr.Header, int, error)

UnpackRRHeader unpacks header data of a resource record from the received byte slice

func (*DefaultUnpacker) UnpackRRList

func (p *DefaultUnpacker) UnpackRRList(count uint16, data []byte, offset int) ([]rr.RR, int, error)

UnpackRRList unpacks a list of resource records from the received byte slice

type Packer

type Packer interface {
	// Packs packs a single DNS message by converting
	// the provided message to the wire format
	Pack(*dns.Message) ([]byte, error)

	// PackHeader packs header data by converting
	// the provided header to the wire format
	PackHeader(dns.Header, []byte, int) (int, error)

	// PackQuestion packs a question by converting
	// the provided question to the wire format
	PackQuestion(dns.Question, []byte, int) (int, error)

	// PackRRList packs a slice of resource records
	// by converting the provided records to the
	// wire format
	PackRRList([]rr.RR, []byte, int) (int, error)

	// PackRR packs a single resource record by
	// converting the provided data to the wire
	// format
	PackRR(rr.RR, []byte, int) (int, error)

	// PackRRHeader packs a resource record header
	// by converting the provided data to the
	// wire format
	PackRRHeader(*rr.Header, []byte, int) (int, error)
}

Packer packs DNS messages from a struct into the wire format

func NewDefaultPacker

func NewDefaultPacker() Packer

type Unpacker

type Unpacker interface {
	// Unpack unpacks a single complete DNS message from the
	// received byte slice
	Unpack(dns.Header, []byte, int) (*dns.Message, error)

	// UnpackHeader unpacks header data from the received
	// byte slice
	UnpackHeader([]byte) (dns.Header, int, error)

	// UnpackQuestion unpacks a question from the received
	// byte slice
	UnpackQuestion([]byte, int) (dns.Question, int, error)

	// UnpackRRList unpacks a list of resource records from the
	// received byte slice
	UnpackRRList(uint16, []byte, int) ([]rr.RR, int, error)

	// UnpackRR unpacks a single resource record from the
	// received byte slice
	UnpackRR([]byte, int) (rr.RR, int, error)

	// UnpackRRHeader unpacks header data of a resource
	// record from the received byte slice
	UnpackRRHeader([]byte, int) (rr.Header, int, error)
}

func NewDefaultUnpacker

func NewDefaultUnpacker() Unpacker

NewDefaultUnpacker creates a new default wrapper instance

Jump to

Keyboard shortcuts

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