config

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Version          string
	Directory        string
	BlockLists       []string
	BlockListDir     string
	RootServers      []string
	Root6Servers     []string
	DNSSEC           string
	RootKeys         []string
	FallbackServers  []string
	ForwarderServers []string
	AccessList       []string
	LogLevel         string
	AccessLog        string
	Bind             string
	BindTLS          string
	BindDOH          string
	BindDOQ          string
	TLSCertificate   string
	TLSPrivateKey    string
	API              string
	BearerToken      string //nolint:gosec // G117 - not a hardcoded credential, loaded from config file
	Nullroute        string
	Nullroutev6      string
	HostsFile        string
	OutboundIPs      []string
	OutboundIP6s     []string
	Timeout          Duration
	QueryTimeout     Duration
	Expire           uint32
	CacheSize        int
	Prefetch         uint32
	Maxdepth         int
	RateLimit        int
	ClientRateLimit  int
	NSID             string
	Blocklist        []string
	Whitelist        []string
	Chaos            bool
	QnameMinLevel    int `toml:"qname_min_level"`
	EmptyZones       []string

	// Views are per-client static answers, evaluated in order. A
	// query whose source IP falls in a view's Sources gets that
	// view's Records as the response; non-matching queries fall
	// through to the rest of the middleware chain (blocklist,
	// resolver, etc.).
	Views []ViewConfig

	// Dnstap configuration
	DnstapSocket        string
	DnstapIdentity      string
	DnstapVersion       string
	DnstapLogQueries    bool
	DnstapLogResponses  bool
	DnstapFlushInterval int

	// Domain metrics configuration
	DomainMetrics      bool
	DomainMetricsLimit int

	// Kubernetes middleware configuration as a section
	Kubernetes KubernetesConfig `toml:"kubernetes"`

	// DNS64 middleware configuration (RFC 6147). Translates A
	// records into AAAA records embedded in a configured IPv6
	// prefix, so an IPv6-only client can reach IPv4-only services.
	DNS64 DNS64Config `toml:"dns64"`

	// ECS (EDNS Client Subnet, RFC 7871) policy. Default-disabled
	// per §11 privacy guidance: the resolver strips client ECS on
	// the way out unless the operator opts in via [ecs].enabled.
	// Stage 1 of the feature uses Enabled / ForwardV4Max /
	// ForwardV6Max / ClientNetworks for upstream forwarding; the
	// remaining fields ride along for the Stage 2 cache changes
	// so the on-disk schema only bumps once.
	ECS ECSConfig `toml:"ecs"`

	Plugins map[string]Plugin

	CookieSecret string
	IPv6Access   bool `toml:"ipv6access"`

	// TCP connection pooling configuration
	TCPKeepalive      bool
	RootTCPTimeout    Duration // Timeout for root server TCP connections
	TLDTCPTimeout     Duration // Timeout for TLD server TCP connections
	TCPMaxConnections int      // Maximum number of TCP connections to pool

	// Resolver concurrency limits
	MaxConcurrentQueries int // Maximum concurrent DNS queries (default 10000)

	// Reflex: DNS amplification/reflection attack detection
	ReflexEnabled      bool    // Enable amplification attack detection
	ReflexBlockMode    bool    // If false, only log but don't block
	ReflexLearningMode bool    // If true, log detections but don't block
	ReflexThreshold    float64 // Suspicion threshold (0.0-1.0, default: 0.7)
	// contains filtered or unexported fields
}

Config type.

func Load

func Load(cfgfile, version string) (*Config, error)

Load loads the given config file.

func (*Config) ServerVersion added in v1.0.0

func (c *Config) ServerVersion() string

(*Config).ServerVersion serverVersion return current server version.

type DNS64Config added in v1.6.7

type DNS64Config struct {
	Enabled             bool     `toml:"enabled"`
	Prefixes            []string `toml:"prefixes"`
	ClientNetworks      []string `toml:"client_networks"`
	ExcludeZones        []string `toml:"exclude_zones"`
	ExcludeANetworks    []string `toml:"exclude_a_networks"`
	ExcludeAAAANetworks []string `toml:"exclude_aaaa_networks"`
}

DNS64Config holds DNS64 middleware configuration (RFC 6147).

Prefixes lists Pref64::/n IPv6 prefixes used to embed IPv4 addresses in synthesised AAAA records. Each prefix length must be one of /32, /40, /48, /56, /64, /96 per RFC 6052 §2.2. Per RFC 6147 §5.2 every configured prefix synthesises in parallel: each upstream A record produces one AAAA per prefix, so a client receives every reachable Pref64 path in a single reply. When DNS64 is enabled but no usable prefix is configured the well-known 64:ff9b::/96 is the runtime default.

ClientNetworks restricts synthesis to clients whose source IP falls in one of the listed CIDRs. An empty list synthesises for every client; "::/0" plus "0.0.0.0/0" achieves the same and is the recommended explicit form.

ExcludeZones is a list of fully-qualified domain names whose AAAA responses are never synthesised (their original NODATA / NXDOMAIN flows through unchanged). Useful for opting out specific zones when some other middleware is expected to handle IPv6.

ExcludeANetworks is the RFC 6147 §5.1.4 / RFC 6052 §3.1 "do not translate" set. IPv4 addresses inside any listed CIDR are dropped from synthesis when the well-known prefix 64:ff9b::/96 is in use. Operator-chosen network-specific prefixes ignore this list — they picked the prefix knowing the network's reachability. When the field is omitted entirely (nil) and the well-known prefix is active, a runtime default list mirroring the IANA Special-Purpose Address Registry is applied; declaring an explicit empty list opts out.

ExcludeAAAANetworks lists IPv6 prefixes whose AAAA records in the upstream response must be filtered before deciding pass-through vs synthesis (RFC 6147 §5.1.4). The default ::ffff:0:0/96 (IPv4- mapped IPv6) keeps misconfigured upstreams from leaking non-routable addresses into the client. When every AAAA in the upstream answer is excluded, the response is treated as if no AAAA records were returned and synthesis proceeds. Declaring an explicit empty list opts out of filtering.

type Duration added in v0.3.0

type Duration struct {
	time.Duration
}

Duration type.

func (*Duration) UnmarshalText added in v0.3.0

func (d *Duration) UnmarshalText(text []byte) error

(*Duration).UnmarshalText unmarshalText for duration type.

type ECSConfig added in v1.7.0

type ECSConfig struct {
	Enabled        bool     `toml:"enabled"`
	ForwardV4Max   uint8    `toml:"forward_v4"`
	ForwardV6Max   uint8    `toml:"forward_v6"`
	ClientNetworks []string `toml:"client_networks"`
	CacheLimitTTL  Duration `toml:"cache_limit_ttl"`
	MinScopeV4     uint8    `toml:"min_scope_v4"`
	MinScopeV6     uint8    `toml:"min_scope_v6"`
}

ECSConfig holds the EDNS Client Subnet middleware configuration (RFC 7871). Strictly opt-in: when Enabled is false, the resolver strips every client-supplied ECS option before forwarding upstream, matching the §11 privacy stance and SDNS's historical behaviour.

When Enabled is true, ForwardV4Max and ForwardV6Max cap the source-prefix length we'll forward — narrower (more specific) client prefixes get clamped down. Defaults are /24 and /56, matching common operator practice.

ClientNetworks restricts forwarding to known clients (corporate networks, internal load balancers, CDN edges); empty means every eligible client.

CacheLimitTTL, MinScopeV4, and MinScopeV6 control how scoped answers are stored (Stage 2). They live here so the on-disk schema only bumps once across the rollout, even though Stage 1 doesn't consume them yet.

type KubernetesConfig added in v1.6.0

type KubernetesConfig struct {
	Enabled       bool   `toml:"enabled"`
	ClusterDomain string `toml:"cluster_domain"`
	// KillerMode is deprecated and ignored. The kubernetes middleware
	// always uses the sharded registry; the field is retained so
	// older configs parse without error. Remove it from new configs.
	KillerMode bool   `toml:"killer_mode"`
	Kubeconfig string `toml:"kubeconfig"`
	// Demo populates the registry with synthetic services so the
	// middleware can be exercised without a real cluster
	// (development / tests). It is NEVER safe to enable in
	// production: the middleware will answer synthesised names
	// that look real. Independent from Enabled.
	Demo bool                `toml:"demo"`
	TTL  KubernetesTTLConfig `toml:"ttl"`
}

KubernetesConfig holds Kubernetes middleware configuration

type KubernetesTTLConfig added in v1.6.0

type KubernetesTTLConfig struct {
	Service uint32 `toml:"service"`
	Pod     uint32 `toml:"pod"`
	SRV     uint32 `toml:"srv"`
	PTR     uint32 `toml:"ptr"`
}

KubernetesTTLConfig holds TTL settings for different record types

type Plugin added in v1.1.0

type Plugin struct {
	Path   string
	Config map[string]any
}

Plugin type.

type ViewConfig added in v1.6.6

type ViewConfig struct {
	Zone     string
	Networks []string
	Answers  []string
}

ViewConfig describes a single per-client static-answer view. Zone is a free-form label that names the view in logs and errors. Networks are CIDR strings; a query is dispatched to this view if its source IP is contained in any of them. Answers are DNS resource records in standard zone-file format; wildcard owners (e.g. "*.example.lan.") match any name strictly more specific than the suffix per RFC 4592.

Jump to

Keyboard shortcuts

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