79 lines
4.9 KiB
Go
79 lines
4.9 KiB
Go
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
package query
|
|
|
|
import (
|
|
"errors"
|
|
)
|
|
|
|
// Message is for overall DNS responses.
|
|
//
|
|
//nolint:govet,tagliatelle // Better looking output is worth a few bytes.
|
|
type Message struct {
|
|
DateString string `json:"dateString,omitempty" xml:"dateString,omitempty" yaml:"dateString,omitempty"`
|
|
DateSeconds int64 `json:"dateSeconds,omitempty" xml:"dateSeconds,omitempty" yaml:"dateSeconds,omitempty"`
|
|
MsgSize int `json:"msgLength,omitempty" xml:"msgSize,omitempty" yaml:"msgSize,omitempty"`
|
|
ID uint16 `json:"id," xml:"id," yaml:"id" example:"12"`
|
|
|
|
Opcode string `json:"opcode," xml:"opcode," yaml:"opcode" example:"QUERY"`
|
|
Status string `json:"status," xml:"status," yaml:"status" example:"NOERR"`
|
|
Response bool `json:"response," xml:"response," yaml:"response" example:"true"`
|
|
Authoritative bool `json:"authoritative," xml:"authoritative," yaml:"authoritative" example:"false"`
|
|
Truncated bool `json:"truncated," xml:"truncated," yaml:"truncated" example:"false"`
|
|
RecursionDesired bool `json:"RD," xml:"recursionDesired," yaml:"recursionDesired" example:"true"`
|
|
RecursionAvailable bool `json:"RA," xml:"recursionAvailable," yaml:"recursionAvailable" example:"true"`
|
|
Zero bool `json:"zero," xml:"zero," yaml:"zero" example:"false"`
|
|
AuthenticatedData bool `json:"authenticatedData," xml:"authenticatedData," yaml:"authenticatedData" example:"false"`
|
|
CheckingDisabled bool `json:"checkingDisabled," xml:"checkingDisabled," yaml:"checkingDisabled" example:"false"`
|
|
Name string `json:"QNAME,omitempty" xml:"QNAME,omitempty" yaml:"QNAME,omitempty" example:"localhost"`
|
|
Type uint16 `json:"QTYPE,omitempty" xml:"QTYPE,omitempty" yaml:"QTYPE,omitempty" example:"IN"`
|
|
TypeName string `json:"QTYPEname,omitempty" xml:"QTYPEname,omitempty" yaml:"QTYPEname,omitempty" example:"IN"`
|
|
Class uint16 `json:"QCLASS,omitempty" xml:"QCLASS,omitempty" yaml:"QCLASS,omitempty" example:"A"`
|
|
ClassName string `json:"QCLASSname,omitempty" xml:"QCLASSname,omitempty" yaml:"QCLASSname,omitempty" example:"1"`
|
|
RTT string `json:"queryTime,omitempty" xml:"queryTime,omitempty" yaml:"queryTime,omitempty"`
|
|
Server string `json:"server,omitempty" xml:"server,omitempty" yaml:"server,omitempty"`
|
|
When string `json:"when,omitempty" xml:"when,omitempty" yaml:"when,omitempty"`
|
|
|
|
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
|
|
AnswerRRs []Answer `json:"answersRRs,omitempty" xml:"answersRRs,omitempty" yaml:"answersRRs,omitempty" example:"false"`
|
|
AuthoritativeRRs []Answer `json:"authorityRRs,omitempty" xml:"authorityRRs,omitempty" yaml:"authorityRRs,omitempty" example:"false"`
|
|
AdditionalRRs []Answer `json:"additionalRRs,omitempty" xml:"additionalRRs,omitempty" yaml:"additionalRRs,omitempty" example:"false"`
|
|
}
|
|
|
|
// Question is a DNS Query.
|
|
//
|
|
//nolint:govet,tagliatelle
|
|
type Question struct {
|
|
Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty" example:"localhost"`
|
|
Type uint16 `json:"TYPE,omitempty" xml:"type,omitempty" yaml:"type,omitempty" example:"IN"`
|
|
TypeName string `json:"TYPEname,omitempty" xml:"TYPEname,omitempty" yaml:"TYPEname,omitempty" example:"IN"`
|
|
Class uint16 `json:"CLASS,omitempty" xml:"class,omitempty" yaml:"class,omitempty" example:"A"`
|
|
ClassName string `json:"CLASSname,omitempty" xml:"CLASSname,omitempty" yaml:"CLASSname,omitempty" example:"1"`
|
|
}
|
|
|
|
// Answer is for DNS Resource Headers.
|
|
//
|
|
//nolint:govet,tagliatelle
|
|
type Answer struct {
|
|
Name string `json:"NAME,omitempty" xml:"name,omitempty" yaml:"name,omitempty" example:"127.0.0.1"`
|
|
Type uint16 `json:"TYPE,omitempty" xml:"type,omitempty" yaml:"type,omitempty" example:"IN"`
|
|
TypeName string `json:"TYPEname,omitempty" xml:"TYPEname,omitempty" yaml:"TYPEname,omitempty" example:"IN"`
|
|
Class uint16 `json:"CLASS,omitempty" xml:"class,omitempty" yaml:"class,omitempty" example:"A"`
|
|
ClassName string `json:"CLASSname,omitempty" xml:"CLASSname,omitempty" yaml:"CLASSname,omitempty" example:"A"`
|
|
TTL string `json:"TTL,omitempty" xml:"ttl,omitempty" yaml:"ttl,omitempty" example:"0ms"`
|
|
Value string `json:"rdata,omitempty" xml:"rdata,omitempty" yaml:"rdata,omitempty"`
|
|
Rdlength uint16 `json:"RDLENGTH,omitempty" xml:"RDLENGTH,omitempty" yaml:"RDLENGTH,omitempty"`
|
|
Rdhex string `json:"RDATAHEX,omitempty" xml:"RDATAHEX,omitempty" yaml:"RDATAHEX,omitempty"`
|
|
}
|
|
|
|
// Opts is for the OPT pseudosection, nearly exclusively for EDNS.
|
|
type Opts struct {
|
|
Name string `json:"name,omitempty" xml:"name,omitempty" yaml:"name,omitempty"`
|
|
Value string `json:"value" xml:"value" yaml:"value"`
|
|
}
|
|
|
|
var errNoMessage = errors.New("no message")
|