Documentation
¶
Index ¶
- Constants
- Variables
- func ParseDNS64Prefix(cidr string) (net.IPNet, error)
- func SynthesizeAAAA(ipv4 net.IP, prefix net.IPNet) net.IP
- type DelegationNS
- type DoTPolicy
- type ForwardTable
- type ForwardZone
- type InfraCache
- func (ic *InfraCache) CleanStale(maxIdle time.Duration)
- func (ic *InfraCache) GetRTT(nsIP string) time.Duration
- func (ic *InfraCache) IsLame(nsIP string, zone string) bool
- func (ic *InfraCache) Len() int
- func (ic *InfraCache) RecordFailure(nsIP string)
- func (ic *InfraCache) RecordLame(nsIP string, zone string)
- func (ic *InfraCache) RecordRTT(nsIP string, rtt time.Duration)
- func (ic *InfraCache) SortByRTT(entries []nsEntry) []nsEntry
- func (ic *InfraCache) StartCleanup(ctx context.Context, interval, maxIdle time.Duration)
- type LocalRecord
- type LocalZone
- type LocalZoneTable
- type LocalZoneType
- type NSInfo
- type NameServer
- type ResolveResult
- type Resolver
- func (r *Resolver) DNS64Prefix() (net.IPNet, bool)
- func (r *Resolver) DNSSECValidator() *dnssec.Validator
- func (r *Resolver) EnableDNSSEC(logger *slog.Logger)
- func (r *Resolver) InfraCache() *InfraCache
- func (r *Resolver) IsReady() bool
- func (r *Resolver) LocalZones() *LocalZoneTable
- func (r *Resolver) PrimeCommonTLDs()
- func (r *Resolver) PrimeRootHints() error
- func (r *Resolver) QueryDNSSEC(name string, qtype uint16, qclass uint16) (*dns.Message, error)
- func (r *Resolver) Resolve(name string, qtype uint16, qclass uint16) (*ResolveResult, error)
- func (r *Resolver) ResolveWithECS(name string, qtype uint16, qclass uint16, clientECS *dns.ECSOption) (*ResolveResult, error)
- func (r *Resolver) ResolveWithECSAndCD(name string, qtype uint16, qclass uint16, clientECS *dns.ECSOption, cd bool) (*ResolveResult, error)
- func (r *Resolver) SetDNSSECAllowSHA1(allow bool)
- func (r *Resolver) SetDNSSECNegativeTrustAnchors(entries []string) []string
- func (r *Resolver) SetErrorReporting(enabled bool)
- func (r *Resolver) SetForwardTable(ft *ForwardTable)
- func (r *Resolver) SetLocalZones(lz *LocalZoneTable)
- func (r *Resolver) StartRootRefresh(ctx context.Context, interval time.Duration)
- func (r *Resolver) StartTCPPoolCleanup(ctx context.Context)
- func (r *Resolver) Trace(ctx context.Context, name string, qtype uint16, qclass uint16, ...) (*ResolveResult, error)
- type ResolverConfig
- type TraceEvent
- type TraceOptions
- type TraceStatus
Constants ¶
const MaxInfraCacheEntries = 100_000
MaxInfraCacheEntries caps the number of distinct nameserver IPs the InfraCache will track at once. An attacker who controls an authoritative server (or a chain of glue records pointing into their controlled zone) can drive the resolver to contact thousands of distinct upstream NS addresses by serving each query with a fresh, unique IPv4/IPv6 NS set. Each contact lazily creates an NSInfo via getOrCreate, and CleanStale only runs on the operator- configured interval — between ticks the map can grow without bound. 100k IP-tracked nameservers is multiple orders of magnitude above any legitimate population (the global root + TLD + popular auth NS footprint sits below 50k IPs) and small enough that the worst-case footprint stays bounded to a handful of MB. When the cap is reached, getOrCreate evicts the OLDEST (least recently used) entry to make room — the cache exists to remember "good recent servers", so evicting the stalest is the right loss.
const MaxLameZonesPerNS = 10_000
MaxLameZonesPerNS caps the number of zones a single NSInfo will remember as lame. Without this an attacker who controls one nameserver IP can flag it lame for millions of distinct sub-zones via crafted referral chains, inflating the per-NSInfo LameZones map without bound. 10k lame zones per NS is enormous — a single authoritative misbehaving for 10k zones is a sysadmin emergency, not a steady state — and stops a single IP from amplifying memory pressure linearly in qname diversity. When the cap is reached, RecordLame is a no-op (the cache is degraded but functional; the NSInfo still serves its primary role of tracking RTT/FailCount).
const MinRootRefreshInterval = time.Minute
MinRootRefreshInterval is the floor StartRootRefresh applies. The loop calls time.NewTicker(interval) which panics on a non-positive value; a YAML resolver.root_hints_refresh: 0 (or a misconfigured /api/config/raw PUT) would crash the resolver at boot. RFC 8109 recommends ~25 hours (just over a day); 1 minute is well below any legitimate operator setting and just above the panic threshold.
Variables ¶
var DefaultDNS64Prefix = net.IPNet{ IP: net.ParseIP("64:ff9b::"), Mask: net.CIDRMask(96, 128), }
DefaultDNS64Prefix is the well-known prefix for DNS64 (RFC 6052).
var RootServers = []NameServer{
{Name: "a.root-servers.net", IPv4: "198.41.0.4", IPv6: "2001:503:ba3e::2:30"},
{Name: "b.root-servers.net", IPv4: "170.247.170.2", IPv6: "2801:1b8:10::b"},
{Name: "c.root-servers.net", IPv4: "192.33.4.12", IPv6: "2001:500:2::c"},
{Name: "d.root-servers.net", IPv4: "199.7.91.13", IPv6: "2001:500:2d::d"},
{Name: "e.root-servers.net", IPv4: "192.203.230.10", IPv6: "2001:500:a8::e"},
{Name: "f.root-servers.net", IPv4: "192.5.5.241", IPv6: "2001:500:2f::f"},
{Name: "g.root-servers.net", IPv4: "192.112.36.4", IPv6: "2001:500:12::d0d"},
{Name: "h.root-servers.net", IPv4: "198.97.190.53", IPv6: "2001:500:1::53"},
{Name: "i.root-servers.net", IPv4: "192.36.148.17", IPv6: "2001:7fe::53"},
{Name: "j.root-servers.net", IPv4: "192.58.128.30", IPv6: "2001:503:c27::2:30"},
{Name: "k.root-servers.net", IPv4: "193.0.14.129", IPv6: "2001:7fd::1"},
{Name: "l.root-servers.net", IPv4: "199.7.83.42", IPv6: "2001:500:9f::42"},
{Name: "m.root-servers.net", IPv4: "202.12.27.33", IPv6: "2001:dc3::35"},
}
RootServers contains the 13 root DNS servers with IPv4 and IPv6 addresses.
Functions ¶
func ParseDNS64Prefix ¶
ParseDNS64Prefix parses a CIDR string into a net.IPNet suitable for DNS64. It returns an error if the prefix is not a valid IPv6 /96 network.
Types ¶
type DelegationNS ¶
type DelegationNS struct {
Hostname string
IPv4 string
IPv6 string
IPv4s []string
IPv6s []string
IPv4TTL uint32
IPv6TTL uint32
}
DelegationNS represents a delegated nameserver with optional glue. IPv4/IPv6 hold the first glue address of each family; IPv4s/IPv6s hold every one, in referral order. A hostname with several A records (live: freemailbl-s.snb.it, one NS name with three addresses, one of them REFUSED) must keep them all, or the dead one is the only one tried.
type DoTPolicy ¶ added in v0.8.33
type DoTPolicy struct {
// AuthName is the RFC 8310 §6.1 authentication domain name. When set,
// the server certificate is verified against it with ordinary PKIX
// rules — chain to a system root, name match, validity dates.
AuthName string
// Pins holds RFC 8310 §8.1 SPKI pins: base64-encoded SHA-256 digests
// of the server's SubjectPublicKeyInfo. When non-empty, the server's
// SPKI must match one of them.
//
// A pin authenticates the key rather than the name, so it works for an
// upstream with no PKIX-valid certificate — a resolver on an internal
// network, or one whose operator publishes a pin instead of a name.
Pins []string
}
DoTPolicy is the resolved TLS policy for one forward zone.
type ForwardTable ¶
type ForwardTable struct {
// contains filtered or unexported fields
}
ForwardTable stores forward/stub zones and provides longest-suffix matching.
func NewForwardTable ¶
func NewForwardTable(zones []ForwardZone) *ForwardTable
NewForwardTable creates a ForwardTable from the given zone list. Zone names are normalised to lowercase with no trailing dot.
func (*ForwardTable) Match ¶
func (ft *ForwardTable) Match(qname string) *ForwardZone
Match finds the ForwardZone whose name is the longest suffix of qname. Returns nil if no zone matches.
type ForwardZone ¶
type ForwardZone struct {
Name string // zone name (lowercase, no trailing dot)
Addrs []string // upstream IP addresses
IsStub bool // false = forward (RD=1), true = stub (RD=0, iterative from addrs)
// TLS enables DNS-over-TLS to this zone's upstreams (RFC 7858).
// Forward zones only: a stub zone drives iterative resolution against
// arbitrary authoritative servers, which do not speak DoT.
TLS bool
// DoT carries the RFC 8310 authentication policy. Meaningful only when
// TLS is set, and never empty in that case — the config layer rejects
// a TLS forward zone with no way to authenticate its upstream.
DoT DoTPolicy
}
ForwardZone represents a configured forwarding or stub zone.
type InfraCache ¶
type InfraCache struct {
// contains filtered or unexported fields
}
InfraCache tracks nameserver performance (RTT, failures, lameness) to enable intelligent NS selection.
func NewInfraCache ¶
func NewInfraCache() *InfraCache
NewInfraCache creates a new infrastructure cache.
func (*InfraCache) CleanStale ¶
func (ic *InfraCache) CleanStale(maxIdle time.Duration)
CleanStale removes entries that have not been used for more than maxIdle.
func (*InfraCache) GetRTT ¶
func (ic *InfraCache) GetRTT(nsIP string) time.Duration
GetRTT returns the recorded RTT for a nameserver (for testing).
func (*InfraCache) IsLame ¶
func (ic *InfraCache) IsLame(nsIP string, zone string) bool
IsLame returns true if the nameserver is known to be lame for the given zone.
func (*InfraCache) Len ¶
func (ic *InfraCache) Len() int
Len returns the number of entries in the infra cache (for testing).
func (*InfraCache) RecordFailure ¶
func (ic *InfraCache) RecordFailure(nsIP string)
RecordFailure increments the fail count for a nameserver.
func (*InfraCache) RecordLame ¶
func (ic *InfraCache) RecordLame(nsIP string, zone string)
RecordLame marks a nameserver as lame for a specific zone. When the per-NSInfo LameZones map has reached MaxLameZonesPerNS, additional distinct lame zones are dropped silently — see the cap's docstring for the threat model. RTT / FailCount continue to track as normal.
func (*InfraCache) RecordRTT ¶
func (ic *InfraCache) RecordRTT(nsIP string, rtt time.Duration)
RecordRTT records a successful query RTT using EWMA (0.7*old + 0.3*sample).
func (*InfraCache) SortByRTT ¶
func (ic *InfraCache) SortByRTT(entries []nsEntry) []nsEntry
SortByRTT sorts nameserver entries by their effective RTT (fastest first). Entries with failures are penalised. Unknown servers get moderate priority.
func (*InfraCache) StartCleanup ¶
func (ic *InfraCache) StartCleanup(ctx context.Context, interval, maxIdle time.Duration)
StartCleanup runs periodic cleanup of stale infra cache entries.
type LocalRecord ¶
LocalRecord holds a single record within a local zone.
func ParseLocalRecord ¶
func ParseLocalRecord(s string) (*LocalRecord, error)
ParseLocalRecord parses a string in "name TYPE rdata" format into a LocalRecord. Examples:
"localhost. A 127.0.0.1" "localhost. AAAA ::1" "example.com. CNAME www.example.com." "example.com. TXT \"hello world\"" "example.com. MX 10 mail.example.com." "1.0.0.127.in-addr.arpa. PTR localhost."
type LocalZone ¶
type LocalZone struct {
Name string
Type LocalZoneType
Records []LocalRecord
}
LocalZone represents a locally-served DNS zone.
type LocalZoneTable ¶
type LocalZoneTable struct {
// contains filtered or unexported fields
}
LocalZoneTable stores local zones sorted by specificity (longest name first) for efficient longest-suffix matching.
func NewLocalZoneTable ¶
func NewLocalZoneTable(zones []LocalZone) *LocalZoneTable
NewLocalZoneTable creates a LocalZoneTable from the given zones, sorting them so the most specific (longest name) zone comes first.
func (*LocalZoneTable) FindZone ¶ added in v0.8.33
func (t *LocalZoneTable) FindZone(name string) *LocalZone
FindZone returns the local zone whose apex name matches the argument, or nil if no such zone exists. The lookup is exact and case-insensitive (zone names are normalised to lowercase at construction time). The returned pointer shares storage with the table; callers must not mutate it.
This is the public counterpart to findZone: it powers the `/api/zones/:name/export` endpoint, which needs to materialise the records of one specific zone in BIND master-file form.
func (*LocalZoneTable) Lookup ¶
func (t *LocalZoneTable) Lookup(name string, qtype uint16, qclass uint16) *ResolveResult
Lookup checks whether the query matches a local zone and returns the appropriate result. Returns nil if no local zone matches or if the zone type allows fall-through (e.g. LocalTransparent with no matching record).
func (*LocalZoneTable) Zones ¶ added in v0.8.33
func (t *LocalZoneTable) Zones() []LocalZone
Zones returns a snapshot of the local zones in the table. The slice is freshly allocated and the caller may modify it without affecting the table. The order matches the table's internal longest-suffix-first order; the slice is stable for the lifetime of the table because Go map and slice memory is not shared with the table's internal storage once the copy is made.
type LocalZoneType ¶
type LocalZoneType int
LocalZoneType controls how a local zone behaves.
const ( // LocalStatic returns configured records or NXDOMAIN. LocalStatic LocalZoneType = iota // LocalDeny silently drops the query (returns nil response). LocalDeny // LocalRefuse returns REFUSED rcode. LocalRefuse // LocalRedirect returns configured records for any name in the zone. LocalRedirect // LocalTransparent returns configured records if found, otherwise // falls through to recursive resolution. LocalTransparent )
func ParseLocalZoneType ¶
func ParseLocalZoneType(s string) (LocalZoneType, bool)
ParseLocalZoneType converts a string to a LocalZoneType.
type NSInfo ¶
type NSInfo struct {
RTT time.Duration // EWMA of round-trip times
FailCount int
LameZones map[string]struct{}
LastUsed time.Time
// contains filtered or unexported fields
}
NSInfo holds performance data for a single nameserver IP.
type NameServer ¶
NameServer represents a DNS nameserver with its IP addresses.
type ResolveResult ¶
type ResolveResult struct {
Answers []dns.ResourceRecord
Authority []dns.ResourceRecord
Additional []dns.ResourceRecord
RCODE uint8
DNSSECStatus string // "secure", "insecure", "bogus", ""
// DNSSECReason carries a stable token classifying the cause when
// DNSSECStatus is "bogus" or "insecure" due to a specific RFC condition.
// The server uses it to pick a granular RFC 8914 EDE info code
// (signature-expired → 7, dnskey-missing → 9, etc.) instead of always
// emitting the generic EDE 6. Empty string when no specific cause is
// recorded. See dnssec.FailureReason.
DNSSECReason string
// Synthesized marks a result that was locally constructed from cached
// DNSSEC proofs (DNS64 AAAA synthesis) rather than fetched from an
// authoritative server. The server uses this flag to attach RFC 8914
// §4.29 EDE code 29 ("Synthesized") so downstream clients know the
// answer was materialised locally, not an authoritative response.
Synthesized bool
// FailureReason carries a stable token classifying a NON-DNSSEC
// failure (RCODE=SERVFAIL paths that have nothing to do with crypto).
// Currently used to surface "no-reachable-authority" when every NS in
// the delegation refused or was unreachable — the server maps it to
// EDE info code 22 (RFC 8914 §4.22) so clients and operators can tell
// "your resolver is broken" from "the auth chain itself is broken
// upstream of us, retry won't help". Empty when no specific cause.
FailureReason string
// FromFailureCache marks this result as a replay from the RFC 9520
// resolution-failure cache rather than a fresh upstream attempt.
// The server uses the flag to attach RFC 8914 §4.13 EDE info code
// 13 ("Cached Error") alongside whatever EDE the original failure
// reason mapped to, so downstream operators can tell a cache replay
// from a live fresh failure without having to track query timing.
FromFailureCache bool
// Attempts lists the authoritative exchanges that failed while the
// request was resolved ("zone@ip: outcome", at most maxAttemptLog), so
// the fallback log says why the primary resolution gave up.
Attempts []string
Error error // underlying error if resolution failed
// UpstreamECS is the EDNS Client Subnet option that the authoritative
// (or forward) server included in its response, if any. The SCOPE
// PREFIX-LENGTH field (RFC 7871 §6) determines the cache key shape: a
// scope of 0 means the answer is global and can be shared across all
// clients; a non-zero scope means the answer is subnet-specific and
// must be cached under the matching ECS-keyed entry. Nil when the
// upstream did not include ECS in its response.
UpstreamECS *dns.ECSOption
}
ResolveResult holds the outcome of a recursive resolution.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver implements recursive DNS resolution.
func NewResolver ¶
func NewResolver(c *cache.Cache, cfg ResolverConfig, m *metrics.Metrics, logger *slog.Logger) *Resolver
NewResolver creates a new recursive resolver.
func (*Resolver) DNS64Prefix ¶ added in v0.8.47
DNS64Prefix reports the DNS64 synthesis prefix and whether DNS64 is enabled. The server's private-address filter uses it to judge synthesised AAAA records by the IPv4 address they embed.
func (*Resolver) DNSSECValidator ¶ added in v0.6.42
DNSSECValidator exposes the active DNSSEC validator (or nil if DNSSEC is disabled). Used by the observability layer to surface validator counters (e.g. NTAMatches) through the metrics endpoint.
func (*Resolver) EnableDNSSEC ¶
EnableDNSSEC creates the DNSSEC validator, allowing the resolver to validate signed responses. Call this after PrimeRootHints.
func (*Resolver) InfraCache ¶
func (r *Resolver) InfraCache() *InfraCache
InfraCache returns the resolver's infrastructure cache for external use.
func (*Resolver) LocalZones ¶ added in v0.8.33
func (r *Resolver) LocalZones() *LocalZoneTable
LocalZones returns the current local zone table, or nil when none is configured. Used by the secondary-zone manager to merge transferred zones with the statically configured ones rather than replacing them.
func (*Resolver) PrimeCommonTLDs ¶ added in v0.8.32
func (r *Resolver) PrimeCommonTLDs()
PrimeCommonTLDs asks a root server for NS (+glue) of busy parent zones and caches them. Best-effort: individual zone failures are logged and skipped so a single unreachable TLD never blocks readiness.
func (*Resolver) PrimeRootHints ¶
PrimeRootHints queries a root server for . NS to refresh root data.
func (*Resolver) QueryDNSSEC ¶
QueryDNSSEC fetches a DNS record for DNSSEC chain validation. It satisfies the dnssec.Querier interface used by the validator to fetch DNSKEY and DS records.
The previous implementation only sent a single query to a random root server, which works only for ".", root-zone DNSKEY, and TLD DS records. For any deeper zone the root server returns a referral, not the requested records, so the validator could never assemble a chain past the TLD and fell back to Indeterminate for almost every signed zone.
This implementation does proper iterative resolution from the roots, reusing the standard resolver pipeline but bypassing the resolver's own DNSSEC validator on the result. The validator is bypassed because this method is called from within the validator itself — running it again would recurse infinitely. The validator performs its own signature verification on the records this method returns, which is the only correctness guarantee that matters.
func (*Resolver) Resolve ¶
Resolve performs recursive resolution for the given query. Concurrent requests for the same name+type are coalesced. This wrapper retains the legacy signature for callers (and the broad test suite) that do not carry client subnet context.
func (*Resolver) ResolveWithECS ¶ added in v0.6.9
func (r *Resolver) ResolveWithECS(name string, qtype uint16, qclass uint16, clientECS *dns.ECSOption) (*ResolveResult, error)
ResolveWithECS performs recursive resolution while carrying the client's EDNS Client Subnet option (RFC 7871) end-to-end. clientECS is propagated to every authoritative or forward upstream query so the upstream may geo-tailor its response, and the upstream's returned scope is surfaced in ResolveResult.UpstreamECS so the caller can pick the appropriate cache key. Pass nil for clientECS to disable ECS for this resolution (equivalent to Resolve).
Note: ECS is intentionally NOT propagated through the in-flight coalescer key. A coalescer that mixes subnets would serve client A's geo-tailored answer to client B; the coalescer therefore only fires for the no-ECS path. ECS-bearing queries always run independently — correctness over dedup throughput.
func (*Resolver) ResolveWithECSAndCD ¶ added in v0.6.25
func (r *Resolver) ResolveWithECSAndCD(name string, qtype uint16, qclass uint16, clientECS *dns.ECSOption, cd bool) (*ResolveResult, error)
ResolveWithECSAndCD is the CD-bit-aware entry point used by the server when the client's query carried CD=1 (RFC 4035 §3.2.2, RFC 6840 §5.9 — "Checking Disabled"). On the iterative path CD is irrelevant (authoritative servers ignore it), but on the forward path we MUST propagate it so a downstream-validating client does not get its verdict silently rewritten by an intermediate cache that chose to validate on its own. Existing ResolveWithECS callers keep cd=false.
func (*Resolver) SetDNSSECAllowSHA1 ¶ added in v0.6.2
SetDNSSECAllowSHA1 toggles acceptance of weak SHA1-based DNSSEC primitives (RSASHA1 RRSIGs and SHA1 DS digests) on the active validator. Default is false, matching modern resolver behavior. No-op if DNSSEC is not enabled.
func (*Resolver) SetDNSSECNegativeTrustAnchors ¶ added in v0.6.42
SetDNSSECNegativeTrustAnchors installs the operator-configured RFC 7646 NTA list onto the active validator. Each entry is "<zone>|<RFC3339-expiry>|<reason>". Returns the list of entries that failed to parse (caller logs them); the validator still receives the entries that did parse. No-op if DNSSEC is not enabled.
func (*Resolver) SetErrorReporting ¶ added in v0.8.33
SetErrorReporting turns RFC 9567 outbound error reporting on or off at runtime. Called from startup and from the /api/config/raw hot-reload path.
func (*Resolver) SetForwardTable ¶
func (r *Resolver) SetForwardTable(ft *ForwardTable)
SetForwardTable configures forward and stub zones for the resolver.
func (*Resolver) SetLocalZones ¶
func (r *Resolver) SetLocalZones(lz *LocalZoneTable)
SetLocalZones configures the resolver's local zone table. Queries matching a local zone are answered immediately without recursion.
func (*Resolver) StartRootRefresh ¶
StartRootRefresh runs a background goroutine that re-primes root hints at the given interval (RFC 8109). Call this after the initial PrimeRootHints. Floors interval at MinRootRefreshInterval so a bad config never crashes the refresher.
func (*Resolver) StartTCPPoolCleanup ¶ added in v0.8.33
StartTCPPoolCleanup runs the idle-connection sweeper until ctx is done, then closes the pool.
get() already discards connections that went idle too long, so the sweeper is not needed for correctness — it is needed for manners. Without it, a resolver that queried an authoritative over TCP once and then went quiet would hold that socket open on the authoritative's side until the peer timed it out. RFC 7766 §6.2.3 puts the onus on the client to close idle connections, and a busy authoritative serving thousands of resolvers notices when they do not.
func (*Resolver) Trace ¶ added in v0.6.7
func (r *Resolver) Trace( ctx context.Context, name string, qtype uint16, qclass uint16, opts TraceOptions, events chan<- TraceEvent, ) (*ResolveResult, error)
Trace performs a diagnostic resolution that emits one TraceEvent per pipeline stage. The function returns when the channel reader has consumed all events or ctx is cancelled. Events are guaranteed to be ordered by Seq. The caller is expected to read events promptly — the channel is unbuffered to give back-pressure when the UI cannot keep up. Trace closes `events` before it returns.
Trace does NOT use the inflight coalescer (so each call is independent of concurrent production resolutions for the same name) and bypasses the answer cache when opts.BypassCache is set. It still reads glue and delegation cache to avoid hammering the roots on every diagnostic.
type ResolverConfig ¶
type ResolverConfig struct {
MaxDepth int
MaxCNAMEDepth int
UpstreamTimeout time.Duration
UpstreamRetries int
// MaxQueriesPerRequest caps total outbound queries per client request
// (NXNS / runaway-referral backstop). <= 0 means unlimited.
MaxQueriesPerRequest int
// RequestTimeout is the wall-clock deadline for one client request.
// <= 0 means no deadline.
RequestTimeout time.Duration
// FailureCacheMinTTL / FailureCacheMaxTTL bound the RFC 9520 §3.2
// resolution-failure cache: a failure is held FailureCacheMinTTL at
// first and twice as long each time it recurs, up to
// FailureCacheMaxTTL (capped at 5 minutes). <= 0 means 5s / 5m.
FailureCacheMinTTL time.Duration
FailureCacheMaxTTL time.Duration
QMinEnabled bool
Caps0x20Enabled bool // DNS 0x20 case randomization (RFC 5452)
PreferIPv4 bool
DNSSECEnabled bool
// UpstreamPort overrides the DNS port for upstream queries (default "53").
// Used for testing with mock DNS servers.
UpstreamPort string
// DNS64Enabled enables DNS64 synthesis (RFC 6147).
DNS64Enabled bool
// DNS64Prefix is the IPv6 prefix used for DNS64 synthesis (must be /96).
DNS64Prefix net.IPNet
// ECSEnabled enables forwarding of EDNS Client Subnet options.
ECSEnabled bool
// ECSMaxPrefix is the maximum source prefix length for ECS (default 24).
ECSMaxPrefix int
// FallbackResolvers is a list of backup recursive DNS servers (e.g. 8.8.8.8, 1.1.1.1).
// When primary resolution returns SERVFAIL, one randomly-picked fallback is tried once.
FallbackResolvers []string
// FallbackDebug enables JSONL writes to FallbackLogPath for each
// public-resolver fallback engagement (reason + recovered).
FallbackDebug bool
// FallbackLogPath is the destination for fallback debug JSONL.
// Used only when FallbackDebug is true; empty disables the file.
FallbackLogPath string
// UpstreamUDPBufferSize is the EDNS0 UDP payload size advertised in
// outgoing OPT records. RFC 9018 / DNS Flag Day 2020 recommends 1232
// to avoid IP fragmentation, which closes the off-path fragment-
// injection cache-poisoning vector. 0 means "use the safe default".
UpstreamUDPBufferSize int
// MaxNSNamesPerDelegation caps how many NS hostnames the resolver will
// accept from a single delegation response. Default 13 matches BIND's
// effective cap; 0 or negative means unlimited.
MaxNSNamesPerDelegation int
}
ResolverConfig holds configuration for the recursive resolver.
type TraceEvent ¶ added in v0.6.7
type TraceEvent struct {
Seq uint64 `json:"seq"`
Stage string `json:"stage"`
Status TraceStatus `json:"status"`
Time time.Time `json:"time"`
ElapsedMs int64 `json:"elapsed_ms"`
Message string `json:"message"`
Details map[string]any `json:"details,omitempty"`
}
TraceEvent is a single point of progress emitted by Trace.
Stage names are stable and form the "pipeline" the UI renders:
start, local-zones, forward-zones, cache, iterative-step, upstream, classify, cname, dname, delegation, dnssec, fallback, finish.
Details is free-form per-stage context (e.g. NS IP, response counts).
type TraceOptions ¶ added in v0.6.7
type TraceOptions struct {
// BypassCache makes the trace ignore the resolver cache for the queried
// name. Glue / DNSKEY caching is unaffected so the trace stays fast.
BypassCache bool
// SkipDNSSEC turns off the DNSSEC validator for this trace even if the
// resolver has it enabled. Useful when diagnosing whether a SERVFAIL is
// upstream-related or validation-related.
SkipDNSSEC bool
// MaxDepth caps the number of iterative steps; 0 falls back to resolver
// MaxDepth.
MaxDepth int
// MaxCNAMEDepth caps CNAME chasing; 0 falls back to resolver setting.
MaxCNAMEDepth int
}
TraceOptions controls Trace behaviour.
type TraceStatus ¶ added in v0.6.7
type TraceStatus string
TraceStatus classifies an emitted event for UI rendering.
const ( TraceStatusInfo TraceStatus = "info" TraceStatusOK TraceStatus = "ok" TraceStatusWarn TraceStatus = "warn" TraceStatusError TraceStatus = "error" )
Source Files
¶
- classify.go
- closest_delegation.go
- cname.go
- delegation.go
- dns64.go
- dot_upstream.go
- errorreport.go
- failure_cache.go
- fallback.go
- fallback_debug.go
- forward.go
- inflight.go
- infracache.go
- localzone.go
- no_edns_cache.go
- nsec_aggressive.go
- qmin.go
- resolver.go
- rfc6303_locally_served.go
- roots.go
- server_cookie_cache.go
- specialuse.go
- tcppool.go
- trace.go
- trace_ede.go
- udp_dial.go
- udp_pmtu_linux.go
- upstream.go