Documentation
¶
Index ¶
- type ACLConfig
- type ACLZoneConfig
- type BlocklistConfig
- type BlocklistEntry
- type CacheConfig
- type CatalogZoneConfig
- type ClusterActionConfig
- type ClusterConfig
- type ClusterPeerConfig
- type ClusterSyncConfig
- type Config
- type DaemonConfig
- type ForwardZoneConfig
- type LocalZoneConfig
- type LoggingConfig
- type RRLConfig
- type RateLimitConfig
- type ResolverConfig
- type SecondaryZoneConfig
- type SecurityConfig
- type ServerConfig
- type StubZoneConfig
- type WebAuthConfig
- type WebConfig
- type WebDashboardConfig
- type ZabbixConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ACLConfig ¶
type ACLConfig struct {
Allow []string
Deny []string
Zones []ACLZoneConfig
}
ACLConfig holds access control list settings.
type ACLZoneConfig ¶
ACLZoneConfig holds per-zone ACL settings.
type BlocklistConfig ¶
type BlocklistConfig struct {
Enabled bool
Lists []BlocklistEntry
RefreshInterval time.Duration
BlockingMode string
CustomIP string
Whitelist []string
}
BlocklistConfig holds blocklist filtering settings.
type BlocklistEntry ¶
BlocklistEntry holds a single blocklist source URL and its format.
type CacheConfig ¶
type CacheConfig struct {
MaxEntries int
MinTTL uint32
MaxTTL uint32
NegMaxTTL uint32
SweepInterval time.Duration
ServeStale bool
StaleTTL uint32
// StaleMaxAge bounds how far past expiry a stale entry may be served
// (RFC 8767 §3.3: "It is RECOMMENDED that responses no longer than
// 1-3 days old be considered for stale serve"). An entry whose live
// expiry is older than this threshold is rejected even when the
// physical record is still in cache. Default is 86400 seconds (1 day).
// Setting 0 keeps the prior unbounded behaviour for operators who
// prefer it, but the strong recommendation is to keep a finite cap so
// long-tail zones cannot pin obsolete data indefinitely.
StaleMaxAge uint32
NoCacheClients []string
Prefetch bool
}
CacheConfig holds cache settings.
type CatalogZoneConfig ¶ added in v0.8.33
type CatalogZoneConfig SecondaryZoneConfig
CatalogZoneConfig holds a catalog zone (RFC 9432) whose member zones are provisioned automatically as secondaries.
The transfer parameters here apply to the catalog itself AND are inherited by every member it lists. RFC 9432 §5.1 leaves the entry-to-configuration mapping implementation-defined, and inheritance is the mapping that needs no second configuration surface: the catalog says which zones, this block says how to fetch them.
func (CatalogZoneConfig) Validate ¶ added in v0.8.33
func (z CatalogZoneConfig) Validate() error
Validate applies the same checks as a secondary zone.
type ClusterActionConfig ¶
ClusterActionConfig controls cluster fanout behavior for admin actions.
type ClusterConfig ¶
type ClusterConfig struct {
Enabled bool
Role string
NodeID string
Peers []ClusterPeerConfig
Actions ClusterActionConfig
Sync ClusterSyncConfig
}
ClusterConfig holds optional multi-node cluster settings.
type ClusterPeerConfig ¶
type ClusterPeerConfig struct {
Name string
Enabled bool
APIBase string
APIToken string
SyncFields []string
}
ClusterPeerConfig defines a peer node accessible via admin API.
type ClusterSyncConfig ¶
ClusterSyncConfig controls configuration synchronization behavior.
type Config ¶
type Config struct {
Server ServerConfig
Resolver ResolverConfig
Cache CacheConfig
Security SecurityConfig
Logging LoggingConfig
ACL ACLConfig
Web WebConfig
Daemon DaemonConfig
Zabbix ZabbixConfig
Blocklist BlocklistConfig
Cluster ClusterConfig
LocalZones []LocalZoneConfig
ForwardZones []ForwardZoneConfig
StubZones []StubZoneConfig
SecondaryZones []SecondaryZoneConfig
CatalogZones []CatalogZoneConfig
}
Config holds the complete application configuration.
type DaemonConfig ¶
DaemonConfig holds daemon mode settings.
type ForwardZoneConfig ¶
type ForwardZoneConfig struct {
Name string
Addrs []string
// TLS enables DNS-over-TLS to this zone's upstreams (RFC 7858). The
// addresses are then contacted on port 853 unless they carry an
// explicit port.
TLS bool
// TLSAuthName is the RFC 8310 §6.1 authentication domain name — the
// name the upstream's certificate must be valid for, e.g.
// "cloudflare-dns.com" or "dns.quad9.net".
TLSAuthName string
// TLSPins holds RFC 8310 §8.1 SPKI pins: base64-encoded SHA-256
// digests of the upstream's SubjectPublicKeyInfo. Useful for an
// upstream with no publicly-valid certificate, and as belt-and-braces
// alongside an auth name.
TLSPins []string
}
ForwardZoneConfig holds a single forward zone: queries matching the zone name are forwarded (RD=1) to the configured upstream addresses.
func (ForwardZoneConfig) Validate ¶ added in v0.8.33
func (z ForwardZoneConfig) Validate() error
Validate checks that a TLS-enabled forward zone can actually authenticate its upstream.
RFC 8310 defines an Opportunistic profile that encrypts without authenticating, and Labyrinth deliberately does not offer it. A forward zone is a trust statement — the resolver honours the upstream's AD bit for that zone on the operator's say-so — and an unauthenticated TLS session lets any on-path attacker occupy that position while the config and the dashboard both report the zone as encrypted. Failing the config load is noisy; silently shipping a security claim we cannot back is worse.
type LocalZoneConfig ¶
type LocalZoneConfig struct {
Name string
Type string
Data []string
ZoneFile string // path to a BIND master-file; empty when unused
}
LocalZoneConfig holds a local zone's definition from the config file.
A local zone is served from the local zone table rather than resolved iteratively. The records may come from one of two places, in this order of preference:
- ZoneFile: a path to a BIND master-file (RFC 1035 §5). The file is parsed by dns.ParseZone at startup, and the records are added to the local zone table as if they had been typed inline. This is the round-trip partner of the export endpoint: an operator can write a zone file, point Labyrinth at it, and rely on the parser's strict (round-trip-only) grammar to surface mistakes.
- Data: a list of "name TYPE rdata" lines, parsed by resolver.ParseLocalRecord. Used when the zone is small enough that an inline list is more readable than a separate file.
If both are set, ZoneFile wins and Data is ignored. An empty ZoneFile is treated as "no file"; the loader does not error on an unconfigured field.
type LoggingConfig ¶
type LoggingConfig struct {
Level string
Format string
FallbackLog string
// FallbackDebug enables JSONL writes to FallbackLog for each
// public-resolver fallback engagement (reason + recovered).
FallbackDebug bool
}
LoggingConfig holds logging settings.
type RRLConfig ¶
type RRLConfig struct {
Enabled bool
ResponsesPerSecond float64
SlipRatio int
IPv4Prefix int
IPv6Prefix int
}
RRLConfig holds response rate limiting settings.
type RateLimitConfig ¶
RateLimitConfig holds rate limiter settings.
type ResolverConfig ¶
type ResolverConfig struct {
MaxDepth int
MaxCNAMEDepth int
UpstreamTimeout time.Duration
UpstreamRetries int
// MaxQueriesPerRequest caps the total number of outbound queries the
// resolver issues while resolving a single client request — across every
// CNAME hop, QNAME-minimisation step, and nameserver-address sub-
// resolution. It is the global backstop against NXNS-style delegation
// amplification (the CVE-2020-8616 family) and runaway referral trees,
// which MaxDepth (a per-iteration *depth* limit) does not bound. 0 or
// negative is floored to the default by clampConfigBounds.
MaxQueriesPerRequest int
// RequestTimeout is the wall-clock deadline for resolving a single client
// request. It bounds pathological delegation/CNAME trees that stay under
// the query budget but where each hop is slow. 0 or negative is floored
// to the default by clampConfigBounds.
RequestTimeout time.Duration
QMinEnabled bool
Caps0x20Enabled bool
PreferIPv4 bool
DNSSECEnabled bool
DNSSECAllowSHA1 bool
// DNSSECNegativeTrustAnchors is the operator-installed NTA list
// (RFC 7646). Each entry is "<zone>|<RFC3339 expiry>|<reason>" — the
// pipe separator keeps the format trivially parseable from a YAML
// list of strings without inventing a nested schema. Empty list
// disables NTA enforcement.
DNSSECNegativeTrustAnchors []string
HardenBelowNXDomain bool
RootHintsRefresh time.Duration
ECSEnabled bool
ECSMaxPrefix int // IPv4 source-prefix ceiling (RFC 7871 §11.1 recommends /24)
ECSMaxPrefixV6 int // IPv6 source-prefix ceiling (RFC 7871 §11.1 recommends /56)
DNS64Enabled bool
DNS64Prefix string
FallbackResolvers []string
UpstreamUDPBufferSize int
// MaxNSNamesPerDelegation caps how many NS hostnames the resolver will
// accept from a single delegation response. A legitimate delegation
// carries 2–13 NS names (RFC 1034 recommends at least 2); an attacker
// can publish dozens or hundreds to amplify resolution work (NXNS
// class, CVE-2020-8616). Default 13 matches BIND's effective cap;
// 0 or negative means unlimited.
MaxNSNamesPerDelegation int
// ErrorReporting enables RFC 9567 outbound DNS error reporting. When a
// zone advertises a Report-Channel agent domain and this resolver
// rejects one of its answers, a throwaway TXT query naming the failure
// is sent to that agent domain so the zone operator learns about the
// breakage from the resolver that saw it.
//
// Default false. The mechanism is genuinely useful to zone operators,
// but it tells a third party that this resolver looked up a particular
// name and got a particular error (RFC 9567 §8), so enabling it is the
// operator's call rather than a default.
ErrorReporting bool
}
ResolverConfig holds resolver settings.
type SecondaryZoneConfig ¶ added in v0.8.33
type SecondaryZoneConfig struct {
Name string
Primary string
TLS bool
TLSAuthName string
// TSIGKeyName and TSIGSecret authenticate the transfer. The secret is
// base64 in the config file, matching how every other DNS
// implementation writes TSIG keys, and is decoded at load time.
TSIGKeyName string
TSIGSecret string
TSIGAlgorithm string
}
SecondaryZoneConfig holds a zone transferred from a primary and served locally (RFC 5936 AXFR / RFC 1995 IXFR, optionally over TLS per RFC 9103 and authenticated with TSIG per RFC 8945).
This does not make Labyrinth authoritative for the zone on the public internet — it serves the transferred copy from the local zone table, so queries inside the zone are answered here instead of resolved iteratively.
func (SecondaryZoneConfig) Validate ¶ added in v0.8.33
func (z SecondaryZoneConfig) Validate() error
Validate rejects a secondary zone that cannot work as configured.
type SecurityConfig ¶
type SecurityConfig struct {
RateLimit RateLimitConfig
RRL RRLConfig
PrivateAddressFilter bool
DNSCookies bool
// DNSCookiesEnforce — RFC 7873 §5.4 strict mode. When true, a UDP
// query without a client cookie is rejected with BADCOOKIE. Default
// false; opt-in for hostile-network deployments. Has no effect
// unless DNSCookies is also true.
DNSCookiesEnforce bool
}
SecurityConfig holds security settings.
type ServerConfig ¶
type ServerConfig struct {
ListenAddr string
MetricsAddr string
MaxUDPSize int
TCPTimeout time.Duration
MaxTCPConns int
MaxUDPWorkers int
GracefulPeriod time.Duration
TCPPipelineMax int
TCPIdleTimeout time.Duration
DoTEnabled bool
DoTListenAddr string
DoQEnabled bool
DoQListenAddr string
TLSCertFile string
TLSKeyFile string
// MaxTCPConnsPerClient caps concurrent TCP connections from a single
// source IP. Default 16 prevents slow-loris style single-source
// exhaustion of the global MaxTCPConns pool while leaving headroom
// for legitimate pipelining (RFC 7766). 0 or negative means unlimited
// (same as the global cap).
MaxTCPConnsPerClient int
// MaxDoTConnsPerClient is the per-source-IP cap for DoT connections.
// Same default and semantics as MaxTCPConnsPerClient.
MaxDoTConnsPerClient int
// NSID is the RFC 5001 Name Server Identifier reported to clients
// that request it. Empty (the default) disables NSID responses.
//
// The default is empty rather than the hostname on purpose: RFC 5001
// §3.1 notes the identifier is disclosed to any client that asks, and
// an operator running behind anycast usually wants a deliberate site
// code ("ams-01") rather than an internal hostname. Values longer
// than dns.MaxNSIDLength (64) are truncated when emitted.
NSID string
// DDRTargetName is the DNS name published in RFC 9462 Discovery of
// Designated Resolvers answers — the host a client should connect to
// for encrypted DNS with this resolver.
//
// Empty (the default) disables DDR. The name must be one whose TLS
// certificate covers the IP address clients already use for this
// resolver: RFC 9462 §4.2 requires the client to check exactly that
// before trusting the designation, so a mismatched name produces
// designations every client will reject. There is no safe default to
// guess here, which is why it is opt-in rather than derived from the
// listener address.
DDRTargetName string
// DDRDoHPath is the RFC 9461 §5 URI template advertised for the DoH
// designation. Defaults to "/dns-query{?dns}" when empty.
DDRDoHPath string
// DDRDoHPort is the port advertised for DoH. 0 means "omit the
// parameter", which tells the client to use the ALPN default (443).
DDRDoHPort int
}
ServerConfig holds server-related settings.
type StubZoneConfig ¶
StubZoneConfig holds a single stub zone: the resolver starts iterative resolution (RD=0) from the configured nameserver addresses instead of roots.
type WebAuthConfig ¶
WebAuthConfig holds web dashboard authentication settings.
type WebConfig ¶
type WebConfig struct {
Enabled bool
Addr string
QueryLogBuffer int
TopClientsLimit int
TopDomainsLimit int
AlertErrorThreshold float64
AlertLatencyMs int
AutoUpdate bool
UpdateCheckInterval time.Duration
Dashboard WebDashboardConfig
Auth WebAuthConfig
DoHEnabled bool
DoH3Enabled bool
TLSEnabled bool
TLSCertFile string
TLSKeyFile string
AutoTLS bool
AutoTLSDomain string
AutoTLSEmail string
AutoTLSCacheDir string
AutoTLSStaging bool
}
WebConfig holds web dashboard settings.
type WebDashboardConfig ¶
WebDashboardConfig holds persisted dashboard layout preferences.
type ZabbixConfig ¶
ZabbixConfig holds Zabbix integration settings.