package dnsmessage

Import Path
	vendor/golang.org/x/net/dns/dnsmessage (on golang.org and go.dev)

Dependency Relation
	imports one package, and imported by one package

Involved Source Files
	d-> message.go

Exported Type Names

type AAAAResource (struct) An AAAAResource is an AAAA Resource record. AAAA [16]byte (*T) GoString() string *T : ResourceBody *T : fmt.GoStringer func (*Parser).AAAAResource() (AAAAResource, error) func (*Builder).AAAAResource(h ResourceHeader, r AAAAResource) error
type AResource (struct) An AResource is an A Resource record. A [4]byte (*T) GoString() string *T : ResourceBody *T : fmt.GoStringer func (*Parser).AResource() (AResource, error) func (*Builder).AResource(h ResourceHeader, r AResource) error
type Builder (struct) A Builder allows incrementally packing a DNS message. Example usage: buf := make([]byte, 2, 514) b := NewBuilder(buf, Header{...}) b.EnableCompression() // Optionally start a section and add things to that section. // Repeat adding sections as necessary. buf, err := b.Finish() // If err is nil, buf[2:] will contain the built bytes. (*T) AAAAResource(h ResourceHeader, r AAAAResource) error (*T) AResource(h ResourceHeader, r AResource) error (*T) CNAMEResource(h ResourceHeader, r CNAMEResource) error (*T) EnableCompression() (*T) Finish() ([]byte, error) (*T) MXResource(h ResourceHeader, r MXResource) error (*T) NSResource(h ResourceHeader, r NSResource) error (*T) OPTResource(h ResourceHeader, r OPTResource) error (*T) PTRResource(h ResourceHeader, r PTRResource) error (*T) Question(q Question) error (*T) SOAResource(h ResourceHeader, r SOAResource) error (*T) SRVResource(h ResourceHeader, r SRVResource) error (*T) StartAdditionals() error (*T) StartAnswers() error (*T) StartAuthorities() error (*T) StartQuestions() error (*T) TXTResource(h ResourceHeader, r TXTResource) error func NewBuilder(buf []byte, h Header) Builder
type Class uint16 A Class is a type of network. (T) GoString() string (T) String() string T : expvar.Var T : fmt.GoStringer T : fmt.Stringer const ClassANY const ClassCHAOS const ClassCSNET const ClassHESIOD const ClassINET
type CNAMEResource (struct) A CNAMEResource is a CNAME Resource record. CNAME Name (*T) GoString() string *T : ResourceBody *T : fmt.GoStringer func (*Parser).CNAMEResource() (CNAMEResource, error) func (*Builder).CNAMEResource(h ResourceHeader, r CNAMEResource) error
type Header (struct) Header is a representation of a DNS message header. Authoritative bool ID uint16 OpCode OpCode RCode RCode RecursionAvailable bool RecursionDesired bool Response bool Truncated bool (*T) GoString() string *T : fmt.GoStringer func (*Parser).Start(msg []byte) (Header, error) func NewBuilder(buf []byte, h Header) Builder
type Message (struct) Message is a representation of a DNS message. Additionals []Resource Answers []Resource Authorities []Resource Header Header Header.Authoritative bool Header.ID uint16 Header.OpCode OpCode Header.RCode RCode Header.RecursionAvailable bool Header.RecursionDesired bool Header.Response bool Header.Truncated bool Questions []Question (*T) AppendPack(b []byte) ([]byte, error) (*T) GoString() string (*T) Pack() ([]byte, error) (*T) Unpack(msg []byte) error *T : fmt.GoStringer
type MXResource (struct) An MXResource is an MX Resource record. MX Name Pref uint16 (*T) GoString() string *T : ResourceBody *T : fmt.GoStringer func (*Parser).MXResource() (MXResource, error) func (*Builder).MXResource(h ResourceHeader, r MXResource) error
type Name (struct) A Name is a non-encoded domain name. It is used instead of strings to avoid allocations. Data [255]byte Length uint8 (*T) GoString() string (T) String() string T : expvar.Var *T : fmt.GoStringer T : fmt.Stringer func MustNewName(name string) Name func NewName(name string) (Name, error)
type NSResource (struct) An NSResource is an NS Resource record. NS Name (*T) GoString() string *T : ResourceBody *T : fmt.GoStringer func (*Parser).NSResource() (NSResource, error) func (*Builder).NSResource(h ResourceHeader, r NSResource) error
type OpCode uint16 An OpCode is a DNS operation code. (T) GoString() string T : fmt.GoStringer
type Option (struct) An Option represents a DNS message option within OPTResource. The message option is part of the extension mechanisms for DNS as defined in RFC 6891. Code uint16 Data []byte (*T) GoString() string *T : fmt.GoStringer
type OPTResource (struct) An OPTResource is an OPT pseudo Resource record. The pseudo resource record is part of the extension mechanisms for DNS as defined in RFC 6891. Options []Option (*T) GoString() string *T : ResourceBody *T : fmt.GoStringer func (*Parser).OPTResource() (OPTResource, error) func (*Builder).OPTResource(h ResourceHeader, r OPTResource) error
type Parser (struct) A Parser allows incrementally parsing a DNS message. When parsing is started, the Header is parsed. Next, each Question can be either parsed or skipped. Alternatively, all Questions can be skipped at once. When all Questions have been parsed, attempting to parse Questions will return (nil, nil) and attempting to skip Questions will return (true, nil). After all Questions have been either parsed or skipped, all Answers, Authorities and Additionals can be either parsed or skipped in the same way, and each type of Resource must be fully parsed or skipped before proceeding to the next type of Resource. Note that there is no requirement to fully skip or parse the message. (*T) AAAAResource() (AAAAResource, error) (*T) AResource() (AResource, error) (*T) Additional() (Resource, error) (*T) AdditionalHeader() (ResourceHeader, error) (*T) AllAdditionals() ([]Resource, error) (*T) AllAnswers() ([]Resource, error) (*T) AllAuthorities() ([]Resource, error) (*T) AllQuestions() ([]Question, error) (*T) Answer() (Resource, error) (*T) AnswerHeader() (ResourceHeader, error) (*T) Authority() (Resource, error) (*T) AuthorityHeader() (ResourceHeader, error) (*T) CNAMEResource() (CNAMEResource, error) (*T) MXResource() (MXResource, error) (*T) NSResource() (NSResource, error) (*T) OPTResource() (OPTResource, error) (*T) PTRResource() (PTRResource, error) (*T) Question() (Question, error) (*T) SOAResource() (SOAResource, error) (*T) SRVResource() (SRVResource, error) (*T) SkipAdditional() error (*T) SkipAllAdditionals() error (*T) SkipAllAnswers() error (*T) SkipAllAuthorities() error (*T) SkipAllQuestions() error (*T) SkipAnswer() error (*T) SkipAuthority() error (*T) SkipQuestion() error (*T) Start(msg []byte) (Header, error) (*T) TXTResource() (TXTResource, error)
type PTRResource (struct) A PTRResource is a PTR Resource record. PTR Name (*T) GoString() string *T : ResourceBody *T : fmt.GoStringer func (*Parser).PTRResource() (PTRResource, error) func (*Builder).PTRResource(h ResourceHeader, r PTRResource) error
type Question (struct) A Question is a DNS query. Class Class Name Name Type Type (*T) GoString() string *T : fmt.GoStringer func (*Parser).AllQuestions() ([]Question, error) func (*Parser).Question() (Question, error) func (*Builder).Question(q Question) error
type RCode uint16 An RCode is a DNS response status code. (T) GoString() string (T) String() string T : expvar.Var T : fmt.GoStringer T : fmt.Stringer func (*ResourceHeader).ExtendedRCode(rcode RCode) RCode func (*ResourceHeader).ExtendedRCode(rcode RCode) RCode func (*ResourceHeader).SetEDNS0(udpPayloadLen int, extRCode RCode, dnssecOK bool) error const RCodeFormatError const RCodeNameError const RCodeNotImplemented const RCodeRefused const RCodeServerFailure const RCodeSuccess
type Resource (struct) A Resource is a DNS resource record. Body ResourceBody Header ResourceHeader (*T) GoString() string *T : fmt.GoStringer func (*Parser).Additional() (Resource, error) func (*Parser).AllAdditionals() ([]Resource, error) func (*Parser).AllAnswers() ([]Resource, error) func (*Parser).AllAuthorities() ([]Resource, error) func (*Parser).Answer() (Resource, error) func (*Parser).Authority() (Resource, error)
type ResourceBody (interface) A ResourceBody is a DNS resource record minus the header. (T) GoString() string *AAAAResource *AResource *CNAMEResource *MXResource *NSResource *OPTResource *PTRResource *SOAResource *SRVResource *TXTResource T : fmt.GoStringer
type ResourceHeader (struct) 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. Class Class Length uint16 Name Name TTL uint32 Type Type (*T) DNSSECAllowed() bool (*T) ExtendedRCode(rcode RCode) RCode (*T) GoString() string (*T) SetEDNS0(udpPayloadLen int, extRCode RCode, dnssecOK bool) error *T : fmt.GoStringer func (*Parser).AdditionalHeader() (ResourceHeader, error) func (*Parser).AnswerHeader() (ResourceHeader, error) func (*Parser).AuthorityHeader() (ResourceHeader, error) func (*Builder).AAAAResource(h ResourceHeader, r AAAAResource) error func (*Builder).AResource(h ResourceHeader, r AResource) error func (*Builder).CNAMEResource(h ResourceHeader, r CNAMEResource) error func (*Builder).MXResource(h ResourceHeader, r MXResource) error func (*Builder).NSResource(h ResourceHeader, r NSResource) error func (*Builder).OPTResource(h ResourceHeader, r OPTResource) error func (*Builder).PTRResource(h ResourceHeader, r PTRResource) error func (*Builder).SOAResource(h ResourceHeader, r SOAResource) error func (*Builder).SRVResource(h ResourceHeader, r SRVResource) error func (*Builder).TXTResource(h ResourceHeader, r TXTResource) error
type SOAResource (struct) An SOAResource is an SOA Resource record. Expire uint32 MBox Name MinTTL uint32 NS Name Refresh uint32 Retry uint32 Serial uint32 (*T) GoString() string *T : ResourceBody *T : fmt.GoStringer func (*Parser).SOAResource() (SOAResource, error) func (*Builder).SOAResource(h ResourceHeader, r SOAResource) error
type SRVResource (struct) An SRVResource is an SRV Resource record. Port uint16 Priority uint16 Target Name Weight uint16 (*T) GoString() string *T : ResourceBody *T : fmt.GoStringer func (*Parser).SRVResource() (SRVResource, error) func (*Builder).SRVResource(h ResourceHeader, r SRVResource) error
type TXTResource (struct) A TXTResource is a TXT Resource record. TXT []string (*T) GoString() string *T : ResourceBody *T : fmt.GoStringer func (*Parser).TXTResource() (TXTResource, error) func (*Builder).TXTResource(h ResourceHeader, r TXTResource) error
type Type uint16 A Type is a type of DNS request and response. (T) GoString() string (T) String() string T : expvar.Var T : fmt.GoStringer T : fmt.Stringer const TypeA const TypeAAAA const TypeALL const TypeAXFR const TypeCNAME const TypeHINFO const TypeMINFO const TypeMX const TypeNS const TypeOPT const TypePTR const TypeSOA const TypeSRV const TypeTXT const TypeWKS
Exported Values
const ClassANY Class = 255 Question.Class
const ClassCHAOS Class = 3
const ClassCSNET Class = 2
const ClassHESIOD Class = 4
const ClassINET Class = 1 ResourceHeader.Class and Question.Class
var ErrNotStarted error ErrNotStarted indicates that the prerequisite information isn't available yet because the previous records haven't been appropriately parsed, skipped or finished.
var ErrSectionDone error ErrSectionDone indicated that all records in the section have been parsed or finished.
func MustNewName(name string) Name MustNewName creates a new Name from a string and panics on error.
func NewBuilder(buf []byte, h Header) Builder NewBuilder creates a new builder with compression disabled. Note: Most users will want to immediately enable compression with the EnableCompression method. See that method's comment for why you may or may not want to enable compression. The DNS message is appended to the provided initial buffer buf (which may be nil) as it is built. The final message is returned by the (*Builder).Finish method, which may return the same underlying array if there was sufficient capacity in the slice.
func NewName(name string) (Name, error) NewName creates a new Name from a string.
const RCodeRefused RCode = 5
const RCodeSuccess RCode = 0 Message.Rcode
const TypeA Type = 1 ResourceHeader.Type and Question.Type
const TypeAAAA Type = 28
const TypeALL Type = 255
const TypeAXFR Type = 252
const TypeCNAME Type = 5
const TypeHINFO Type = 13
const TypeMINFO Type = 14
const TypeMX Type = 15
const TypeNS Type = 2
const TypeOPT Type = 41
const TypePTR Type = 12
const TypeSOA Type = 6
const TypeSRV Type = 33
const TypeTXT Type = 16
const TypeWKS Type = 11 Question.Type