config

package
v0.3.0-dev Latest Latest
Warning

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

Go to latest
Published: Apr 11, 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"`
	SMTP    SMTPConfig    `koanf:"smtp"`
	SMTPS   SMTPSConfig   `koanf:"smtps"`
	Logging LoggingConfig `koanf:"logging"`
}

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"`
}

type HTTPSConfig

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

type LoadResult

type LoadResult struct {
	Config  Config
	Path    string
	Created bool
}

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 SMTPConfig

type SMTPConfig struct {
	Enabled           bool   `koanf:"enabled"`
	Addr              string `koanf:"addr"`                // ":1025"
	Domain            string `koanf:"domain"`              // "localhost"
	WriteTimeout      int    `koanf:"write_timeout"`       // 10 seconds
	ReadTimeout       int    `koanf:"read_timeout"`        // 10 seconds
	MaxMessageBytes   int    `koanf:"max_message_bytes"`   // 1024 * 1024
	MaxRecipients     int    `koanf:"max_recipients"`      // 50
	RequireAuth       bool   `koanf:"require_auth"`        // false
	AllowInsecureAuth bool   `koanf:"allow_insecure_auth"` // true
}

type SMTPSConfig

type SMTPSConfig struct {
	Enabled           bool   `koanf:"enabled"`
	Addr              string `koanf:"addr"`                // ":1465"
	Domain            string `koanf:"domain"`              // "localhost"
	WriteTimeout      int    `koanf:"write_timeout"`       // 10 seconds
	ReadTimeout       int    `koanf:"read_timeout"`        // 10 seconds
	MaxMessageBytes   int    `koanf:"max_message_bytes"`   // 1024 * 1024
	MaxRecipients     int    `koanf:"max_recipients"`      // 50
	RequireAuth       bool   `koanf:"require_auth"`        // false
	AllowInsecureAuth bool   `koanf:"allow_insecure_auth"` // false (secure)
	Cert              string `koanf:"cert"`                // Optional TLS cert
	Key               string `koanf:"key"`                 // Optional TLS key
}

Jump to

Keyboard shortcuts

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