dns

package
v0.0.0-...-3ea0f55 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2014 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PACKET_TYPE_REQUEST  = 0
	PACKET_TYPE_RESPONSE = 1
)
View Source
const (
	RESPONSE_CODE_NO_ERROR        = 0
	RESPONSE_CODE_FORMAT_ERROR    = 1
	RESPONSE_CODE_SERVER_ERROR    = 2
	RESPONSE_CODE_NAME_ERROR      = 3
	RESPONSE_CODE_NOT_IMPLEMENTED = 4
	RESPONSE_CODE_REFUSED         = 5
)
View Source
const (
	HEADER_LEN = 12
)

Variables

View Source
var Classes = map[uint16]string{
	1:   "IN",
	2:   "CS",
	3:   "CH",
	4:   "HS",
	255: "*",
}
View Source
var Types = map[uint16]string{
	1:   "A",
	2:   "NS",
	3:   "MD",
	4:   "MF",
	5:   "CNAME",
	6:   "SOA",
	7:   "MB",
	8:   "MG",
	9:   "MR",
	10:  "NULL",
	11:  "WKS",
	12:  "PTR",
	13:  "HINFO",
	14:  "MINFO",
	15:  "MX",
	16:  "TXT",
	252: "AXFR",
	253: "MAILB",
	254: "MAILA",
	255: "*",
}

Functions

This section is empty.

Types

type CName

type CName Domain

type Domain

type Domain struct {
	Labels []Label
}

func NewDomain

func NewDomain(packet []byte, offset int) (Domain, int, error)

func (Domain) String

func (domain Domain) String() string
type Header struct {
	ID uint16

	QDCount uint16
	ANCount uint16
	NSCount uint16
	ARCount uint16
	// contains filtered or unexported fields
}

func NewHeader

func NewHeader(data []byte) Header

func (Header) IsAuthoritativeAnswer

func (header Header) IsAuthoritativeAnswer() bool

func (Header) IsRecursionAvailable

func (header Header) IsRecursionAvailable() bool

func (Header) IsRecursionDesired

func (header Header) IsRecursionDesired() bool

func (Header) IsTruncated

func (header Header) IsTruncated() bool

func (Header) OpCode

func (header Header) OpCode() uint8

func (Header) PacketType

func (header Header) PacketType() uint8

func (Header) PacketTypeString

func (header Header) PacketTypeString() string

func (Header) ResponseCode

func (header Header) ResponseCode() uint8

func (Header) String

func (header Header) String() string

type Label

type Label struct {
	Length byte
	Data   string
}

func ReadLabels

func ReadLabels(packet []byte, offset int) ([]Label, int, error)

func (Label) DataLength

func (label Label) DataLength() byte

func (Label) String

func (label Label) String() string

type Packet

type Packet struct {
	Header
	Questions         []Question
	Answers           []ResourceRecord
	NameServers       []ResourceRecord
	AdditionalRecords []ResourceRecord
}

func NewPacket

func NewPacket(packetData []byte) (*Packet, error)

func (*Packet) IsValid

func (packet *Packet) IsValid() bool

func (*Packet) String

func (packet *Packet) String() string

type Question

type Question struct {
	Domain
	Type  uint16
	Class uint16
}

func NewQuestion

func NewQuestion(packet []byte, offset int) (Question, int)

func (Question) ClassName

func (question Question) ClassName() string

func (Question) String

func (question Question) String() string

func (Question) TypeName

func (question Question) TypeName() string

type ResourceRecord

type ResourceRecord struct {
	Domain
	Type     uint16
	Class    uint16
	TTL      uint32
	RDLength uint16
	RData    interface{}
}

func NewResourceRecord

func NewResourceRecord(packet []byte, offset int) (ResourceRecord, int)

func (ResourceRecord) ClassName

func (record ResourceRecord) ClassName() string

func (ResourceRecord) String

func (record ResourceRecord) String() string

func (ResourceRecord) TypeName

func (record ResourceRecord) TypeName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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