Documentation
¶
Index ¶
- Constants
- Variables
- func CompareNames(a, b string) int
- func PaddedMsgLen(msgLen int, blockLen uint16) int
- func RRLen(rr dns.RR) (l int)
- type Builder
- func (b *Builder) Available() int
- func (b *Builder) Cap() int
- func (b *Builder) Clear() *Builder
- func (b *Builder) EnableCompression() *Builder
- func (b *Builder) EnableLengthPrefix() *Builder
- func (b *Builder) EnablePadding(blockLen uint16) *Builder
- func (b *Builder) Err() error
- func (b *Builder) Grow(n int) *Builder
- func (b *Builder) Len() int
- func (b *Builder) Message() ([]byte, error)
- func (b *Builder) Reset() *Builder
- func (b *Builder) SetHeader(h MsgHeader) *Builder
- func (b *Builder) Write(p []byte) (n int, err error)
- func (b *Builder) WriteEncryptionPadding(tlv *EncryptionPadding) (int, error)
- func (b *Builder) WriteKeepAlive(tlv *KeepAlive) (int, error)
- func (b *Builder) WritePush(tlv *Push) (int, error)
- func (b *Builder) WritePushChange(change []dns.RR) (n int, err error)
- func (b *Builder) WriteReconfirm(tlv *Reconfirm) (int, error)
- func (b *Builder) WriteRetryDelay(tlv *RetryDelay) (int, error)
- func (b *Builder) WriteSubscribe(tlv *Subscribe) (int, error)
- func (b *Builder) WriteTLV(tlv TLV) (int, error)
- func (b *Builder) WriteTo(w io.Writer) (int64, error)
- func (b *Builder) WriteUnsubscribe(tlv *Unsubscribe) (int, error)
- type EncryptionPadding
- func (tlv *EncryptionPadding) AppendBinary(b []byte) (b1 []byte, err error)
- func (tlv *EncryptionPadding) Clone() TLV
- func (tlv *EncryptionPadding) Equal(tlv1 TLV) bool
- func (tlv EncryptionPadding) Len() int
- func (tlv *EncryptionPadding) MarshalBinary() ([]byte, error)
- func (tlv EncryptionPadding) String() string
- func (tlv EncryptionPadding) Type() Type
- func (tlv *EncryptionPadding) UnmarshalBinary(data []byte) error
- func (tlv *EncryptionPadding) Verify(usage Usage) error
- type KeepAlive
- func (tlv *KeepAlive) AppendBinary(b []byte) (b1 []byte, err error)
- func (tlv *KeepAlive) Clone() TLV
- func (tlv *KeepAlive) Equal(tlv1 TLV) bool
- func (tlv KeepAlive) Len() int
- func (tlv *KeepAlive) MarshalBinary() ([]byte, error)
- func (tlv KeepAlive) String() string
- func (tlv KeepAlive) Type() Type
- func (tlv *KeepAlive) UnmarshalBinary(data []byte) error
- func (tlv *KeepAlive) Verify(usage Usage) error
- type Msg
- func (m *Msg) AppendBinary(b []byte) ([]byte, error)
- func (m *Msg) Clone() (m1 *Msg)
- func (m *Msg) Equal(m1 *Msg) bool
- func (m *Msg) Len() (n int)
- func (m *Msg) MarshalBinary() ([]byte, error)
- func (m *Msg) Pack() (msg []byte, err error)
- func (m *Msg) PackTo(b *Builder)
- func (m *Msg) UnmarshalBinary(data []byte) error
- func (m *Msg) Verify(request *Msg) (err error)
- type MsgHeader
- func (h MsgHeader) AppendBinary(b []byte) ([]byte, error)
- func (h MsgHeader) IsRequest() bool
- func (h MsgHeader) IsResponse() bool
- func (h MsgHeader) IsUnidirectional() bool
- func (h MsgHeader) MarshalBinary() (data []byte, err error)
- func (h *MsgHeader) UnmarshalBinary(data []byte) (err error)
- func (h MsgHeader) Verify() error
- type Origin
- type PackingError
- type Parser
- func (p *Parser) EncryptionPadding() (tlv EncryptionPadding, err error)
- func (p *Parser) IsPadded() bool
- func (p *Parser) KeepAlive() (tlv KeepAlive, err error)
- func (p *Parser) Push() (tlv Push, err error)
- func (p *Parser) Reconfirm() (tlv Reconfirm, err error)
- func (p *Parser) RetryDelay() (tlv RetryDelay, err error)
- func (p *Parser) SetResponseType(t Type)
- func (p *Parser) SkipTLV() (err error)
- func (p *Parser) Start(msg []byte, origin Origin) (MsgHeader, error)
- func (p *Parser) Subscribe() (tlv Subscribe, err error)
- func (p *Parser) TLV() (TLV, error)
- func (p *Parser) TLVHeader() (h TLVHeader, err error)
- func (p *Parser) TLVUsage() (u Usage)
- func (p *Parser) Unsubscribe() (tlv Unsubscribe, err error)
- type Push
- func (tlv *Push) AppendBinary(b []byte) (b1 []byte, err error)
- func (tlv *Push) Clone() TLV
- func (tlv *Push) Equal(tlv1 TLV) bool
- func (tlv *Push) Len() (l int)
- func (tlv *Push) MarshalBinary() ([]byte, error)
- func (tlv Push) String() string
- func (tlv Push) Type() Type
- func (tlv *Push) UnmarshalBinary(data []byte) error
- func (tlv *Push) Verify(usage Usage) error
- type Reconfirm
- func (tlv *Reconfirm) AppendBinary(b []byte) (b1 []byte, err error)
- func (tlv *Reconfirm) Clone() TLV
- func (tlv *Reconfirm) Equal(tlv1 TLV) bool
- func (tlv *Reconfirm) Len() int
- func (tlv *Reconfirm) MarshalBinary() ([]byte, error)
- func (tlv Reconfirm) String() string
- func (tlv Reconfirm) Type() Type
- func (tlv *Reconfirm) UnmarshalBinary(data []byte) error
- func (tlv *Reconfirm) Verify(usage Usage) error
- type RetryDelay
- func (tlv *RetryDelay) AppendBinary(b []byte) (b1 []byte, err error)
- func (tlv *RetryDelay) Clone() TLV
- func (tlv *RetryDelay) Equal(tlv1 TLV) bool
- func (tlv RetryDelay) Len() int
- func (tlv *RetryDelay) MarshalBinary() ([]byte, error)
- func (tlv RetryDelay) String() string
- func (tlv RetryDelay) Type() Type
- func (tlv *RetryDelay) UnmarshalBinary(data []byte) error
- func (tlv *RetryDelay) Verify(usage Usage) error
- type Subscribe
- func (tlv *Subscribe) AppendBinary(b []byte) (b1 []byte, err error)
- func (tlv *Subscribe) Clone() TLV
- func (tlv *Subscribe) Equal(tlv1 TLV) bool
- func (tlv *Subscribe) Len() int
- func (tlv *Subscribe) MarshalBinary() ([]byte, error)
- func (tlv Subscribe) String() string
- func (tlv Subscribe) Type() Type
- func (tlv *Subscribe) UnmarshalBinary(data []byte) error
- func (tlv *Subscribe) Verify(usage Usage) error
- type TLV
- type TLVHeader
- type Type
- type UnpackingError
- type Unsubscribe
- func (tlv *Unsubscribe) AppendBinary(b []byte) (b1 []byte, err error)
- func (tlv *Unsubscribe) Clone() TLV
- func (tlv *Unsubscribe) Equal(tlv1 TLV) bool
- func (tlv Unsubscribe) Len() int
- func (tlv *Unsubscribe) MarshalBinary() ([]byte, error)
- func (tlv Unsubscribe) String() (s string)
- func (tlv Unsubscribe) Type() Type
- func (tlv *Unsubscribe) UnmarshalBinary(data []byte) error
- func (tlv *Unsubscribe) Verify(usage Usage) error
- type Usage
Examples ¶
Constants ¶
const ( LengthPrefixLen = 2 // MsgHeaderLen is fixed wire length of DSO message header. MsgHeaderLen = 12 // TLVHeaderLen is fixed wire length of [TLVHeader]. TLVHeaderLen = 4 // KeepAliveLen is fixed wire length of [KeepAlive] TLV. KeepAliveLen = 8 // RetryDelayLen is fixed wire length of [RetryDelay] TLV. RetryDelayLen = 4 // UnsubscribeLen is fixed wire length of [Unsubscribe] TLV. UnsubscribeLen = 2 // TLSBlockLen is recommended multiple for padding. // // RFC 8467, Section 4.1: If a server receives a query that includes the EDNS(0) "Padding" // option, ... SHOULD pad the corresponding response to a multiple of 468 octets TLSBlockLen = 468 // MaxMsgLen is maximum wire length of DSO message. MaxMsgLen = dns.MaxMsgSize )
const ( // TypeKeepAlive is type of KeepAlive TLV. TypeKeepAlive = Type(dns.StatefulTypeKeepAlive) // TypeRetryDelay is type of RetryDelay TLV. TypeRetryDelay = Type(dns.StatefulTypeRetryDelay) // TypeEncryptionPadding is type of EncryptionPadding TLV. TypeEncryptionPadding = Type(dns.StatefulTypeEncryptionPadding) // TypeSubscribe is type of Subscribe TLV. TypeSubscribe Type = 0x0040 // TypePush is type of Push TLV. TypePush Type = 0x0041 // TypeUnsubscribe is type of Unsubscribe TLV. TypeUnsubscribe Type = 0x0042 // TypeReconfirm is type of Reconfirm TLV. TypeReconfirm Type = 0x0043 )
const ( // InactivityTimeoutDefault is default inactivity timeout. // // RFC 8490, Section 6.2: On a new DSO Session, if no explicit DSO Keepalive message exchange // has taken place, the default value ... is 15 seconds. InactivityTimeoutDefault = 15 * 1000 // InactivityTimeoutNever is special value that represents "infinity". // // RFC 8490, Section 6.4.2: An inactivity timeout of 0xFFFFFFFF represents "infinity" // and informs the client that it may keep an idle connection open as long as it wishes. InactivityTimeoutNever = 0xFFFFFFFF // KeepAliveIntervalDefault is default keepalive interval. // // RFC 8490, Section 6.2: On a new DSO Session, if no explicit DSO Keepalive message exchange // has taken place, the default value ... is 15 seconds. KeepAliveIntervalDefault = 15 * 1000 // KeepAliveIntervalRecommended is recommended keepalive interval. // // RFC 8490, Section 6.5.2: By default, it is RECOMMENDED that clients request, and servers // grant, a keepalive interval of 60 minutes. KeepAliveIntervalRecommended = 60 * 60 * 1000 // KeepAliveIntervalMin is minimum allowed keepalive interval. // // RFC 8490, Section 7.1: The keepalive interval MUST NOT be less than ten seconds. KeepAliveIntervalMin = 10 * 1000 // KeepAliveIntervalNever is special value that represents "infinity". // // RFC 8490, Section 6.5.2: A keepalive interval value of 0xFFFFFFFF represents "infinity" // and informs the client that it should generate no DSO keepalive traffic. KeepAliveIntervalNever = 0xFFFFFFFF )
const ( // PushTTLRemove is special TTL value for removal. // // RFC 8765, Section 6.3.1: If the TTL has the value 0xFFFFFFFF, then the DNS Resource Record // with the given name, type, class, and RDATA is removed. PushTTLRemove = 0xFFFFFFFF // PushTTLCollectiveRemove is special TTL value for collective removal. // // RFC 8765, Section 6.3.1: If the TTL has the value 0xFFFFFFFE, then this is a 'collective' // remove notification. PushTTLCollectiveRemove = 0xFFFFFFFE // PushTTLAddMin is mininum allowd TTL for addition. // // RFC 8765, Section 6.3.1: If the TTL is in the range 0 to 2,147,483,647 seconds // (0 to 231 - 1, or 0x7FFFFFFF), then a new DNS Resource Record with the given name, // type, class, and RDATA is added. PushTTLAddMin = 0 // PushTTLAddMax is maximum allowd TTL for addition. // // RFC 8765, Section 6.3.1: If the TTL is in the range 0 to 2,147,483,647 seconds // (0 to 2^(31) - 1, or 0x7FFFFFFF), then a new DNS Resource Record with the given name, // type, class, and RDATA is added. PushTTLAddMax = 0x7FFFFFFF // MaxPushMsgLen is maximum push message length. // // RFC 8765, Section 6.3.1: Servers may generate PUSH messages up to a maximum DNS message // length of 16,382 bytes, counting from the start of the DSO 12-byte header. Including // the two-byte length prefix that is used to frame DNS over a byte stream like TLS, // this makes a total of 16,384 bytes. Servers MUST NOT generate PUSH messages larger than this. MaxPushMsgLen = 16382 // PushDomain is domain name of DSO Push server in given zone. PushDomain = "_dns-push-tls._tcp." )
Variables ¶
var ( // ErrFormat indicates that DSO message content is invalid. ErrFormat = fmt.Errorf("dsomessage: bad message format") // ErrHeader indicates that DSO message header is invalid. ErrHeader = fmt.Errorf("%w - bad header", ErrFormat) // ErrTLV indicates that TLV's content or usage is invalid. ErrTLV = fmt.Errorf("%w - bad TLV", ErrFormat) // ErrBufferFull indicates that there is not enough space in buffer // to accomodate change in message layout. ErrBufferFull = fmt.Errorf("dsomessage.Builder: short buffer") // ErrShortWrite indicates that write required longer buffer than was supplied. ErrShortWrite = fmt.Errorf("dsomessage.Builder: short write") // ErrTooLong indicates that message is too long to set length prefix. ErrTooLong = fmt.Errorf("dsomessage.Builder: msg too long") // ErrDone indicates that all TLVs have been parsed. ErrDone = fmt.Errorf("dsomessage.Parser: done") )
Functions ¶
func CompareNames ¶ added in v0.2.0
CompareNames returns <0 when a is less than b, 0 when they are equal and >0 when a is larger than b.
Follows DNSSEC canonical ordering (RFC 4034, Section 6.1):
- `\DDD` byte is decoded before comparison
- Uppercase A-Z letters are treated as if they were lowercase
- Absence of octet sorts before zero value octet
Quirks:
- Trailing `\` that escapes nothing is ignored
- Leading `\` in `\D` and `\DD` is ignored
- Non-FQDN names are assumed to be root-terminated
func PaddedMsgLen ¶
PaddedMsgLen pads msgLen, if needed, up to multiple of blockLen.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder incrementally builds DSO message.
Errors are sticky. It's expected that callers take care allocating and growing buffers such that under normal program flow TLVs fit without fail. Thus when Builder.Message returns an error it's because user miscalculated buffer size, tried to write malformed data or some other programmer's error fatal to DSO session.
When padding is enabled, operations that change layout or length enforce requirement of having enough available space to pad message.
Example ¶
b := NewBuilder(make([]byte, 128)).
SetHeader(MsgHeader{42, false, dns.RcodeSuccess})
b.WriteKeepAlive(&KeepAlive{InactivityTimeoutDefault, KeepAliveIntervalDefault})
msg, err := b.Message()
if err != nil {
panic(err.Error())
}
fmt.Printf("% x\n", msg)
Output: 00 2a 30 00 00 00 00 00 00 00 00 00 00 01 00 08 00 00 3a 98 00 00 3a 98
func NewBuilder ¶
NewBuilder returns new Builder that takes ownership of buf.
Will panic if buffer's length is less than MsgHeaderLen.
func (*Builder) EnableCompression ¶
EnableCompression enables compression for dns.PackRR and dns.PackDomainName.
func (*Builder) EnableLengthPrefix ¶
EnableLengthPrefix uses first two bytes to encode message length.
ErrBufferFull is set if there is not enough available space for adjustment.
func (*Builder) EnablePadding ¶
EnablePadding aligns message length to multiple of blockLen.
If > 1 writes enforce that either message length is proper multiple or at least TLVHeaderLen bytes are available for EncryptionPadding TLV.
ErrBufferFull is set if there is not enough available space for adjustment.
func (*Builder) Grow ¶
Grow resizes underlying buffer to guarantee space for another n bytes.
If n is negative, Grow will panic.
func (*Builder) Message ¶
Message returns subslice of underlying buffer with bytes written so far, padded if needed.
ErrTooLong is set if length prefix is requested, but message is longer than MaxMsgLen.
func (*Builder) Write ¶
Write implements io.Writer.Write. If underlying buffer is too small for entire input, n is 0 and err is set.
func (*Builder) WriteEncryptionPadding ¶
func (b *Builder) WriteEncryptionPadding(tlv *EncryptionPadding) (int, error)
WriteEncryptionPadding writes EncryptionPadding TLV to underlying buffer.
func (*Builder) WriteKeepAlive ¶
WriteKeepAlive writes KeepAlive TLV to underlying buffer.
func (*Builder) WritePushChange ¶
WritePushChange writes Push TLV to underlying buffer with as many RRs from change as can fit.
Unlike Builder.WritePush it allows to write changes incrementally with non-sticky PackingError being returned on incomplete write with PackingError.Index pointing where to continue.
func (*Builder) WriteReconfirm ¶
WriteReconfirm writes Reconfirm TLV to underlying buffer.
func (*Builder) WriteRetryDelay ¶
func (b *Builder) WriteRetryDelay(tlv *RetryDelay) (int, error)
WriteRetryDelay writes RetryDelay TLV to underlying buffer.
func (*Builder) WriteSubscribe ¶
WriteSubscribe writes Subscribe TLV to underlying buffer.
func (*Builder) WriteTo ¶
WriteTo implements io.WriterTo.WriteTo.
func (*Builder) WriteUnsubscribe ¶
func (b *Builder) WriteUnsubscribe(tlv *Unsubscribe) (int, error)
WriteUnsubscribe writes Unsubscribe TLV to underlying buffer.
type EncryptionPadding ¶
type EncryptionPadding struct {
Padding uint16
}
EncryptionPadding is RFC 8490, Section 7.3 Encryption Padding TLV.
Even the empty TLV adds 4 bytes due to header. See also RFC 8467.
func (*EncryptionPadding) AppendBinary ¶
func (tlv *EncryptionPadding) AppendBinary(b []byte) (b1 []byte, err error)
AppendBinary implements encoding.BinaryAppender.
func (*EncryptionPadding) Clone ¶
func (tlv *EncryptionPadding) Clone() TLV
Clone implements TLV.Clone
func (*EncryptionPadding) Equal ¶
func (tlv *EncryptionPadding) Equal(tlv1 TLV) bool
Equal implements TLV.Equal.
func (*EncryptionPadding) MarshalBinary ¶
func (tlv *EncryptionPadding) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (EncryptionPadding) String ¶
func (tlv EncryptionPadding) String() string
String implements TLV.String.
func (EncryptionPadding) Type ¶
func (tlv EncryptionPadding) Type() Type
Type implements the TLV.Type.
func (*EncryptionPadding) UnmarshalBinary ¶
func (tlv *EncryptionPadding) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*EncryptionPadding) Verify ¶
func (tlv *EncryptionPadding) Verify(usage Usage) error
Verify implements TLV.Verify.
type KeepAlive ¶
type KeepAlive struct {
// This is the timeout at which the client MUST begin closing an inactive DSO Session.
InactivityTimeout uint32
// This is the interval at which a client MUST generate DSO keepalive traffic to maintain
// connection state.
KeepAliveInterval uint32
}
KeepAlive is RFC 8490, Section 7.1 Keepalive TLV.
func (*KeepAlive) AppendBinary ¶
AppendBinary implements encoding.BinaryAppender.
func (*KeepAlive) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*KeepAlive) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type Msg ¶
func (*Msg) MarshalBinary ¶
func (*Msg) UnmarshalBinary ¶
type MsgHeader ¶
MsgHeader represents DSO DNS message header fields.
func (MsgHeader) AppendBinary ¶
AppendBinary implements encoding.BinaryAppender.
func (MsgHeader) IsResponse ¶
IsResponse returns true if the message is a DSO response.
func (MsgHeader) IsUnidirectional ¶
IsUnidirectional returns true if the message is a DSO unidirectional.
func (MsgHeader) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*MsgHeader) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type Origin ¶
type Origin uint16
Origin indicates side message originated from for verification of RFC compliance.
const ( OriginInvalid Origin = 0 // OriginServer is origin of messages created on server. OriginServer Origin = Origin(UsageFromServer) // OriginClient is origin of messages created on client. OriginClient Origin = Origin(UsageFromClient) )
type PackingError ¶
type PackingError struct {
Index int // index of RR that failed to pack; -1 if method packs exactly one RR
Offset int // offset where packing halted
// contains filtered or unexported fields
}
PackingError wraps dns.PackRR error (available via PackingError.Unwrap) with offset and index of RR that failed to pack.
func (*PackingError) Error ¶
func (e *PackingError) Error() string
func (*PackingError) Unwrap ¶
func (e *PackingError) Unwrap() error
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser incrementally parses a DSO message.
- Parser.Start starts parsing and returns message MsgHeader
- Use Parser.TLVHeader to parse TLVHeader and, optionally, Parser.TLVUsage to get Usage context
- Use [Parser.XxxTLV] to fully parse the TLV, or Parser.SkipTLV to skip
- Continue 2-3 until ErrDone, or other error, is returned.
Parser is safe to copy to preserve the parsing state.
Note that there is no requirement to fully skip or parse the message.
Example ¶
var (
msg = []byte("\x00\x2a\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x08\x00\x00\x3a\x98\x00\x00\x3a\x98")
p Parser
header MsgHeader
tlvHeader TLVHeader
usage Usage
tlv TLV
err error
)
header, err = p.Start(msg, OriginClient)
fmt.Printf("%+v\n", header)
for err == nil {
tlvHeader, err = p.TLVHeader()
if err != nil {
break
}
fmt.Printf("%+v\n", tlvHeader)
usage = p.TLVUsage()
fmt.Printf("Usage:%d\n", usage)
tlv, err = p.TLV()
if err != nil {
break
}
fmt.Printf("%v\n", tlv)
err = tlv.Verify(usage)
if err != nil {
break
}
}
if err != nil && !errors.Is(err, ErrDone) {
panic(err.Error())
}
Output: {ID:42 Response:false Rcode:0} {Type:KeepAlive Length:8} Usage:32 timeout 15s, interval 15s
func (*Parser) EncryptionPadding ¶
func (p *Parser) EncryptionPadding() (tlv EncryptionPadding, err error)
EncryptionPadding parses a single EncryptionPadding TLV.
func (*Parser) IsPadded ¶
IsPadded returns true if message contains EncryptionPadding. The result it cached.
func (*Parser) RetryDelay ¶
func (p *Parser) RetryDelay() (tlv RetryDelay, err error)
RetryDelay parses a single RetryDelay TLV.
func (*Parser) SetResponseType ¶
SetResponseType sets primary response type of message to distinguish response primary from response additional usage contexts.
func (*Parser) Unsubscribe ¶
func (p *Parser) Unsubscribe() (tlv Unsubscribe, err error)
Unsubscribe parses a single Unsubscribe TLV.
type Push ¶
type Push struct {
// Changes (at least one) in RRs the receiver is subscribed to.
//
// RR's TTL value may carry special meaning, see RFC 8765, Section 6.3.1 for details.
Change []dns.RR
}
Push is RFC 8765, Section 6.3 Push TLV.
func (*Push) AppendBinary ¶
AppendBinary implements encoding.BinaryAppender by writing uncompressed wire representation.
func (*Push) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler by writing uncompressed wire representation.
func (*Push) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler for uncompressed wire representation.
type Reconfirm ¶
type Reconfirm struct {
// RR that the sender belives to be stale.
//
// RR's type must not be TypeANY (255), class must not be ClassANY (255), wildcarding
// is not supported, case insensitivity applies, CNAME matches only a CNAME record.
// RR's TTL is ignored and Rdlength is re-calculated.
RR dns.RR
}
Reconfirm is RFC 8765, Section 6.5 Reconfirm TLV.
func (*Reconfirm) AppendBinary ¶
AppendBinary implements encoding.BinaryAppender by writing uncompressed wire representation.
func (*Reconfirm) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler by writing uncompressed wire representation.
func (*Reconfirm) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler for uncompressed wire representation.
type RetryDelay ¶
type RetryDelay struct {
// A time value within which the initiator MUST NOT retry this operation or retry connecting
// to this server.
RetryDelay uint32
}
RetryDelay is RFC 8490, Section 7.2 Retry Delay TLV.
func (*RetryDelay) AppendBinary ¶
func (tlv *RetryDelay) AppendBinary(b []byte) (b1 []byte, err error)
AppendBinary implements encoding.BinaryAppender.
func (*RetryDelay) MarshalBinary ¶
func (tlv *RetryDelay) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (*RetryDelay) UnmarshalBinary ¶
func (tlv *RetryDelay) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*RetryDelay) Verify ¶
func (tlv *RetryDelay) Verify(usage Usage) error
Verify implements TLV.Verify.
type Subscribe ¶
type Subscribe struct {
// Domain name of RR that subscriber wants.
//
// DNS wildcarding is not supported, case insensitivity applies, CNAME matches
// only a CNAME record.
Name string
// Type of RR that subscriber wants.
//
// TypeANY (255) is interepreted to mean "ALL".
RRType uint16
// Class of RR that subscriber wants.
//
// ClassANY (255) is interpreted to mean "ALL".
Class uint16
}
Subscribe is RFC 8765, Section 6.2 Subscribe TLV.
func (*Subscribe) AppendBinary ¶
AppendBinary implements encoding.BinaryAppender by writing uncompressed wire representation.
func (*Subscribe) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler by writing uncompressed wire representation.
func (*Subscribe) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler for uncompressed wire representation.
type TLV ¶
type TLV interface {
// Type returns numerical TLV type.
Type() Type
// Len returns upper boundary of uncompressed length. Actual wire length can be lower.
Len() int
// Verify checks that TLV satisfies specification in given usage context.
Verify(usage Usage) error
// Equal returns true if TLVs are equal.
Equal(tlv TLV) bool
// Clone creates deep-copy of TLV.
Clone() TLV
// String converts TLV to readable string.
String() string
encoding.BinaryAppender
encoding.BinaryMarshaler
encoding.BinaryUnmarshaler
// contains filtered or unexported methods
}
TLV is generic DSO TLV.
type TLVHeader ¶
TLVHeader is header of DSO TLV.
func (TLVHeader) AppendBinary ¶
AppendBinary implements encoding.BinaryAppender.
func (TLVHeader) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (*TLVHeader) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
type UnpackingError ¶
type UnpackingError struct {
Offset int // offset where unpacking halted
// contains filtered or unexported fields
}
UnpackingError wraps dns.UnpackRR error (available via UnpackingError.Unwrap) with offset where unpacking halted.
func (*UnpackingError) Error ¶
func (e *UnpackingError) Error() string
func (*UnpackingError) Unwrap ¶
func (e *UnpackingError) Unwrap() error
type Unsubscribe ¶
type Unsubscribe struct {
// ID of the previously sent Subscribe request message.
SubscribeID uint16
}
Unsubscribe is RFC 8765, Section 6.4 Unsubscribe TLV.
func (*Unsubscribe) AppendBinary ¶
func (tlv *Unsubscribe) AppendBinary(b []byte) (b1 []byte, err error)
AppendBinary implements encoding.BinaryAppender.
func (*Unsubscribe) Equal ¶
func (tlv *Unsubscribe) Equal(tlv1 TLV) bool
Equal implements TLV.Equal.
func (*Unsubscribe) MarshalBinary ¶
func (tlv *Unsubscribe) MarshalBinary() ([]byte, error)
MarshalBinary implements encoding.BinaryMarshaler.
func (Unsubscribe) String ¶
func (tlv Unsubscribe) String() (s string)
String implements TLV.String.
func (*Unsubscribe) UnmarshalBinary ¶
func (tlv *Unsubscribe) UnmarshalBinary(data []byte) error
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*Unsubscribe) Verify ¶
func (tlv *Unsubscribe) Verify(usage Usage) error
Verify implements TLV.Verify.
type Usage ¶
type Usage uint16
Usage RFC 8490, Section 8.2 TLV usage contexts matrix.
const ( UsageInvalid Usage = 0 // UsageSP is primary TLV, sent in DSO request message, from server to client. UsageSP Usage = usageP // UsageSU is primary TLV, sent in DSO unidirectional message, from server to client. UsageSU Usage = usageU // UsageSA is additional TLV, optionally added to a DSO request message or DSO unidirectional message // from server to client. UsageSA Usage = usageA // UsageCRP is response primary TLV, included in response message sent back to the client // where the DSO-TYPE of the Response TLV matches the DSO-TYPE of the Primary TLV in the request. UsageCRP Usage = usageRP // UsageCRA is response additional TLV, included in response message sent back to the client where // the DSO-TYPE of the Response TLV does not match the DSO-TYPE of the Primary TLV in the request. UsageCRA Usage = usageRA // UsageCP is primary TLV, sent in DSO request message, from client to server. UsageCP Usage = usageP << usageClientOff // UsageCU is primary TLV, sent in DSO unidirectional message, from client to server. UsageCU Usage = usageU << usageClientOff // UsageCA is additional TLV, optionally added to a DSO request message or DSO unidirectional message // from client to server. UsageCA Usage = usageA << usageClientOff // UsageSRP is response primary TLV, included in response message sent back to the server where the DSO-TYPE // of the Response TLV matches the DSO-TYPE of the Primary TLV in the request. UsageSRP Usage = usageRP << usageClientOff // UsageSRA is response additional TLV, included in response message sent back to the server where the DSO-TYPE // of the Response TLV does not match the DSO-TYPE of the Primary TLV in the request. UsageSRA Usage = usageRA << usageClientOff // UsagePrimary is mask of primary usage contexts. UsagePrimary Usage = UsageCP | UsageCU | UsageCRP | UsageSP | UsageSU | UsageSRP // UsageAdditional is mask of additional usage contexts. UsageAdditional Usage = UsageCA | UsageCRA | UsageSA | UsageSRA // UsageFromServer is mask of usage contexts originated from server. UsageFromServer Usage = UsageSP | UsageSU | UsageSA | UsageCRP | UsageCRA // UsageFromClient is mask of usage contexts originated from client. UsageFromClient Usage = UsageCP | UsageCU | UsageCA | UsageSRP | UsageSRA // UsageKeepAlive is mask of allowed usage contexts of [KeepAlive]. UsageKeepAlive Usage = UsageCP | UsageCRP | UsageSU // UsageRetryDelay is mask of allowed usage contexts of [RetryDelay]. UsageRetryDelay Usage = UsageCRA | UsageSU | UsageSRA // UsageEncryptionPadding is mask of allowed usage contexts of [EncryptionPadding]. UsageEncryptionPadding Usage = UsageCA | UsageCRA | UsageSA | UsageSRA // UsageSubscribe is mask of allowed usage contexts of [Subscribe]. UsageSubscribe Usage = UsageCP // UsagePush is mask of allowed usage contexts of [Push]. UsagePush Usage = UsageSU // UsageUnsubscribe is mask of allowed usage contexts of [Unsubscribe]. UsageUnsubscribe Usage = UsageCU // UsageReconfirm is mask of allowed usage contexts of [Reconfirm]. UsageReconfirm Usage = UsageCU )