Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDnstapMinimiserRunning is returned when Run is called concurrently. ErrDnstapMinimiserRunning = errors.New("dnstap minimiser is already running") // ErrDnstapMinimiserAlreadyRun is returned when Run is called after a prior run. ErrDnstapMinimiserAlreadyRun = errors.New("dnstap minimiser has already run") // ErrNilConfigProvider is returned when a nil ConfigProvider is supplied. ErrNilConfigProvider = errors.New("nil config provider") // ErrNilLogger is returned when a nil logger is supplied. ErrNilLogger = errors.New("nil logger") // ErrNilRunContext is returned when Run is called with a nil context. ErrNilRunContext = errors.New("nil run context") // ErrInvalidConfig is wrapped by every error returned from // [Config.Validate] so callers can match configuration validation // failures with [errors.Is]. ErrInvalidConfig = errors.New("invalid configuration") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
ConfigFile string `toml:"config-file"`
DisableSessionFiles bool `toml:"disable-session-files" reload:"true"`
DisableHistogramSender bool `toml:"disable-histogram-sender" reload:"true"`
DisableMQTT bool `toml:"disable-mqtt"`
DisableMQTTFilequeue bool `toml:"disable-mqtt-filequeue"`
EnableManualParquetRotation bool `toml:"enable-manual-parquet-rotation"`
PebbleSync bool `toml:"pebble-sync" reload:"true"`
InputUnix string `toml:"input-unix"`
InputTCP string `toml:"input-tcp"`
InputTLS string `toml:"input-tls"`
InputTLSCertFile string `toml:"input-tls-cert-file"`
InputTLSKeyFile string `toml:"input-tls-key-file"`
InputTLSClientCAFile string `toml:"input-tls-client-ca-file"`
CryptopanKey string `toml:"cryptopan-key" reload:"true"`
CryptopanKeySalt string `toml:"cryptopan-key-salt" reload:"true"`
WellKnownDomainsFile string `toml:"well-known-domains-file" reload:"true"`
HistogramHLLExplicitThreshold int `toml:"histogram-hll-explicit-threshold"`
IgnoredClientIPsFile string `toml:"ignored-client-ips-file" reload:"true"`
IgnoredQuestionNamesFile string `toml:"ignored-question-names-file" reload:"true"`
DataDir string `toml:"data-dir"`
MinimiserWorkers int `toml:"minimiser-workers"`
MQTTSigningKeyFile string `toml:"mqtt-signing-key-file"`
MQTTClientKeyFile string `toml:"mqtt-client-key-file" reload:"true"`
MQTTClientCertFile string `toml:"mqtt-client-cert-file" reload:"true"`
MQTTServer string `toml:"mqtt-server"`
MQTTCAFile string `toml:"mqtt-ca-file"`
MQTTKeepalive uint16 `toml:"mqtt-keepalive"`
MQTTSignWorkers int `toml:"mqtt-sign-workers"`
QnameSeenEntries int `toml:"qname-seen-entries"`
CryptopanAddressEntries int `toml:"cryptopan-address-entries"`
NewQnameBuffer int `toml:"newqname-buffer"`
HTTPCAFile string `toml:"http-ca-file"`
HTTPSigningKeyFile string `toml:"http-signing-key-file"`
HTTPClientKeyFile string `toml:"http-client-key-file" reload:"true"`
HTTPClientCertFile string `toml:"http-client-cert-file" reload:"true"`
HTTPURL string `toml:"http-url"`
Debug bool `toml:"debug"`
DebugDnstapFilename string `toml:"debug-dnstap-filename"`
DebugEnableBlockProfiling bool `toml:"debug-enable-blockprofiling"`
DebugEnableMutexProfiling bool `toml:"debug-enable-mutexprofiling"`
}
Config contains all runtime configuration for DnstapMinimiser.
The toml struct tags name the config file keys and stay in sync with the flags in pkg/cmd. Validation rules are enforced by Config.Validate.
func DefaultConfig ¶
func DefaultConfig() (conf Config)
DefaultConfig returns the built-in defaults for Config.
It is the single source of truth for both the "run" command flag defaults and the base layer FileConfigProvider starts from before applying the config file and startup overrides.
func (Config) Validate ¶
Validate checks the configuration rules for Config.
It reports every violation in a single error: individual failures are combined with errors.Join and the result wraps ErrInvalidConfig for matching with errors.Is. Violations of the exactly-one-input rule additionally wrap the same error identities returned by the dnstap input setup. Messages use the CLI flag / config key spelling.
type ConfigOverride ¶
type ConfigOverride func(*Config)
ConfigOverride applies one flag- or environment-derived value to a Config.
Overrides are captured once at startup and re-applied on every config reload, so command line and environment values always win over the config file even after the file changes.
type ConfigProvider ¶
ConfigProvider supplies the current runner configuration.
Implementations must be safe to call from the runner's config reload goroutine while DnstapMinimiser.Run is active.
type DnstapMinimiser ¶
type DnstapMinimiser struct {
// contains filtered or unexported fields
}
DnstapMinimiser runs the Edge DNSTAP Minimiser service.
Construct instances with NewDnstapMinimiser. A DnstapMinimiser is single-use: one instance supports exactly one DnstapMinimiser.Run lifecycle. Concurrent Run calls return ErrDnstapMinimiserRunning; calls after a prior Run has started return ErrDnstapMinimiserAlreadyRun.
func NewDnstapMinimiser ¶
func NewDnstapMinimiser(provider ConfigProvider, logger *slog.Logger, opts ...DnstapMinimiserOption) (*DnstapMinimiser, error)
NewDnstapMinimiser constructs a DnstapMinimiser.
The returned service is ready to run but has no active run context until DnstapMinimiser.Run is called.
func (*DnstapMinimiser) Run ¶
func (edm *DnstapMinimiser) Run(ctx context.Context) error
Run starts the minimiser and blocks until it stops.
Run is not reentrant. It returns startup and runtime errors directly. When ctx is cancelled after startup, workers drain in shutdown order and Run returns nil.
type DnstapMinimiserOption ¶
type DnstapMinimiserOption func(*dnstapMinimiserOptions)
DnstapMinimiserOption customizes a DnstapMinimiser at construction time.
func WithLoggerLevel ¶
func WithLoggerLevel(loggerLevel *slog.LevelVar) DnstapMinimiserOption
WithLoggerLevel sets the mutable log level used by DnstapMinimiser.Run.
type FileConfigProvider ¶
type FileConfigProvider struct {
// contains filtered or unexported fields
}
FileConfigProvider reads Config from a TOML file, layering it as DefaultConfig values overwritten by file contents overwritten by overrides.
It implements ConfigProvider and is safe for repeated GetConfig calls from the runner's config reload goroutine.
func NewFileConfigProvider ¶
func NewFileConfigProvider(path string, overrides ...ConfigOverride) *FileConfigProvider
NewFileConfigProvider returns a provider reading the TOML file at path.
func (*FileConfigProvider) GetConfig ¶
func (p *FileConfigProvider) GetConfig() (conf Config, err error)
GetConfig reads and validates the configuration.
The file is re-read on every call so a SIGHUP-triggered reload always observes the current file contents. Unknown keys in the config file are rejected; the returned error wraps toml.StrictMissingError. A decode or strict-mode failure additionally carries go-toml's human-readable detail (the offending key and source line). Validation failures wrap ErrInvalidConfig.
func (*FileConfigProvider) Path ¶
func (p *FileConfigProvider) Path() string
Path returns the config file path the provider reads from.