Documentation ¶
Overview ¶
Package magna implements DNS message encoding/decoding.
Index ¶
- type A
- type BufferOverflowError
- type CNAME
- type DNSClass
- type DNSType
- type DomainCompressionError
- type HINFO
- type Header
- type InvalidLabelError
- type MB
- type MD
- type MF
- type MG
- type MINFO
- type MR
- type MX
- type MagnaError
- type Message
- type NS
- type NULL
- type OPCode
- type PTR
- type Question
- type RCode
- type Reserved
- type ResourceRecord
- type ResourceRecordData
- type SOA
- type TXT
- type WKS
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferOverflowError ¶
BufferOverflowError represents an error when there is a buffer overflow.
func (*BufferOverflowError) Error ¶
func (e *BufferOverflowError) Error() string
type DomainCompressionError ¶
type DomainCompressionError struct{}
DomainCompressionError represents an error related to domain compression.
func (*DomainCompressionError) Error ¶
func (e *DomainCompressionError) Error() string
type HINFO ¶
type HINFO struct { CPU string // CPU specifies the CPU type. OS string // OS specifies the operating system. }
HINFO represents the general information about a server.
type Header ¶
type Header struct { ID uint16 // ID is a 16 bit identifier. QR bool // QR (query response) specifies if the packet is a query (false) or response (true). OPCode OPCode // OPCode is a 4bit value that specifies the kind of the query. AA bool // AA (Authoritative Answer) specifies if the responding name server is the authoritative server. TC bool // TC (Truncation) specifies if the packet was truncated due to length. RD bool // RD (Recursion Desired) specifies that the client wants to recurse. RA bool // RA (Recursion Available) specifies that the server is available to recurse. Z uint8 // Z Reserved for future use RCode RCode // RCode is a 4 bit field representing the response error. QDCount uint16 // QDCount specifies number of entries in the Question slice. ANCount uint16 // ANCount specifies number of entries in the Answer slice. NSCount uint16 // NSCount specifies number of entries in the Authority slice. ARCount uint16 // ARCount specifies number of entries in the Additional slice. }
A Header represents the metadata information of a DNS packet.
type InvalidLabelError ¶
type InvalidLabelError struct {
Length int
}
InvalidLabelError represents an error when an invalid label length is encountered.
func (*InvalidLabelError) Error ¶
func (e *InvalidLabelError) Error() string
type MD ¶
type MD struct {
MADName string
}
MD represents the mail agent for a domain. XXX: Obsolete
type MF ¶
type MF struct {
MADName string
}
MF represents a host which has a mail agent for a domain. XXX: Obsolete
type MG ¶
type MG struct {
MGMName string
}
MG represents a mailbox which is configured for MGMName.
type MINFO ¶
type MINFO struct { RMailBx string // RMailBx specifies the mailbox for a mailing list. EMailBx string // EMailBx specifes a mailbox for receiving errors. }
MINFO represents mailing list information.
type MX ¶
type MX struct { Preference uint16 // Preference specifies the preference with lower values being prefered. Exchange string // Exchange specifies host acting for the name. }
MX represents a host acting as a mail exchange.
type MagnaError ¶
type MagnaError struct {
Message string
}
MagnaError represents a generic error with a custom message.
func (*MagnaError) Error ¶
func (e *MagnaError) Error() string
type Message ¶
type Message struct { Header Header // Header contains metadata about the message. Question []Question // Question contains a slice of questions. Answer []ResourceRecord // Answer contains a slice of resource records. Authority []ResourceRecord // Authority contains a slice of resource records. Additional []ResourceRecord // Additional contains a slice of resource records. // contains filtered or unexported fields }
A Message represents the single format supported by the DNS protocol.
func CreateRequest ¶
func (*Message) AddQuestion ¶
func (*Message) CreateReply ¶
type NULL ¶
type NULL struct {
Anything []byte
}
NULL can be anything as long as its under 65535 octets.
type PTR ¶
type PTR struct {
PTRDName string
}
PTR specifies to a location in the domain name space.
type Question ¶
type Question struct { QName string // QName domain name being questioned. QType DNSType // QType specifies the type of the question. QClass DNSClass // QClass specifies the class of the question. }
A Question represent a question in the DNS packet.
type Reserved ¶
type Reserved struct {
Bytes []byte
}
Reserved represents a record that is not yet implemented.
type ResourceRecord ¶
type ResourceRecord struct { Name string // a domain label RType DNSType // the type of the record RClass DNSClass // the class of the record TTL uint32 // the time to live of the record in seconds RDLength uint16 // the length of the record in number of bytes RData ResourceRecordData // the data of the record }
ResourceRecord represents DNS records.
type ResourceRecordData ¶
type ResourceRecordData interface { Decode([]byte, int, int) (int, error) Encode([]byte, *map[string]uint16) []byte String() string }
A ResourceRecordData represents the RDATA field of the resource record. Decode:
[]byte - DNS packet int - offset in []byte to start parsing resource record data int - length of the resource record field
Encode:
[]byte - DNS Packet *map[string]uint8 - map containing labels and offsets for domain name compression
type SOA ¶
type SOA struct { MName string // MName represents the name server that was the original source of data for a zone. RName string // RName represents a mailbox of the person responsible for this zone. Serial uint32 // Serial is a 32 bit version number of the original copy of the zone. Refresh uint32 // Refresh is a 32 bit time interval before the zone should be refreshed. Retry uint32 // Retry is a 32 bit time interval that should elapse before a failed refresh is retried. Expire uint32 // Expire is the upper limit on the time interval that can elapse before the zone is no longer authoritative. Minimum uint32 // Minimum is the minimum TTL field that should be exported with any RR from this zone. }
SOA represents