Documentation
¶
Index ¶
- type Header
- type Message
- func (m *Message) AddAdditional(record rr.RR)
- func (m *Message) AddAnswer(record rr.RR)
- func (m *Message) AddAnswers(records []rr.RR)
- func (m *Message) AddAuthority(record rr.RR)
- func (m *Message) AddQuestion(question Question)
- func (m *Message) AddRecords(answer, authority, additional []rr.RR)
- func (m *Message) IsEDNS() bool
- func (m *Message) IsSOA() bool
- func (m *Message) Len() int
- func (m Message) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (m *Message) Q() (string, uint16, uint16)
- func (m *Message) SetIsResponse()
- func (m *Message) SetRecursionAvailable(ra bool)
- type Question
- type RawHeader
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Header ¶
type Header struct { ID uint16 // ID IsQuery bool // QR OpCode opcode.Code // OPCODE Authoritative bool // AA Truncated bool // TC RecursionDesired bool // RD RecursionAvailable bool // RA Zero bool // Z RCode rcode.Code // RCODE QDCount uint16 // Question count ANCount uint16 // Answer count NSCount uint16 // Authority count ARCount uint16 // Additional record count }
Header describes the header data of a message. This header format enables easy access to all header fields. The RawHeader in comparison stores raw data directly from the "wire". See https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.1
type Message ¶
type Message struct { Header Header Question []Question Answer []rr.RR Authority []rr.RR Additional []rr.RR // Compression keeps track of compression pointers // and domain names Compression compression.Map }
Message describes a complete DNS message describes in RFC 1035 Section 4. See https://datatracker.ietf.org/doc/html/rfc1035#section-4
func NewMessage ¶
func NewMessage() *Message
NewMessage returns a new empty (default value) DNS message
func NewMessageWith ¶
NewMessageWith returns a new empty (default value) DNS message with the provided header
func (*Message) AddAdditional ¶
AddAdditional adds a resource record to the additional section
func (*Message) AddAnswers ¶
AddAnswers adds multiple resource record sto the answer section of the message
func (*Message) AddAuthority ¶
AddAuthority adds a resource record to the authoritative name server section
func (*Message) AddQuestion ¶
AddQuestion adds a question to the question section of the message
func (*Message) AddRecords ¶
AddRecords adds multiple answerm authority and additional RRs to the appropriate sections in the message
func (Message) MarshalLogObject ¶
func (m Message) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject marshals the DNS message as a zap log object
func (*Message) SetIsResponse ¶
func (m *Message) SetIsResponse()
SetIsResponse sets the QR bit of the DNS header to 1
func (*Message) SetRecursionAvailable ¶
SetRecursionAvailable sets the RA bit in the DNS header to 1
type Question ¶
Questions holds a DNS question. The RFC allows multiple questions per message, but most DNS servers only accpet one and multiple questions often result in errors. See https://datatracker.ietf.org/doc/html/rfc1035#section-4.1.2
func (Question) MarshalLogObject ¶
func (q Question) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject marshals a DNS question as a zap log object
type RawHeader ¶
type RawHeader struct { ID uint16 // ID Flags uint16 // Various flags, see above QDCount uint16 // QDCOUNT ANCount uint16 // ANCOUNT NSCount uint16 // NSCOUNT ARCount uint16 // ARCOUNT }
RawHeader describes the raw header data of a message directly from the "wire". The data gets unpacked by splitting the message into six 16 bit (2 octet) chunks. The second chunk "flags" carries data like QR, OPCODE, etc. which gets split up further by bit masks