rr

package
v0.0.0-...-5abfbfe Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

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

	ANY uint16 = 255 // Any class (*)
)

Class describes RR class codes. See https://datatracker.ietf.org/doc/html/rfc1035#section-3.2.4

View Source
const (
	TypeNone  uint16 = 0
	TypeA     uint16 = 1  // A host address
	TypeNS    uint16 = 2  // An authoritative name server
	TypeMD    uint16 = 3  // A mail destination (Obsolete - use MX)
	TypeMF    uint16 = 4  // A mail forwarded (Obsolete - use MX)
	TypeCNAME uint16 = 5  // The canonical name for an alias
	TypeSOA   uint16 = 6  // Marks the start of a zone of authority
	TypeMB    uint16 = 7  // A mailbox domain name (EXPERIMENTAL)
	TypeMG    uint16 = 8  // A mail group member (EXPERIMENTAL)
	TypeMR    uint16 = 9  // A mail rename domain name (EXPERIMENTAL)
	TypeNULL  uint16 = 10 // A null RR (EXPERIMENTAL)
	TypePTR   uint16 = 12 // A domain name pointer
	TypeHINFO uint16 = 13 // Host information
	TypeMINFO uint16 = 14 // Mailbox or mail list information
	TypeMX    uint16 = 15 // Mail exchange
	TypeTXT   uint16 = 16 // Text strings
	TypeAAAA  uint16 = 28 // AAAA host address
	TypeOPT   uint16 = 41 // OPT Record / Meta record

	TypeAXFR  uint16 = 252 // A request for a transfer of an entire zone
	TypeMAILB uint16 = 253 // A request for mailbox-related records (MB, MG or MR)
	TypeMAILA uint16 = 254 // A request for mail agent RRs (Obsolete - see MX)
	TypeANY   uint16 = 255 // A request for all records (*)
)

Variables

View Source
var (
	ErrNoSuchType            = errors.New("no such RR type")
	ErrFailedToConvertRRData = errors.New("failed to convert RR data")
	ErrInvalidRRData         = errors.New("invalid RR data")
)
View Source
var (
	ErrSOASerialOutOfRange = errors.New("serial out of range")
)

Functions

func TypeToString

func TypeToString(t uint16) string

func UpdateTTL

func UpdateTTL(record RR, expire time.Time)

UpdateTTL updates the TTL of a record based on the expiry timestamp

Types

type A

type A struct {
	H       Header
	Address netip.Addr
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.4.1

func (*A) Header

func (rr *A) Header() *Header

func (*A) IsSame

func (rr *A) IsSame(o RR) bool

func (*A) Len

func (rr *A) Len() uint16

func (*A) Pack

func (rr *A) Pack(buf []byte, offset int, _ compression.Map) (int, error)

func (*A) SetData

func (rr *A) SetData(data ...interface{}) error

func (*A) SetHeader

func (rr *A) SetHeader(header Header)

func (*A) String

func (rr *A) String() string

func (*A) Unpack

func (rr *A) Unpack(data []byte, offset int) (int, error)

type AAAA

type AAAA struct {
	H       Header
	Address netip.Addr
}

See https://datatracker.ietf.org/doc/html/rfc3596

func (*AAAA) Header

func (rr *AAAA) Header() *Header

func (*AAAA) IsSame

func (rr *AAAA) IsSame(o RR) bool

func (*AAAA) Len

func (rr *AAAA) Len() uint16

func (*AAAA) Pack

func (rr *AAAA) Pack(buf []byte, offset int, _ compression.Map) (int, error)

func (*AAAA) SetData

func (rr *AAAA) SetData(data ...interface{}) error

func (*AAAA) SetHeader

func (rr *AAAA) SetHeader(header Header)

func (*AAAA) String

func (rr *AAAA) String() string

func (*AAAA) Unpack

func (rr *AAAA) Unpack(data []byte, offset int) (int, error)

type CNAME

type CNAME struct {
	H      Header
	Target string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.1

func (*CNAME) Header

func (rr *CNAME) Header() *Header

func (*CNAME) IsSame

func (rr *CNAME) IsSame(o RR) bool

func (*CNAME) Len

func (rr *CNAME) Len() uint16

func (*CNAME) Pack

func (rr *CNAME) Pack(buf []byte, offset int, comp compression.Map) (int, error)

func (*CNAME) SetData

func (rr *CNAME) SetData(data ...interface{}) error

func (*CNAME) SetHeader

func (rr *CNAME) SetHeader(header Header)

func (*CNAME) String

func (rr *CNAME) String() string

func (*CNAME) Unpack

func (rr *CNAME) Unpack(data []byte, offset int) (int, error)

type HINFO

type HINFO struct {
	H   Header
	CPU string
	OS  string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.2

func (*HINFO) Header

func (rr *HINFO) Header() *Header

func (*HINFO) IsSame

func (rr *HINFO) IsSame(o RR) bool

func (*HINFO) Len

func (rr *HINFO) Len() uint16

func (*HINFO) Pack

func (rr *HINFO) Pack(buf []byte, offset int, _ compression.Map) (int, error)

func (*HINFO) SetData

func (rr *HINFO) SetData(data ...interface{}) error

func (*HINFO) SetHeader

func (rr *HINFO) SetHeader(header Header)

func (*HINFO) String

func (rr *HINFO) String() string

func (*HINFO) Unpack

func (rr *HINFO) Unpack(data []byte, offset int) (int, error)
type Header struct {
	// Name specifies an owner name
	Name string

	// Type specifies a RR type code
	Type uint16

	// Class specifies a RR class code
	Class uint16

	// TTL specifies the time interval in seconds that the RR
	// may be cached before it should be considered outdated
	TTL uint32

	// RDLength specifies the length of RDATA in octets
	RDLength uint16

	// Additional Expires field. This helps to more easily handle cached records
	Expires int64
}

Header describes header data of a resource record. See https://datatracker.ietf.org/doc/html/rfc1035#section-3.2.1

type MB

type MB struct {
	H       Header
	MADName string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.3 (EXPERIMENTAL)

func (*MB) Header

func (rr *MB) Header() *Header

func (*MB) IsSame

func (rr *MB) IsSame(o RR) bool

func (*MB) Len

func (rr *MB) Len() uint16

func (*MB) Pack

func (rr *MB) Pack(buf []byte, offset int, comp compression.Map) (int, error)

func (*MB) SetData

func (rr *MB) SetData(data ...interface{}) error

func (*MB) SetHeader

func (rr *MB) SetHeader(header Header)

func (*MB) String

func (rr *MB) String() string

func (*MB) Unpack

func (rr *MB) Unpack(data []byte, offset int) (int, error)

type MD

type MD struct {
	H       Header
	MADName string
}

https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.4 (Obsolete)

func (*MD) Header

func (rr *MD) Header() *Header

func (*MD) IsSame

func (rr *MD) IsSame(o RR) bool

func (*MD) Len

func (rr *MD) Len() uint16

func (*MD) Pack

func (rr *MD) Pack(buf []byte, offset int, comp compression.Map) (int, error)

func (*MD) SetData

func (rr *MD) SetData(data ...interface{}) error

func (*MD) SetHeader

func (rr *MD) SetHeader(header Header)

func (*MD) String

func (rr *MD) String() string

func (*MD) Unpack

func (rr *MD) Unpack(data []byte, offset int) (int, error)

type MF

type MF struct {
	H       Header
	MADName string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.5 (Obsolete)

func (*MF) Header

func (rr *MF) Header() *Header

func (*MF) IsSame

func (rr *MF) IsSame(o RR) bool

func (*MF) Len

func (rr *MF) Len() uint16

func (*MF) Pack

func (rr *MF) Pack(buf []byte, offset int, comp compression.Map) (int, error)

func (*MF) SetData

func (rr *MF) SetData(data ...interface{}) error

func (*MF) SetHeader

func (rr *MF) SetHeader(header Header)

func (*MF) String

func (rr *MF) String() string

func (*MF) Unpack

func (rr *MF) Unpack(data []byte, offset int) (int, error)

type MG

type MG struct {
	H       Header
	MGMName string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.6 (EXPERIMENTAL)

func (*MG) Header

func (rr *MG) Header() *Header

func (*MG) IsSame

func (rr *MG) IsSame(o RR) bool

func (*MG) Len

func (rr *MG) Len() uint16

func (*MG) Pack

func (rr *MG) Pack(buf []byte, offset int, comp compression.Map) (int, error)

func (*MG) SetData

func (rr *MG) SetData(data ...interface{}) error

func (*MG) SetHeader

func (rr *MG) SetHeader(header Header)

func (*MG) String

func (rr *MG) String() string

func (*MG) Unpack

func (rr *MG) Unpack(data []byte, offset int) (int, error)

type MINFO

type MINFO struct {
	H        Header
	RMailBox string
	EMailBox string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.7 (EXPERIMENTAL)

func (*MINFO) Header

func (rr *MINFO) Header() *Header

func (*MINFO) IsSame

func (rr *MINFO) IsSame(o RR) bool

func (*MINFO) Len

func (rr *MINFO) Len() uint16

func (*MINFO) Pack

func (rr *MINFO) Pack(buf []byte, offset int, comp compression.Map) (int, error)

func (*MINFO) SetData

func (rr *MINFO) SetData(data ...interface{}) error

func (*MINFO) SetHeader

func (rr *MINFO) SetHeader(header Header)

func (*MINFO) String

func (rr *MINFO) String() string

func (*MINFO) Unpack

func (rr *MINFO) Unpack(data []byte, offset int) (int, error)

type MR

type MR struct {
	H       Header
	NewName string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.8 (EXPERIMENTAL)

func (*MR) Header

func (rr *MR) Header() *Header

func (*MR) IsSame

func (rr *MR) IsSame(o RR) bool

func (*MR) Len

func (rr *MR) Len() uint16

func (*MR) Pack

func (rr *MR) Pack(buf []byte, offset int, comp compression.Map) (int, error)

func (*MR) SetData

func (rr *MR) SetData(data ...interface{}) error

func (*MR) SetHeader

func (rr *MR) SetHeader(header Header)

func (*MR) String

func (rr *MR) String() string

func (*MR) Unpack

func (rr *MR) Unpack(data []byte, offset int) (int, error)

type MX

type MX struct {
	H          Header
	Preference uint16
	Exchange   string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.9

func (*MX) Header

func (rr *MX) Header() *Header

func (*MX) IsSame

func (rr *MX) IsSame(o RR) bool

func (*MX) Len

func (rr *MX) Len() uint16

func (*MX) Pack

func (rr *MX) Pack(buf []byte, offset int, comp compression.Map) (int, error)

func (*MX) SetData

func (rr *MX) SetData(data ...interface{}) error

func (*MX) SetHeader

func (rr *MX) SetHeader(header Header)

func (*MX) String

func (rr *MX) String() string

func (*MX) Unpack

func (rr *MX) Unpack(data []byte, offset int) (int, error)

type NS

type NS struct {
	H       Header
	NSDName string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.11

func (*NS) Header

func (rr *NS) Header() *Header

func (*NS) IsSame

func (rr *NS) IsSame(o RR) bool

func (*NS) Len

func (rr *NS) Len() uint16

func (*NS) Pack

func (rr *NS) Pack(buf []byte, offset int, comp compression.Map) (int, error)

func (*NS) SetData

func (rr *NS) SetData(data ...interface{}) error

func (*NS) SetHeader

func (rr *NS) SetHeader(header Header)

func (*NS) String

func (rr *NS) String() string

func (*NS) Unpack

func (rr *NS) Unpack(data []byte, offset int) (int, error)

type NULL

type NULL struct {
	H    Header
	Data string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.10

func (*NULL) Header

func (rr *NULL) Header() *Header

func (*NULL) IsSame

func (rr *NULL) IsSame(o RR) bool

func (*NULL) Len

func (rr *NULL) Len() uint16

func (*NULL) Pack

func (rr *NULL) Pack(data []byte, offset int, _ compression.Map) (int, error)

func (*NULL) SetData

func (rr *NULL) SetData(data ...interface{}) error

func (*NULL) SetHeader

func (rr *NULL) SetHeader(header Header)

func (*NULL) String

func (rr *NULL) String() string

func (*NULL) Unpack

func (rr *NULL) Unpack(data []byte, offset int) (int, error)

type OPT

type OPT struct {
	H       Header
	Options []edns.Option
}

func (*OPT) Header

func (rr *OPT) Header() *Header

func (*OPT) IsSame

func (rr *OPT) IsSame(o RR) bool

func (*OPT) Len

func (rr *OPT) Len() uint16

func (*OPT) Pack

func (rr *OPT) Pack(buf []byte, offset int, _ compression.Map) (int, error)

func (*OPT) SetData

func (rr *OPT) SetData(data ...interface{}) error

func (*OPT) SetHeader

func (rr *OPT) SetHeader(header Header)

func (*OPT) String

func (rr *OPT) String() string

func (*OPT) Unpack

func (rr *OPT) Unpack(data []byte, offset int) (int, error)

type PTR

type PTR struct {
	H        Header
	PTRDName string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.12

func (*PTR) Header

func (rr *PTR) Header() *Header

func (*PTR) IsSame

func (rr *PTR) IsSame(o RR) bool

func (*PTR) Len

func (rr *PTR) Len() uint16

func (*PTR) Pack

func (rr *PTR) Pack(buf []byte, offset int, comp compression.Map) (int, error)

func (*PTR) SetData

func (rr *PTR) SetData(data ...interface{}) error

func (*PTR) SetHeader

func (rr *PTR) SetHeader(header Header)

func (*PTR) String

func (rr *PTR) String() string

func (*PTR) Unpack

func (rr *PTR) Unpack(data []byte, offset int) (int, error)

type RR

type RR interface {
	// Get header of RR
	Header() *Header

	// Set header of RR
	SetHeader(Header)

	// Set resource record data
	SetData(...interface{}) error

	// String returns the representation of any RR as text
	String() string

	// Len returns the records RDLENGTH
	Len() uint16

	// IsSame compares both RRs and returns if they are the same
	IsSame(RR) bool

	// Unpack unpacks the RDATA
	Unpack([]byte, int) (int, error)

	// Pack packs the RDATA
	Pack([]byte, int, compression.Map) (int, error)
}

RR describes a resource record. Information of a (domain) name is composed of a set of resource records. See https://datatracker.ietf.org/doc/html/rfc1035#section-3.2

func New

func New(t uint16) (RR, error)

New returns a new RR based on the provided type

func NewFromName

func NewFromName(name string) (RR, uint16, error)

NewFromName returns a new RR based on the provided name

type SOA

type SOA struct {
	H       Header
	MName   string
	RName   string
	Serial  uint32
	Refresh uint32
	Retry   uint32
	Expire  uint32
	Minimum uint32
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.13

func (*SOA) Header

func (rr *SOA) Header() *Header

func (*SOA) IsSame

func (rr *SOA) IsSame(o RR) bool

func (*SOA) Len

func (rr *SOA) Len() uint16

func (*SOA) Pack

func (rr *SOA) Pack(buf []byte, offset int, comp compression.Map) (int, error)

func (*SOA) SerialAdd

func (rr *SOA) SerialAdd(n int) error

func (*SOA) SerialCompare

func (rr *SOA) SerialCompare(soa *SOA) SerialComparison

func (*SOA) SetData

func (rr *SOA) SetData(data ...interface{}) error

func (*SOA) SetHeader

func (rr *SOA) SetHeader(header Header)

func (*SOA) String

func (rr *SOA) String() string

func (*SOA) Unpack

func (rr *SOA) Unpack(data []byte, offset int) (int, error)

type SerialComparison

type SerialComparison int
const (
	SerialEqual SerialComparison = iota
	SerialLess
	SerialGreater
)

type TXT

type TXT struct {
	H    Header
	Data string
}

See https://datatracker.ietf.org/doc/html/rfc1035#section-3.3.14

func (*TXT) Header

func (rr *TXT) Header() *Header

func (*TXT) IsSame

func (rr *TXT) IsSame(o RR) bool

func (*TXT) Len

func (rr *TXT) Len() uint16

func (*TXT) Pack

func (rr *TXT) Pack(buf []byte, offset int, _ compression.Map) (int, error)

func (*TXT) SetData

func (rr *TXT) SetData(data ...interface{}) error

func (*TXT) SetHeader

func (rr *TXT) SetHeader(header Header)

func (*TXT) String

func (rr *TXT) String() string

func (*TXT) Unpack

func (rr *TXT) Unpack(data []byte, offset int) (int, error)

Jump to

Keyboard shortcuts

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