Documentation ¶
Overview ¶
Code generated by "stringer" command for the types within this file; DO NOT EDIT. and then joined together to keep directory clean. The functions have also been modified to avoid heap allocations. - //go:generate stringer -type=Class -trimprefix=Class -output=string_class.go - //go:generate stringer -type=Type -trimprefix=Type -output=string_type.go - //go:generate stringer -type=OpCode -trimprefix=OpCode -output=string_opcode.go
Index ¶
- Constants
- type Class
- type Header
- type HeaderFlags
- func (flags HeaderFlags) IsAuthorativeAnswer() bool
- func (flags HeaderFlags) IsRecursionAvailable() bool
- func (flags HeaderFlags) IsRecursionDesired() bool
- func (flags HeaderFlags) IsResponse() bool
- func (flags HeaderFlags) IsTruncated() bool
- func (flags HeaderFlags) OpCode() OpCode
- func (flags HeaderFlags) ResponseCode() RCode
- func (flags HeaderFlags) String() string
- type Message
- func (m *Message) AddQuestions(questions []Question)
- func (m *Message) AppendTo(buf []byte) (_ []byte, err error)
- func (m *Message) Decode(msg []byte) (_ uint16, incompleteButOK bool, err error)
- func (m *Message) Len() uint16
- func (m *Message) LimitResourceDecoding(maxQ, maxAns, maxAuth, maxAdd uint16)
- func (m *Message) Reset()
- type Name
- func (n *Name) AddLabel(label string)
- func (n *Name) AppendDottedTo(b []byte) []byte
- func (n *Name) AppendTo(b []byte) ([]byte, error)
- func (n *Name) CanAddLabel(label string) bool
- func (n *Name) CloneFrom(ex Name)
- func (n *Name) Decode(b []byte, off uint16) (uint16, error)
- func (n *Name) Len() uint16
- func (n *Name) Reset()
- func (n *Name) String() string
- func (n *Name) VisitLabels(fn func(label []byte)) error
- type OpCode
- type Question
- type RCode
- type Resource
- type ResourceHeader
- type Type
Constants ¶
const ( // SizeHeader is the length (in bytes) of a DNS header. // A header is comprised of 6 uint16s and no padding. SizeHeader = 6 * 2 // The Internet supports name server access using TCP [RFC-9293] on server // port 53 (decimal) as well as datagram access using UDP [RFC-768] on UDP port 53 (decimal). ServerPort = 53 ClientPort = 53 // Messages carried by UDP are restricted to 512 bytes (not counting the IP // or UDP headers). Longer messages are truncated and the TC bit is set in the header. MaxSizeUDP = 512 )
Global parameters.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct { // Generated for any kind of query. This identifier is copied // the corresponding reply and can be used by the requester to // match up replies to outstanding queries. TransactionID uint16 // 0:2 Flags HeaderFlags // 2:4 // number of entries in the question section. QDCount uint16 // 4:6 // number of resource records in the answer section. ANCount uint16 // 6:8 // number of name server resource records in the authority records section. NSCount uint16 // 8:10 // number of resource records in the additional records section. ARCount uint16 // 10:12 }
func DecodeHeader ¶
type HeaderFlags ¶
type HeaderFlags uint16
HeaderFlags gathers the flags in bits 16..31 of the header.
func NewClientHeaderFlags ¶
func NewClientHeaderFlags(op OpCode, enableRecursion bool) HeaderFlags
NewClientHeaderFlags creates the header flags for a client request.
func (HeaderFlags) IsAuthorativeAnswer ¶
func (flags HeaderFlags) IsAuthorativeAnswer() bool
IsAuthorativeAnswer returns AA bit which specifies that the responding name server is an authority for the domain name in question section.
func (HeaderFlags) IsRecursionAvailable ¶
func (flags HeaderFlags) IsRecursionAvailable() bool
IsRecursionAvailable returns RA bit which specifies whether recursive query support is available by the server.
func (HeaderFlags) IsRecursionDesired ¶
func (flags HeaderFlags) IsRecursionDesired() bool
IsRecursionDesired returns RD bit which specifies whether recursive query support is desired by the client. Is optionally set by client.
func (HeaderFlags) IsResponse ¶
func (flags HeaderFlags) IsResponse() bool
IsResponse returns QR bit which specifies whether this message is a query (0), or a response (1).
func (HeaderFlags) IsTruncated ¶
func (flags HeaderFlags) IsTruncated() bool
IsTruncated returns TC bit which specifies that this message was truncated due to length greater than that permitted on the transmission channel.
func (HeaderFlags) OpCode ¶
func (flags HeaderFlags) OpCode() OpCode
OpCode returns the 4-bit opcode.
func (HeaderFlags) ResponseCode ¶
func (flags HeaderFlags) ResponseCode() RCode
ResponseCode returns the 4-bit response code set as part of responses.
func (HeaderFlags) String ¶
func (flags HeaderFlags) String() string
type Message ¶
type Message struct { Header Questions []Question Answers []Resource Authorities []Resource Additionals []Resource }
func (*Message) AddQuestions ¶
func (*Message) Decode ¶
Decode decodes the DNS message in b into m. It returns the number of bytes consumed from b (0 if no bytes were consumed) and any error encountered. If the message was not completely parsed due to LimitResourceDecoding, incompleteButOK is true and an error is returned, though the message is still usable.
func (*Message) LimitResourceDecoding ¶
type Name ¶
type Name struct {
// contains filtered or unexported fields
}
func MustNewName ¶
func (*Name) AddLabel ¶
AddLabel adds a label to the name. If n.CanAddLabel(label) returns false, it panics.
func (*Name) AppendDottedTo ¶
AppendDottedTo appends the Name to b in dotted format and returns the resulting slice.
func (*Name) AppendTo ¶
AppendTo appends the Name to b in wire format and returns the resulting slice.
func (*Name) CanAddLabel ¶
CanAddLabel reports whether the label can be added to the name.
func (*Name) Decode ¶
Decode resets internal Name buffer and reads raw wire data from buffer, returning any error encountered.
func (*Name) Reset ¶
func (n *Name) Reset()
Reset resets the Name labels to be empty and reuses buffer.
func (*Name) VisitLabels ¶
type OpCode ¶
type OpCode uint16
An OpCode is a DNS operation code which specifies the type of query.
type RCode ¶
type RCode uint16
An RCode is a DNS response status code.
const ( RCodeSuccess RCode = 0 // No error condition. RCodeFormatError RCode = 1 // Format error - The name server was unable to interpret the query. RCodeServerFailure RCode = 2 // Server failure - The name server was unable to process this query due to a problem with the name server. RCodeNameError RCode = 3 // Name Error - Meaningful only for responses from an authoritative name server, this code signifies that the domain name referenced in the query does not exist. RCodeNotImplemented RCode = 4 // Not implemented - The name server does not support the requested kind of query. RCodeRefused RCode = 5 // Refused - The name server refuses to perform the specified operation for policy reasons. For example, a name server may not wish to provide the information to the particular requester, or a name server may not wish to perform a particular operation (e.g., zone transfer) for particular data. )
/go:generate stringer -type=RCode -trimprefix=RCode -output=rcode_string.go
type Resource ¶
type Resource struct { Header ResourceHeader // contains filtered or unexported fields }
type ResourceHeader ¶
A ResourceHeader is the header of a DNS resource record. There are many types of DNS resource records, but they all share the same header.
func (*ResourceHeader) Decode ¶
func (rhdr *ResourceHeader) Decode(msg []byte, off uint16) (uint16, error)
func (*ResourceHeader) Reset ¶
func (r *ResourceHeader) Reset()
func (*ResourceHeader) String ¶
func (h *ResourceHeader) String() string
String returns a string representation of the header.
type Type ¶
type Type uint16
Type is a type of DNS request and response.
const ( // ResourceHeader.Type and Question.Type TypeA Type = 1 TypeNS Type = 2 TypeCNAME Type = 5 TypeSOA Type = 6 TypePTR Type = 12 TypeMX Type = 15 TypeTXT Type = 16 TypeAAAA Type = 28 TypeSRV Type = 33 TypeOPT Type = 41 // Question.Type TypeWKS Type = 11 TypeHINFO Type = 13 TypeMINFO Type = 14 TypeAXFR Type = 252 TypeALL Type = 255 )