models

package
v0.0.0-...-ccf3d34 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const HdrLen uint8 = 12 // Length of DnsHeader in Bytes

Variables

This section is empty.

Functions

This section is empty.

Types

type DnsHeader

type DnsHeader struct {
	ID      uint16       `json:"trans-id"`   // Identifier generated to match outstanding queries
	QR      uint8        `json:"trans-type"` // 1 Bit determining; query (0) or response (1)
	OPCODE  OpCode       `json:"opcode"`     // 4 Bit determining type of query
	AA      uint8        `json:"aa"`         // 1 Bit Authoritive Answer
	TC      uint8        `json:"tc"`         // 1 Bit Truncation; specifies if the message is too long
	RD      uint8        `json:"rd"`         // 1 Bit Recursion Desired
	RA      uint8        `json:"ra"`         // 1 Bit Recursion Avaliable
	Z       uint8        `json:"z"`          // 1 Bit Reserved for future use (must be 0)
	RCODE   ResponseCode `json:"rcode"`      // Response Code
	QDCOUNT uint16       `json:"qdcount"`    // Number of entries in Question Section
	ADCOUNT uint16       `json:"adcount"`    // Number of RR in Answer Section
	NSCOUNT uint16       `json:"nscount"`    // Number of NS RR in Authoritive Records Section
	ARCOUNT uint16       `json:"arcount"`    // Number of RR in Additional Records Section
}

type DnsMessage

type DnsMessage struct {
	Hdr         DnsHeader     `json:"hdr"`    // Required for all Messages (has length of below record arrays)
	Questions   []DnsQuestion `json:"quests"` // The question/s for the Name Server
	Answers     []DnsRR       `json:"ans"`    // Resource Records that answer the questions
	Authorities []DnsRR       `json:"auths"`  // Resource Records pointing towards an authority
	Additionals []DnsRR       `json:"adds"`   // Resource Records holdign additional information
}

func MarshalDNS

func MarshalDNS(data []byte) (DnsMessage, error)

type DnsQuestion

type DnsQuestion struct {
	QNAME  []QNameLabel `json:"name"`  // Domain name represented as a sequence of labels. Ends with an empty length label
	QTYPE  QType        `json:"type"`  // Specifies the Type of query eg. NS for an authoritative name server
	QCLASS QClass       `json:"class"` // Specifies the Class of query eg. IN for internet
}

type DnsRR

type DnsRR struct {
	NAME     []byte `json:"name"`  // Uses Message Compression (See RFC1035 4.1.4)
	TYPE     QType  `json:"type"`  // Specifies the Type of query eg. NS for an authoritative name server
	CLASS    QClass `json:"class"` // Specifies the Class of query eg. IN for internet
	TTL      uint32 `json:"ttl"`   // Time interval in seconds RR can be cached before needing to be discarded. 0 = Don't cache
	RDLENGTH uint16 `json:"rdlen"` // Length in bytes of RDATA
	RDATA    []byte `json:"rdata"` // Data of RR, format determined by TYPE and CLASS
}

type OpCode

type OpCode uint8
const (
	QUERY  OpCode = 0 // Standard Query
	IQUERY OpCode = 1 // Inverse Query
	STATUS OpCode = 2 // Server Status Request
)

type QClass

type QClass uint16
const (
	IN QClass = 1 // The Internet
	CS QClass = 2 // The CSNET class (Obsolete - used only for examples in some obsolete RFCs)
	CH QClass = 3 // The CHAOS class
	HS QClass = 4 // Hesiod [Dyer 87]
)

type QNameLabel

type QNameLabel struct {
	Length byte   `json:"len"`   // Length of Data in bytes
	Data   []byte `json:"label"` // Label Data
}

type QType

type QType uint16
const (
	A     QType = 1   // Host Address
	NS    QType = 2   // Authoritative Name Server
	MD    QType = 3   // Mail Destination 					 (Obsolete - use MX)
	MF    QType = 4   // Mail Forwarder 					 (Obsolete - use MX)
	CNAME QType = 5   // Canonical Name for an Alias
	SOA   QType = 6   // Marks the start of a zone of Authority
	MB    QType = 7   // Mailbox domain name 					  (EXPERIMENTAL)
	MG    QType = 8   // Mail group member 						  (EXPERIMENTAL)
	MR    QType = 9   // Mail rename domain name 				  (EXPERIMENTAL)
	NULL  QType = 10  // Null RR 								  (EXPERIMENTAL)
	WKS   QType = 11  // Well known service description
	PTR   QType = 12  // Domain name pointer
	HINFO QType = 13  // Host information
	MINFO QType = 14  // Mailbox or Mail list information
	MX    QType = 15  // Mail exchange
	TXT   QType = 16  // Text strings
	AXFR  QType = 252 // Request for a transfer of an entire zone
	MAILB QType = 253 // Request for mailbox-related records (MB, MG or MR)
	MAILA QType = 254 // Request for mail agent RR			 (Obsolete - use MX)
	ALL   QType = 255 // Request for all records
)

type ResponseCode

type ResponseCode uint8
const (
	OK             ResponseCode = 0 // No error condition
	FormatError    ResponseCode = 1 // NS was unable to interpret query
	ServerFailure  ResponseCode = 2 // NS was unable to process query due to problem with NS
	NameError      ResponseCode = 3 // Domain name referenced does not exit
	NotImplemented ResponseCode = 4 // NS does not support hte requested kind of query
	Refused        ResponseCode = 5 // NS refuses to perform the specified operation for policy reasons
)

Jump to

Keyboard shortcuts

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