core

package module
v0.0.0-...-2459ca3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2026 License: BSD-2-Clause Imports: 21 Imported by: 5

Documentation

Overview

* Copyright (c) 2024 Johan Stenstam, johani@johani.org

* Copyright (c) 2024 Johan Stenstam, johan.stenstam@internetstiftelsen.se

* Copyright (c) 2024 Johan Stenstam, johan.stenstam@internetstiftelsen.se

* Stolen from https://github.com/miekg/dns/blob/master/scan.go

Index

Constants

View Source
const (
	TypeNOTIFY  = 0x0F9A
	TypeMSIGNER = 0x0F9C
	TypeHSYNC   = 0x0F9D
	TypeHSYNC2  = 0x0F9E
	TypeTSYNC   = 0x0F9F
	TypeCHUNK   = 65015 // 0xFDF7 - Unified Chunk/Manifest
	// lots of space
	TypeJSONMANIFEST = 65100 // Older version of CHUNK
	TypeJSONCHUNK    = 65100 // Older version of CHUNK
)
View Source
const (
	SchemeNotify  = 1
	SchemeUpdate  = 2
	SchemeScanner = 3
	SchemeAPI     = 4
	// Private schemes:
	SchemeMSUpdate = 129
	SchemeReport   = 130
)
View Source
const (
	HsyncStateON     uint8 = 1
	HsyncStateOFF    uint8 = 0
	HsyncNSmgmtOWNER uint8 = 1
	HsyncNSmgmtAGENT uint8 = 2
	HsyncSignYES     uint8 = 1
	HsyncSignNO      uint8 = 0
)
View Source
const (
	// Single bit flags
	FlagNSmgmt uint16 = 1 << 0 // bit 0: 0=OWNER, 1=AGENT
	FlagSign   uint16 = 1 << 1 // bit 1: 0=NOSIGN, 1=SIGN
	FlagAudit  uint16 = 1 << 2 // bit 2: 0=NO, 1=YES

	// Multi-bit fields
	ParentSyncMask  uint16 = 0x7 << 3 // bits 3-5: 3 bits for parentsync
	ParentSyncShift uint   = 3        // shift amount for parentsync field
)

Define bit positions and masks in the Flags field

View Source
const (
	ParentSyncOwner uint16 = iota
	ParentSyncNotify
	ParentSyncUpdate
	ParentSyncAPI
)

ParentSync values (using iota for sequential values)

View Source
const (
	Hsync2StateON  uint8 = 1
	Hsync2StateOFF uint8 = 0
)

Keep these constants for State

View Source
const (
	MsignerMethodDNS = 1
	MsignerMethodAPI = 2
	MsignerStateON   = 1
	MsignerStateOFF  = 0
)
View Source
const (
	FormatJSON = 1 // JSON format (original format)

)

Format constants for CHUNK RR type

View Source
const TypeDELEG = 65287
View Source
const TypeDSYNC = 0x0042 // 66 is the official IANA code

Variables

View Source
var FormatToString = map[uint8]string{
	FormatJSON: "JSON",
}

FormatToString maps format constants to their string representations

View Source
var Hsync2StateToString = map[uint8]string{
	Hsync2StateON:  "ON",
	Hsync2StateOFF: "OFF",
}

Keep the State mappings

View Source
var HsyncNSmgmtToString = map[uint8]string{
	HsyncNSmgmtOWNER: "OWNER",
	HsyncNSmgmtAGENT: "AGENT",
}
View Source
var HsyncSignToString = map[uint8]string{
	HsyncSignYES: "SIGN",
	HsyncSignNO:  "NOSIGN",
}
View Source
var HsyncStateToString = map[uint8]string{
	HsyncStateON:  "ON",
	HsyncStateOFF: "OFF",
}
View Source
var MsignerMethodToString = map[MsignerMethod]string{
	MsignerMethodDNS: "DNS",
	MsignerMethodAPI: "API",
}
View Source
var SchemeToString = map[DsyncScheme]string{
	SchemeNotify:  "NOTIFY",
	SchemeUpdate:  "UPDATE",
	SchemeScanner: "SCANNER",
	SchemeAPI:     "API",

	SchemeMSUpdate: "MSUPDATE",
	SchemeReport:   "REPORT",
}
View Source
var StateToString = map[uint8]string{
	MsignerStateON:  "ON",
	MsignerStateOFF: "OFF",
}
View Source
var StringToFormat = map[string]uint8{
	"JSON": FormatJSON,
}

StringToFormat maps string representations to format constants (reverse of FormatToString) NOTE: This map must be kept in sync with FormatToString - when adding a new format to FormatToString, also add the corresponding entry here.

View Source
var StringToHsync2State = map[string]uint8{
	"ON":  Hsync2StateON,
	"OFF": Hsync2StateOFF,
}
View Source
var StringToHsyncNSmgmt = map[string]uint8{
	"OWNER": HsyncNSmgmtOWNER,
	"AGENT": HsyncNSmgmtAGENT,
}
View Source
var StringToHsyncSign = map[string]uint8{
	"SIGN":   HsyncSignYES,
	"NOSIGN": HsyncSignNO,
}
View Source
var StringToHsyncState = map[string]uint8{
	"ON":  HsyncStateON,
	"OFF": HsyncStateOFF,
}
View Source
var StringToMsignerMethod = map[string]MsignerMethod{
	"DNS": MsignerMethodDNS,
	"API": MsignerMethodAPI,
}
View Source
var StringToScheme = map[string]DsyncScheme{
	"NOTIFY":   SchemeNotify,
	"UPDATE":   SchemeUpdate,
	"SCANNER":  SchemeScanner,
	"API":      SchemeAPI,
	"MSUPDATE": SchemeMSUpdate,
	"REPORT":   SchemeReport,
	"REPORTER": SchemeReport,
	"1":        SchemeNotify,
	"2":        SchemeUpdate,
	"3":        SchemeScanner,
	"4":        SchemeAPI,

	"129": SchemeMSUpdate,
	"130": SchemeReport,
}
View Source
var StringToState = map[string]uint8{
	"ON":  MsignerStateON,
	"OFF": MsignerStateOFF,
}
View Source
var TransportToString = map[Transport]string{
	TransportDo53: "do53",
	TransportDoT:  "dot",
	TransportDoH:  "doh",
	TransportDoQ:  "doq",
}

Functions

func NewCHUNK

func NewCHUNK() dns.PrivateRdata

func NewDELEG

func NewDELEG() dns.PrivateRdata

func NewDSYNC

func NewDSYNC() dns.PrivateRdata

func NewHSYNC

func NewHSYNC() dns.PrivateRdata

func NewHSYNC2

func NewHSYNC2() dns.PrivateRdata

func NewJSONCHUNK

func NewJSONCHUNK() dns.PrivateRdata

func NewJSONMANIFEST

func NewJSONMANIFEST() dns.PrivateRdata

func NewMSIGNER

func NewMSIGNER() dns.PrivateRdata

func NewNOTIFY

func NewNOTIFY() dns.PrivateRdata

func NewTSYNC

func NewTSYNC() dns.PrivateRdata

func ParseTransportString

func ParseTransportString(s string) (map[string]uint8, error)

ParseTransportString parses a transport string like "doq:30,dot:20" into a map. - Keys are lower-cased and trimmed - Values must be integers in [0,100] - Duplicate keys are rejected

func RRsetDiffer

func RRsetDiffer(zone string, newrrs, oldrrs []dns.RR, rrtype uint16, lg *log.Logger, verbose, debug bool) (bool, []dns.RR, []dns.RR)

RRsetDiffer compares old and new DNS resource record slices for a given RR type in a zone, ignoring RRSIG records. It returns: a boolean that is true if the RRsets differ, a slice of records present in newrrs but not in oldrrs (adds), and a slice of records present in oldrrs but not in newrrs (removes). RRsetDiffer compares old and new DNS resource records of a specific type in a zone and reports whether the RRsets differ, returning slices of records that were added and removed. It ignores RRSIG records and determines equality using dns.IsDuplicate. When verbose or debug are true, comparison details are written to the provided logger.

func RegisterCHUNKRR

func RegisterCHUNKRR() error

func RegisterDelegRR

func RegisterDelegRR() error

johani

func RegisterDsyncRR

func RegisterDsyncRR() error

func RegisterHsync2RR

func RegisterHsync2RR() error

func RegisterHsyncRR

func RegisterHsyncRR() error

func RegisterJSONCHUNKRR

func RegisterJSONCHUNKRR() error

func RegisterJSONMANIFESTRR

func RegisterJSONMANIFESTRR() error

func RegisterMsignerRR

func RegisterMsignerRR() error

func RegisterNotifyRR

func RegisterNotifyRR() error

func RegisterTsyncRR

func RegisterTsyncRR() error

Types

type CHUNK

type CHUNK struct {
	Format     uint8  // Format identifier (used for manifest, unused for data chunks)
	HMACLen    uint16 // HMAC length (0 for data chunks, >0 for manifest)
	HMAC       []byte // HMAC-SHA256 checksum (only present if HMACLen > 0)
	Sequence   uint16 // Chunk sequence number (unused when Total=0)
	Total      uint16 // Total chunks or 0 for manifest (0 = manifest, >0 = data chunk)
	DataLength uint16 // Length of data
	Data       []byte // Format-specific data (JSON manifest or chunk payload)
}

func (*CHUNK) Copy

func (rd *CHUNK) Copy(dest dns.PrivateRdata) error

func (*CHUNK) Len

func (rd *CHUNK) Len() int

func (*CHUNK) Pack

func (rd *CHUNK) Pack(buf []byte) (int, error)

func (*CHUNK) Parse

func (rd *CHUNK) Parse(txt []string) error

func (CHUNK) String

func (rd CHUNK) String() string

func (*CHUNK) Unpack

func (rd *CHUNK) Unpack(buf []byte) (int, error)

type ConcurrentMap

type ConcurrentMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

A "thread" safe map of type string:Anything. To avoid lock bottlenecks this map is dived to several (shardCount) map shards.

func NewCmap

func NewCmap[V any]() *ConcurrentMap[string, V]

Creates a new concurrent map.

func NewStringer

func NewStringer[K Stringer, V any]() ConcurrentMap[K, V]

Creates a new concurrent map.

func NewWithCustomShardingFunction

func NewWithCustomShardingFunction[K comparable, V any](sharding func(key K) uint32) ConcurrentMap[K, V]

Creates a new concurrent map.

func (*ConcurrentMap[K, V]) Clear

func (m *ConcurrentMap[K, V]) Clear()

Clear removes all items from map.

func (*ConcurrentMap[K, V]) Count

func (m *ConcurrentMap[K, V]) Count() int

Count returns the number of elements within the map.

func (*ConcurrentMap[K, V]) Get

func (m *ConcurrentMap[K, V]) Get(key K) (V, bool)

Get retrieves an element from map under given key.

func (*ConcurrentMap[K, V]) GetShard

func (m *ConcurrentMap[K, V]) GetShard(key K) *ConcurrentMapShared[K, V]

GetShard returns shard under given key

func (*ConcurrentMap[K, V]) Has

func (m *ConcurrentMap[K, V]) Has(key K) bool

Looks up an item under specified key

func (*ConcurrentMap[K, V]) IsEmpty

func (m *ConcurrentMap[K, V]) IsEmpty() bool

IsEmpty checks if map is empty.

func (*ConcurrentMap[K, V]) Items

func (m *ConcurrentMap[K, V]) Items() map[K]V

Items returns all items as map[string]V

func (*ConcurrentMap[K, V]) Iter deprecated

func (m *ConcurrentMap[K, V]) Iter() <-chan Tuple[K, V]

Iter returns an iterator which could be used in a for range loop.

Deprecated: using IterBuffered() will get a better performence

func (*ConcurrentMap[K, V]) IterBuffered

func (m *ConcurrentMap[K, V]) IterBuffered() <-chan Tuple[K, V]

IterBuffered returns a buffered iterator which could be used in a for range loop.

func (*ConcurrentMap[K, V]) IterCb

func (m *ConcurrentMap[K, V]) IterCb(fn IterCb[K, V])

Callback based iterator, cheapest way to read all elements in a map.

func (*ConcurrentMap[K, V]) Keys

func (m *ConcurrentMap[K, V]) Keys() []K

Keys returns all keys as []string

func (*ConcurrentMap[K, V]) MSet

func (m *ConcurrentMap[K, V]) MSet(data map[K]V)

func (*ConcurrentMap[K, V]) MarshalJSON

func (m *ConcurrentMap[K, V]) MarshalJSON() ([]byte, error)

Reviles ConcurrentMap "private" variables to json marshal.

func (*ConcurrentMap[K, V]) NumShards

func (m *ConcurrentMap[K, V]) NumShards() int

func (*ConcurrentMap[K, V]) Pop

func (m *ConcurrentMap[K, V]) Pop(key K) (v V, exists bool)

Pop removes an element from the map and returns it

func (*ConcurrentMap[K, V]) Remove

func (m *ConcurrentMap[K, V]) Remove(key K)

Remove removes an element from the map.

func (*ConcurrentMap[K, V]) RemoveCb

func (m *ConcurrentMap[K, V]) RemoveCb(key K, cb RemoveCb[K, V]) bool

RemoveCb locks the shard containing the key, retrieves its current value and calls the callback with those params If callback returns true and element exists, it will remove it from the map Returns the value returned by the callback (even if element was not present in the map)

func (*ConcurrentMap[K, V]) Set

func (m *ConcurrentMap[K, V]) Set(key K, value V)

Sets the given value under the specified key.

func (*ConcurrentMap[K, V]) SetIfAbsent

func (m *ConcurrentMap[K, V]) SetIfAbsent(key K, value V) bool

Sets the given value under the specified key if no value was associated with it.

func (*ConcurrentMap[K, V]) UnmarshalJSON

func (m *ConcurrentMap[K, V]) UnmarshalJSON(b []byte) (err error)

Reverse process of Marshal.

func (*ConcurrentMap[K, V]) Upsert

func (m *ConcurrentMap[K, V]) Upsert(key K, value V, cb UpsertCb[V]) (res V)

Insert or Update - updates existing element or inserts a new one using UpsertCb

type ConcurrentMapShared

type ConcurrentMapShared[K comparable, V any] struct {
	sync.RWMutex // Read Write mutex, guards access to internal map.
	// contains filtered or unexported fields
}

A "thread" safe string to anything map.

type DELEG

type DELEG struct {
	// Hdr      dns.RR_Header
	Priority uint16          // If zero, Value must be empty or discarded by the user of this library
	Target   string          `dns:"domain-name"`
	Value    []DELEGKeyValue `dns:"pairs"`
}

func (*DELEG) Copy

func (rr *DELEG) Copy(dest dns.PrivateRdata) error

func (*DELEG) Len

func (rr *DELEG) Len() int

johani

func (*DELEG) Pack

func (rr *DELEG) Pack(buf []byte) (int, error)

johani

func (*DELEG) Parse

func (rr *DELEG) Parse(s []string) error

johani

func (*DELEG) String

func (rr *DELEG) String() string

func (*DELEG) Unpack

func (rr *DELEG) Unpack(buf []byte) (int, error)

type DELEGAlpn

type DELEGAlpn struct {
	Alpn []string
}

SVCBAlpn pair is used to list supported connection protocols. The user of this library must ensure that at least one protocol is listed when alpn is present. Protocol IDs can be found at: https://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids Basic use pattern for creating an alpn option:

h := new(dns.HTTPS)
h.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeHTTPS, Class: dns.ClassINET}
e := new(dns.SVCBAlpn)
e.Alpn = []string{"h2", "http/1.1"}
h.Value = append(h.Value, e)

func (*DELEGAlpn) Key

func (*DELEGAlpn) Key() DELEGKey

func (*DELEGAlpn) String

func (s *DELEGAlpn) String() string

type DELEGIPv4Hint

type DELEGIPv4Hint struct {
	Hint []net.IP
}

SVCBIPv4Hint pair suggests an IPv4 address which may be used to open connections if A and AAAA record responses for SVCB's Target domain haven't been received. In that case, optionally, A and AAAA requests can be made, after which the connection to the hinted IP address may be terminated and a new connection may be opened. Basic use pattern for creating an ipv4hint option:

	h := new(dns.HTTPS)
	h.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeHTTPS, Class: dns.ClassINET}
	e := new(dns.SVCBIPv4Hint)
	e.Hint = []net.IP{net.IPv4(1,1,1,1).To4()}

 Or

	e.Hint = []net.IP{net.ParseIP("1.1.1.1").To4()}
	h.Value = append(h.Value, e)

func (*DELEGIPv4Hint) Key

func (*DELEGIPv4Hint) Key() DELEGKey

func (*DELEGIPv4Hint) String

func (s *DELEGIPv4Hint) String() string

type DELEGIPv6Hint

type DELEGIPv6Hint struct {
	Hint []net.IP
}

SVCBIPv6Hint pair suggests an IPv6 address which may be used to open connections if A and AAAA record responses for SVCB's Target domain haven't been received. In that case, optionally, A and AAAA requests can be made, after which the connection to the hinted IP address may be terminated and a new connection may be opened. Basic use pattern for creating an ipv6hint option:

h := new(dns.HTTPS)
h.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeHTTPS, Class: dns.ClassINET}
e := new(dns.SVCBIPv6Hint)
e.Hint = []net.IP{net.ParseIP("2001:db8::1")}
h.Value = append(h.Value, e)

func (*DELEGIPv6Hint) Key

func (*DELEGIPv6Hint) Key() DELEGKey

func (*DELEGIPv6Hint) String

func (s *DELEGIPv6Hint) String() string

type DELEGKey

type DELEGKey uint16

SVCBKey is the type of the keys used in the SVCB RR.

const (
	DELEG_MANDATORY DELEGKey = iota
	DELEG_ALPN
	DELEG_NO_DEFAULT_ALPN
	DELEG_PORT
	DELEG_IPV4HINT
	DELEG_ECHCONFIG
	DELEG_IPV6HINT
	DELEG_DOHPATH // rfc9461 Section 5
	DELEG_OHTTP   // rfc9540 Section 8

)

Keys defined in rfc9460

func (DELEGKey) String

func (key DELEGKey) String() string

type DELEGKeyValue

type DELEGKeyValue interface {
	Key() DELEGKey // Key returns the numerical key code.

	String() string // String returns the string representation of the value.
	// contains filtered or unexported methods
}

DELEGKeyValue defines a key=value pair for the DELEG RR type. A DELEG RR can have multiple DELEGKeyValues appended to it.

type DELEGLocal

type DELEGLocal struct {
	KeyCode DELEGKey // Never 65535 or any assigned keys.
	Data    []byte   // All byte sequences are allowed.
}

SVCBLocal pair is intended for experimental/private use. The key is recommended to be in the range [SVCB_PRIVATE_LOWER, SVCB_PRIVATE_UPPER]. Basic use pattern for creating a keyNNNNN option:

h := new(dns.HTTPS)
h.Hdr = dns.RR_Header{Name: ".", Rrtype: dns.TypeHTTPS, Class: dns.ClassINET}
e := new(dns.SVCBLocal)
e.KeyCode = 65400
e.Data = []byte("abc")
h.Value = append(h.Value, e)

func (*DELEGLocal) Key

func (s *DELEGLocal) Key() DELEGKey

func (*DELEGLocal) String

func (s *DELEGLocal) String() string

type DELEGMandatory

type DELEGMandatory struct {
	Code []DELEGKey
}

SVCBMandatory pair adds to required keys that must be interpreted for the RR to be functional. If ignored, the whole RRSet must be ignored. "port" and "no-default-alpn" are mandatory by default if present, so they shouldn't be included here.

It is incumbent upon the user of this library to reject the RRSet if or avoid constructing such an RRSet that: - "mandatory" is included as one of the keys of mandatory - no key is listed multiple times in mandatory - all keys listed in mandatory are present - escape sequences are not used in mandatory - mandatory, when present, lists at least one key

Basic use pattern for creating a mandatory option:

s := &dns.SVCB{Hdr: dns.RR_Header{Name: ".", Rrtype: dns.TypeSVCB, Class: dns.ClassINET}}
e := new(dns.SVCBMandatory)
e.Code = []uint16{dns.SVCB_ALPN}
s.Value = append(s.Value, e)
t := new(dns.SVCBAlpn)
t.Alpn = []string{"xmpp-client"}
s.Value = append(s.Value, t)

func (*DELEGMandatory) Key

func (*DELEGMandatory) Key() DELEGKey

func (*DELEGMandatory) String

func (s *DELEGMandatory) String() string

type DELEGNoDefaultAlpn

type DELEGNoDefaultAlpn struct{}

SVCBNoDefaultAlpn pair signifies no support for default connection protocols. Should be used in conjunction with alpn. Basic use pattern for creating a no-default-alpn option:

s := &dns.SVCB{Hdr: dns.RR_Header{Name: ".", Rrtype: dns.TypeSVCB, Class: dns.ClassINET}}
t := new(dns.SVCBAlpn)
t.Alpn = []string{"xmpp-client"}
s.Value = append(s.Value, t)
e := new(dns.SVCBNoDefaultAlpn)
s.Value = append(s.Value, e)

func (*DELEGNoDefaultAlpn) Key

func (*DELEGNoDefaultAlpn) String

func (*DELEGNoDefaultAlpn) String() string

type DELEGPort

type DELEGPort struct {
	Port uint16
}

SVCBPort pair defines the port for connection. Basic use pattern for creating a port option:

s := &dns.SVCB{Hdr: dns.RR_Header{Name: ".", Rrtype: dns.TypeSVCB, Class: dns.ClassINET}}
e := new(dns.SVCBPort)
e.Port = 80
s.Value = append(s.Value, e)

func (*DELEGPort) Key

func (*DELEGPort) Key() DELEGKey

func (*DELEGPort) String

func (s *DELEGPort) String() string

type DNSClient

type DNSClient struct {
	Port            string
	Transport       Transport
	TLSConfig       *tls.Config
	HTTPClient      *http.Client
	QUICConfig      *quic.Config
	Timeout         time.Duration
	DNSClientUDP    *dns.Client
	DNSClientTCP    *dns.Client
	DNSClientTLS    *dns.Client
	DisableFallback bool
	ForceTCP        bool
}

DNSClient represents a DNS client that supports multiple transport protocols

func NewDNSClient

func NewDNSClient(transport Transport, port string, tlsConfig *tls.Config, opts ...DNSClientOption) *DNSClient

NewDNSClient creates a new DNS client with the specified transport XXX: Once we can do cert validation we should add a WithVerifyCertificates() option.

func (*DNSClient) Exchange

func (c *DNSClient) Exchange(msg *dns.Msg, server string, debug bool) (*dns.Msg, time.Duration, error)

Exchange sends a DNS message and returns the response

type DNSClientOption

type DNSClientOption func(*DNSClient)

func WithDisableFallback

func WithDisableFallback() DNSClientOption

func WithForceTCP

func WithForceTCP() DNSClientOption

type DSYNC

type DSYNC struct {
	Type   uint16
	Scheme DsyncScheme
	Port   uint16
	Target string
}

func (*DSYNC) Copy

func (rd *DSYNC) Copy(dest dns.PrivateRdata) error

func (*DSYNC) Len

func (rd *DSYNC) Len() int

func (*DSYNC) Pack

func (rd *DSYNC) Pack(buf []byte) (int, error)

func (*DSYNC) Parse

func (rd *DSYNC) Parse(txt []string) error

func (DSYNC) String

func (rd DSYNC) String() string

func (*DSYNC) Unpack

func (rd *DSYNC) Unpack(buf []byte) (int, error)

type DsyncScheme

type DsyncScheme uint8

type HSYNC

type HSYNC struct {
	State    uint8 // 0=OFF, 1=ON
	NSmgmt   uint8 // 1=OWNER, 2=AGENT
	Sign     uint8 // 1=SIGN, 2=NOSIGN
	Identity string
	Upstream string
}

func (*HSYNC) Copy

func (rd *HSYNC) Copy(dest dns.PrivateRdata) error

func (*HSYNC) Len

func (rd *HSYNC) Len() int

func (*HSYNC) Pack

func (rd *HSYNC) Pack(buf []byte) (int, error)

func (*HSYNC) Parse

func (rd *HSYNC) Parse(txt []string) error

func (HSYNC) String

func (rd HSYNC) String() string

func (*HSYNC) Unpack

func (rd *HSYNC) Unpack(buf []byte) (int, error)

type HSYNC2

type HSYNC2 struct {
	State    uint8  // 0=OFF, 1=ON
	Flags    uint16 // Will hold both NSmgmt and Sign bits
	Identity string
	Upstream string
}

func (*HSYNC2) Copy

func (rd *HSYNC2) Copy(dest dns.PrivateRdata) error

func (*HSYNC2) DoAudit

func (rd *HSYNC2) DoAudit() bool

func (*HSYNC2) DoSign

func (rd *HSYNC2) DoSign() bool

func (*HSYNC2) GetParentSync

func (rd *HSYNC2) GetParentSync() uint16

func (*HSYNC2) IsAgent

func (rd *HSYNC2) IsAgent() bool

func (*HSYNC2) Len

func (rd *HSYNC2) Len() int

func (*HSYNC2) Pack

func (rd *HSYNC2) Pack(buf []byte) (int, error)

func (*HSYNC2) Parse

func (rd *HSYNC2) Parse(txt []string) error

func (*HSYNC2) SetAudit

func (rd *HSYNC2) SetAudit(enabled bool)

Add helper functions for the new flags

func (*HSYNC2) SetNSmgmt

func (rd *HSYNC2) SetNSmgmt(isAgent bool)

Helper functions for flag handling

func (*HSYNC2) SetParentSync

func (rd *HSYNC2) SetParentSync(value uint16) error

func (*HSYNC2) SetSign

func (rd *HSYNC2) SetSign(doSign bool)

func (HSYNC2) String

func (rd HSYNC2) String() string

func (*HSYNC2) Unpack

func (rd *HSYNC2) Unpack(buf []byte) (int, error)

type IterCb

type IterCb[K comparable, V any] func(key K, v V)

Iterator callback called for every key,value found in maps. RLock is held for all calls for a given shard therefore callback sees a consistent view of a shard, but not across the shards

type JSONCHUNK

type JSONCHUNK struct {
	Sequence uint16 `json:"sequence"` // Chunk sequence number (0-based)
	Total    uint16 `json:"total"`    // Total number of chunks
	Data     []byte `json:"data"`     // Base64-encoded JSON data (raw bytes, not base64 string)
}

JSONCHUNK - Chunked JSON Data Transport Transports large JSON-structured data (zone lists or encrypted blobs) in chunks Format: Base64-encoded JSON data with sequence/total metadata

func (*JSONCHUNK) Copy

func (rd *JSONCHUNK) Copy(dest dns.PrivateRdata) error

func (*JSONCHUNK) Len

func (rd *JSONCHUNK) Len() int

func (*JSONCHUNK) Pack

func (rd *JSONCHUNK) Pack(buf []byte) (int, error)

func (*JSONCHUNK) Parse

func (rd *JSONCHUNK) Parse(txt []string) error

func (JSONCHUNK) String

func (rd JSONCHUNK) String() string

func (*JSONCHUNK) Unpack

func (rd *JSONCHUNK) Unpack(buf []byte) (int, error)

type JSONMANIFEST

type JSONMANIFEST struct {
	ChunkCount uint16                 `json:"chunk_count"`          // Number of JSONCHUNK records (0 if payload is inline)
	ChunkSize  uint16                 `json:"chunk_size,omitempty"` // Maximum size of each chunk in bytes (optional)
	Checksum   string                 `json:"checksum,omitempty"`   // SHA-256 checksum (optional)
	Metadata   map[string]interface{} `json:"metadata,omitempty"`   // Additional metadata (must include "content")
	Payload    []byte                 `json:"payload,omitempty"`    // Inline payload (base64-encoded in JSON, optional)
}

JSONMANIFEST - JSON Distribution Manifest Small metadata about a distribution event for a specific node Format: JSON structure with chunk_count, checksum, metadata Size limit: <500 bytes (never chunked) The Metadata map should contain a "content" field indicating the type:

  • "zonelist": List of zone names (JSON array of strings)
  • "encrypted_keys": HPKE-encrypted key material
  • "clear_text": Clear text payload (base64 encoded)
  • "encrypted_text": HPKE-encrypted text payload (base64 encoded)

When payload fits inline (typically < 1000 bytes), it can be included directly in the Payload field, eliminating the need for separate JSONCHUNK queries. In this case, ChunkCount should be 0 (or Payload is used instead of chunks).

func (*JSONMANIFEST) Copy

func (rd *JSONMANIFEST) Copy(dest dns.PrivateRdata) error

func (*JSONMANIFEST) Len

func (rd *JSONMANIFEST) Len() int

func (*JSONMANIFEST) Pack

func (rd *JSONMANIFEST) Pack(buf []byte) (int, error)

func (*JSONMANIFEST) Parse

func (rd *JSONMANIFEST) Parse(txt []string) error

func (JSONMANIFEST) String

func (rd JSONMANIFEST) String() string

func (*JSONMANIFEST) Unpack

func (rd *JSONMANIFEST) Unpack(buf []byte) (int, error)

type MSIGNER

type MSIGNER struct {
	State  uint8         // 0=OFF, 1=ON
	Method MsignerMethod // 1=DNS, 2=API
	//	Port   uint16
	Target string
}

func (*MSIGNER) Copy

func (rd *MSIGNER) Copy(dest dns.PrivateRdata) error

func (*MSIGNER) Len

func (rd *MSIGNER) Len() int

func (*MSIGNER) Pack

func (rd *MSIGNER) Pack(buf []byte) (int, error)

func (*MSIGNER) Parse

func (rd *MSIGNER) Parse(txt []string) error

func (MSIGNER) String

func (rd MSIGNER) String() string

func (*MSIGNER) Unpack

func (rd *MSIGNER) Unpack(buf []byte) (int, error)

type MsignerMethod

type MsignerMethod uint8

type NOTIFY

type NOTIFY struct {
	Type   uint16
	Scheme uint8
	Port   uint16
	Target string
}

func (*NOTIFY) Copy

func (rd *NOTIFY) Copy(dest dns.PrivateRdata) error

func (*NOTIFY) Len

func (rd *NOTIFY) Len() int

func (*NOTIFY) Pack

func (rd *NOTIFY) Pack(buf []byte) (int, error)

func (*NOTIFY) Parse

func (rd *NOTIFY) Parse(txt []string) error

func (NOTIFY) String

func (rd NOTIFY) String() string

func (*NOTIFY) Unpack

func (rd *NOTIFY) Unpack(buf []byte) (int, error)

type ParseError

type ParseError struct {
	// contains filtered or unexported fields
}

ParseError is a parsing error. It contains the parse error and the location in the io.Reader where the error occurred.

func (*ParseError) Error

func (e *ParseError) Error() (s string)

type RRset

type RRset struct {
	Name   string
	Class  uint16
	RRtype uint16
	RRs    []dns.RR
	RRSIGs []dns.RR
}

func (*RRset) Add

func (rrset *RRset) Add(rr dns.RR)

Add adds a RR to the RRset if it is not already present.

func (*RRset) Clone

func (rrset *RRset) Clone() *RRset

func (*RRset) Delete

func (rrset *RRset) Delete(rr dns.RR)

Delete deletes a RR from the RRset if it is present.

func (*RRset) RRSIGsDiffer

func (rrset *RRset) RRSIGsDiffer(newrrset *RRset) bool

RRSIGsDiffer compares two slices of RRSIGs and returns true if they differ. Two RRSIG slices are considered equal if they contain the same RRSIGs (using dns.IsDuplicate for comparison), regardless of order. Returns true if the RRSIGs differ, false if they are the same.

func (*RRset) RRsetDiffer

func (rrset *RRset) RRsetDiffer(newrrset *RRset, lg *log.Logger, verbose, debug bool) (bool, []dns.RR, []dns.RR)

func (*RRset) RemoveRR

func (rrset *RRset) RemoveRR(rr dns.RR, verbose, debug bool)

func (*RRset) String

func (rrset *RRset) String(maxlen int) (out string)

type RRsetString

type RRsetString struct {
	Name   string   `json:"name"`
	RRtype uint16   `json:"rrtype"`
	RRs    []string `json:"rrs"`
	RRSIGs []string `json:"rrsigs,omitempty"`
}

String-based versions of RRset for JSON marshaling

type RemoveCb

type RemoveCb[K any, V any] func(key K, v V, exists bool) bool

RemoveCb is a callback executed in a map.RemoveCb() call, while Lock is held If returns true, the element will be removed from the map

type Stringer

type Stringer interface {
	fmt.Stringer
	comparable
}

type TSYNC

type TSYNC struct {
	Type       uint16
	Alias      string
	Transports string
	V4addr     string
	V6addr     string
}

TSYNC is a private/custom RRtype similar in style to DSYNC. RDATA fields (wire format order): - Type: uint16 (the RRtype variant within TSYNC namespace; typically dns.TypeTSYNC) - Alias: domain name (mandatory; must be a valid FQDN, cannot be empty) - Transports: string (optional; e.g., "doq=30,dot=20", can be empty) - V4addr: string (optional; comma-separated list of IPv4 addresses, can be empty) - V6addr: string (optional; comma-separated list of IPv6 addresses, can be empty)

func (*TSYNC) Copy

func (rd *TSYNC) Copy(dest dns.PrivateRdata) error

func (*TSYNC) Len

func (rd *TSYNC) Len() int

func (*TSYNC) Pack

func (rd *TSYNC) Pack(buf []byte) (int, error)

func (*TSYNC) Parse

func (rd *TSYNC) Parse(txt []string) error

func (TSYNC) String

func (rd TSYNC) String() string

func (*TSYNC) Unpack

func (rd *TSYNC) Unpack(buf []byte) (int, error)

type Transport

type Transport uint8

Transport represents the DNS transport protocol

const (
	TransportDo53 Transport = iota + 1
	TransportDoT
	TransportDoH
	TransportDoQ
)

func StringToTransport

func StringToTransport(s string) (Transport, error)

StringToTransport converts a string transport name to Transport type

type Tuple

type Tuple[K comparable, V any] struct {
	Key K
	Val V
}

Used by the Iter & IterBuffered functions to wrap two variables together over a channel,

type UpsertCb

type UpsertCb[V any] func(exist bool, valueInMap V, newValue V) V

Callback to return new element to be inserted into the map It is called while lock is held, therefore it MUST NOT try to access other keys in same map, as it can lead to deadlock since Go sync.RWLock is not reentrant

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL