dns

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DomainPattern = "^(?:[_a-z0-9](?:[_a-z0-9-]{0,61}[a-z0-9]\\.)|(?:[0-9]+/[0-9]{2})\\.)+(?:[a-z](?:[a-z0-9-]{0,61}[a-z0-9])?)?$"
)

Variables

This section is empty.

Functions

func Init

func Init() (err error)

Types

type Query

type Query struct {
	ID     uint16 // An arbitrary 16 bit request identifier (same id is used in the response)
	QR     bool   // A 1 bit flat specifying whether this message is a query (0) or a response (1)
	Opcode uint8  // A 4 bit fields that specifies the query type; 0 (standard), 1 (inverse), 2 (status), 4 (notify), 5 (update)

	AA           bool // Authoritative answer
	TC           bool // 1 bit flag specifying if the message has been truncated
	RD           bool // 1 bit flag to specify if recursion is desired (if the DNS server we secnd out request to doesn't know the answer to our query, it can recursively ask other DNS servers)
	RA           bool // Recursive available
	Z            bool // Reserved for future use
	AD           bool
	CD           bool
	ResponseCode uint8

	QDCount uint16 // Number of entries in the question section
	ANCount uint16 // Number of answers
	NSCount uint16 // Number of authorities
	ARCount uint16 // Number of additional records

	Questions []Question
}

func DecodeQuery

func DecodeQuery(payload []byte) (Query, error)

func (Query) Encode

func (q Query) Encode() ([]byte, error)

func (Query) Write

func (q Query) Write(writer io.Writer) (int, error)

type Question

type Question struct {
	Domain string
	Type   uint16 // DNS Record type; look into utils.A, utils.NS, etc.
	Class  uint16 // DNS Class; look into
}

func DecodeQuestion

func DecodeQuestion(raw []byte) (Question, error)

func (Question) Write

func (q Question) Write(writer io.Writer) (int, error)

type Response

type Response Query

Jump to

Keyboard shortcuts

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