protocol

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package protocol contains helpers to manage encoding/decoding DNS protocol to/from a byte array.

Index

Constants

View Source
const (

	// TypeIXFR is the incremental zone transfer QTYPE (RFC 1995).
	TypeIXFR dnsmessage.Type = 251
)

Variables

This section is empty.

Functions

func ErrorPacket

func ErrorPacket(hdr dnsmessage.Header, rcode dnsmessage.RCode, q *dnsmessage.Question) []byte

ErrorPacket returns a serialized DNS packet signaling an error.

func QDCount

func QDCount(raw []byte) uint16

qdCountFromRaw from the raw packet.

func ReadTCPFrame

func ReadTCPFrame(r io.Reader) ([]byte, error)

ReadTCPFrame reads a single RFC 1035 §4.2.2 2-byte big-endian length-prefixed DNS message from r.

func RequestSanityCheck

func RequestSanityCheck(raw []byte) bool

RequestSanityCheck filters out obviously invalid packets.

func ResponseSanityCheck

func ResponseSanityCheck(raw []byte) bool

ResponseSanityCheck filters out obviously invalid packets.

func SetTxnID

func SetTxnID(raw []byte, id uint16)

SetTxnID in the DNS packet.

func WriteTCPFrame

func WriteTCPFrame(w io.Writer, msg []byte) error

WriteTCPFrame writes msg prefixed with its 2-byte big-endian length to `w“.

Types

This section is empty.

Jump to

Keyboard shortcuts

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