70 lines
3.1 KiB
Go
70 lines
3.1 KiB
Go
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package query
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
// Message is for overall DNS responses.
|
|
//
|
|
//nolint:govet // Better looking output is worth a few bytes.
|
|
type Message struct {
|
|
// Header section
|
|
Header Header `json:"header,omitempty" xml:"header,omitempty" yaml:"header,omitempty"`
|
|
// Opt Pseudosection
|
|
Opt []Opts `json:"opt,omitempty" xml:"opt,omitempty" yaml:"opt,omitempty"`
|
|
// Question Section
|
|
Question []Question `json:"question,omitempty" xml:"question,omitempty" yaml:"question,omitempty"`
|
|
// Answer Section
|
|
Answer []Answer `json:"answer,omitempty" xml:"answer,omitempty" yaml:"answer,omitempty"`
|
|
// Authority Section
|
|
Authority []Answer `json:"authority,omitempty" xml:"authority,omitempty" yaml:"authority,omitempty"`
|
|
// Additional Section
|
|
Additional []Answer `json:"additional,omitempty" xml:"additional,omitempty" yaml:"additional,omitempty"`
|
|
}
|
|
|
|
// Header is the header.
|
|
type Header struct {
|
|
Opcode string `json:"opcode," xml:"opcode," yaml:"opcode"`
|
|
Status string `json:"status," xml:"status," yaml:"status"`
|
|
ID uint16 `json:"id," xml:"id," yaml:"id"`
|
|
Response bool `json:"response," xml:"response," yaml:"response"`
|
|
Authoritative bool `json:"authoritative," xml:"authoritative," yaml:"authoritative"`
|
|
Truncated bool `json:"truncated," xml:"truncated," yaml:"truncated"`
|
|
RecursionDesired bool `json:"recursionDesired," xml:"recursionDesired," yaml:"recursionDesired"`
|
|
RecursionAvailable bool `json:"recursionAvailable," xml:"recursionAvailable," yaml:"recursionAvailable"`
|
|
Zero bool `json:"zero," xml:"zero," yaml:"zero"`
|
|
AuthenticatedData bool `json:"authenticatedData," xml:"authenticatedData," yaml:"authenticatedData"`
|
|
CheckingDisabled bool `json:"checkingDisabled," xml:"checkingDisabled," yaml:"checkingDisabled"`
|
|
}
|
|
|
|
// Question is a DNS Query.
|
|
type Question struct {
|
|
Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
|
|
Class string `json:"class,omitempty" xml:"class,omitempty" yaml:"class,omitempty"`
|
|
Type string `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty"`
|
|
}
|
|
|
|
// RRHeader is for DNS Resource Headers.
|
|
type RRHeader struct {
|
|
Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
|
|
TTL string `json:"ttl,omitempty" xml:"ttl,omitempty" yaml:"ttl,omitempty"`
|
|
Class string `json:"class,omitempty" xml:"class,omitempty" yaml:"class,omitempty"`
|
|
Type string `json:"type,omitempty" xml:"type,omitempty" yaml:"type,omitempty"`
|
|
Rdlength uint16 `json:"-" xml:"-" yaml:"-"`
|
|
}
|
|
|
|
// Opts is for the OPT pseudosection, nearly exclusively for EDNS.
|
|
type Opts struct {
|
|
Name string `json:"name,omitempty" xml:"name,omitempty" yaml:",omitempty"`
|
|
Value string `json:"value" xml:"value" yaml:"value"`
|
|
}
|
|
|
|
// Answer is for a DNS Response.
|
|
type Answer struct {
|
|
Value string `json:"response,omitempty" xml:"response,omitempty" yaml:"response,omitempty"`
|
|
RRHeader `json:"header,omitempty" xml:"header,omitempty" yaml:"header,omitempty"`
|
|
}
|
|
|
|
var errNoMessage = errors.New("no message")
|