Documentation ¶
Overview ¶
Package dns deals with encoding and decoding DNS wire format.
Index ¶
Constants ¶
const ( // https://tools.ietf.org/html/rfc1035#section-3.2.2 RRTypeTXT = 16 // https://tools.ietf.org/html/rfc6891#section-6.1.1 RRTypeOPT = 41 // https://tools.ietf.org/html/rfc1035#section-3.2.4 ClassIN = 1 // https://tools.ietf.org/html/rfc1035#section-4.1.1 RcodeNoError = 0 // a.k.a. NOERROR RcodeFormatError = 1 // a.k.a. FORMERR RcodeNameError = 3 // a.k.a. NXDOMAIN RcodeNotImplemented = 4 // a.k.a. NOTIMPL // https://tools.ietf.org/html/rfc6891#section-9 ExtendedRcodeBadVers = 16 // a.k.a. BADVERS )
Variables ¶
var ( // ErrZeroLengthLabel is the error returned for names that contain a // zero-length label, like "example..com". ErrZeroLengthLabel = errors.New("name contains a zero-length label") // ErrLabelTooLong is the error returned for labels that are longer than // 63 octets. ErrLabelTooLong = errors.New("name contains a label longer than 63 octets") // ErrNameTooLong is the error returned for names whose encoded // representation is longer than 255 octets. ErrNameTooLong = errors.New("name is longer than 255 octets (try using a shorter base domain?)") // ErrReservedLabelType is the error returned when reading a label type // prefix whose two most significant bits are not 00 or 11. ErrReservedLabelType = errors.New("reserved label type") // ErrTooManyPointers is the error returned when reading a compressed // name that has too many compression pointers. ErrTooManyPointers = errors.New("too many compression pointers") // ErrTrailingBytes is the error returned when bytes remain in the parse // buffer after parsing a message. ErrTrailingBytes = errors.New("trailing bytes after message") // ErrIntegerOverflow is the error returned when trying to encode an // integer greater than 65535 into a 16-bit field. ErrIntegerOverflow = errors.New("integer overflow") )
Functions ¶
func DecodeRDataTXT ¶
DecodeRDataTXT decodes TXT-DATA (as found in the RDATA for a resource record with TYPE=TXT) as a raw byte slice, by concatenating all the <character-string>s it contains.
func EncodeRDataTXT ¶
EncodeRDataTXT encodes a slice of bytes as TXT-DATA, as appropriate for the RDATA of a resource record with TYPE=TXT. No length restriction is enforced here; that must be checked at a higher level.
Types ¶
type Message ¶
type Message struct { ID uint16 Flags uint16 Question []Question Answer []RR Authority []RR Additional []RR }
Message represents a DNS message.
https://tools.ietf.org/html/rfc1035#section-4.1
func MessageFromWireFormat ¶
MessageFromWireFormat parses a message from buf and returns a Message object. It returns ErrTrailingBytes if there are bytes remaining in buf after parsing is done.
func (*Message) WireFormat ¶
WireFormat encodes a Message as a slice of bytes in DNS wire format. It returns ErrIntegerOverflow if the number of entries in any section, or the length of the data in any resource record, does not fit in 16 bits.
type Name ¶
type Name [][]byte
Name represents a domain name, a sequence of labels each of which is 63 octets or less in length.
https://tools.ietf.org/html/rfc1035#section-3.1
func NewName ¶
NewName returns a Name from a slice of labels, after checking the labels for validity. Does not include a zero-length label at the end of the slice.
func ParseName ¶
ParseName returns a new Name from a string of labels separated by dots, after checking the name for validity. A single dot at the end of the string is ignored.