config

package
v0.5.0-dev Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	General   GeneralConfig    `koanf:"general"`
	DNS       DNSConfig        `koanf:"dns"`
	HTTP      HTTPConfig       `koanf:"http"`
	HTTPS     HTTPSConfig      `koanf:"https"`
	Logging   LoggingConfig    `koanf:"logging"`
	State     StateConfig      `koanf:"state"`
	Listeners []ListenerConfig `koanf:"listeners"`
}

func Default

func Default() Config

func (Config) Validate

func (c Config) Validate() error

type DNSConfig

type DNSConfig struct {
	Enabled  bool   `koanf:"enabled"`
	Listen   string `koanf:"listen"`
	Network  string `koanf:"network"`
	IPv4     string `koanf:"ipv4"`
	IPv6     string `koanf:"ipv6"`
	Domain   string `koanf:"domain"`
	TXT      string `koanf:"txt"`
	TTL      uint32 `koanf:"ttl"`
	Compress bool   `koanf:"compress"`
}

type GeneralConfig

type GeneralConfig struct {
	ShutdownTimeout time.Duration `koanf:"shutdown_timeout"`
}

type HTTPConfig

type HTTPConfig struct {
	Enabled bool   `koanf:"enabled"`
	Listen  string `koanf:"listen"`
	Status  int    `koanf:"status"`
	Mode    string `koanf:"mode"`
	RootDir string `koanf:"root_dir"`
}

type HTTPSConfig

type HTTPSConfig struct {
	Enabled bool   `koanf:"enabled"`
	Listen  string `koanf:"listen"`
	Status  int    `koanf:"status"`
	Mode    string `koanf:"mode"`
	RootDir string `koanf:"root_dir"`
	Cert    string `koanf:"cert"`
	Key     string `koanf:"key"`
}

type ListenerConfig

type ListenerConfig struct {
	Name        string        `koanf:"name"`
	Enabled     *bool         `koanf:"enabled"`
	Type        string        `koanf:"type"`
	Listen      string        `koanf:"listen"`
	Handler     string        `koanf:"handler"`
	ReadTimeout time.Duration `koanf:"read_timeout"`
	TLS         bool          `koanf:"tls"`
	TLSCert     string        `koanf:"tls_cert"`
	TLSKey      string        `koanf:"tls_key"`
	Capture     *bool         `koanf:"capture"`
}

ListenerConfig is a single [[listeners]] entry; Enabled/Capture default to true when unset.

func (ListenerConfig) IsEnabled

func (c ListenerConfig) IsEnabled() bool

func (ListenerConfig) ShouldCapture

func (c ListenerConfig) ShouldCapture() bool

type LoadResult

type LoadResult struct {
	Config  Config
	Path    string
	Created bool
}

func LoadOptional

func LoadOptional(configPath string, overrides map[string]any) (LoadResult, error)

LoadOptional never creates a config file, unlike LoadOrCreate

func LoadOrCreate

func LoadOrCreate(configPath string) (LoadResult, error)

func LoadOrCreateWithOverrides

func LoadOrCreateWithOverrides(configPath string, overrides map[string]any) (LoadResult, error)

LoadOrCreateWithOverrides loads defaults, then the on-disk config file, then applies the provided flat overrides (dot-delimited keys).

Validation is intentionally not run here; callers should map the resulting config into the isolated service configs (e.g. dnsserver.Config) and call Validate() once on those structs before starting services.

type LoggingConfig

type LoggingConfig struct {
	LogFormat string `koanf:"format"`
	Level     string `koanf:"level"`
}

type StateConfig

type StateConfig struct {
	TotalLimit string `koanf:"total_limit"`
}

empty TotalLimit means the state package default

Jump to

Keyboard shortcuts

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