config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config assembles the settings a Wegweiser process starts with.

It holds bootstrap settings and nothing else: listen addresses, where the database is, and how loudly to log. Everything an operator manages (zones, records, tokens, the reverse conflict policy) lives in the database and is reachable through the API, because architecture invariant 1 says no feature exists in only one client, and a setting that lives only in a file is a feature that exists only for whoever can log in to the machine (docs/decisions.md D11).

Index

Constants

View Source
const DefaultPath = "/etc/wegweiser/config.yaml"

DefaultPath is where the file lives when nothing says otherwise. It matches the packaging: the unit and the container both put it there.

View Source
const PathEnv = "WEG_CONFIG"

PathEnv names the environment variable that moves the file.

Variables

View Source
var Defaults = struct {
	DNSListen       string
	APIListen       string
	APIUI           bool
	Database        string
	UDPResponseSize uint16
	MaxTCPClients   int
	LogLevel        string
}{

	DNSListen: ":53",

	APIListen: "127.0.0.1:8053",

	APIUI: true,

	Database:        "wegweiser.db",
	UDPResponseSize: 1232,

	MaxTCPClients: 0,
	LogLevel:      "info",
}

Defaults are what a process runs with when nothing says otherwise.

View Source
var LogLevels = []string{"debug", "info", "warn", "error"}

LogLevels are the levels Config.LogLevel accepts.

Functions

func LocalAPIAddress

func LocalAPIAddress() (string, bool)

LocalAPIAddress is where the API on this machine listens, as far as the configuration file says, and whether the file said anything.

Types

type APIFile

type APIFile struct {
	Listen *string `json:"listen,omitempty"`
	UI     *bool   `json:"ui,omitempty"`
}

APIFile is what the control plane takes.

type Config

type Config struct {
	// Path is the file that was read, empty when there was none.
	Path string

	DNSListen       Value[string]
	APIListen       Value[string]
	APIUI           Value[bool]
	Database        Value[string]
	UDPResponseSize Value[uint16]
	MaxTCPClients   Value[int]
	LogLevel        Value[string]
}

Config is the settings a process starts with.

func Load

func Load(path string, flags Flags) (*Config, error)

Load reads the file and lays the environment and the flags over it.

type DNSFile

type DNSFile struct {
	Listen          *string `json:"listen,omitempty"`
	UDPResponseSize *uint16 `json:"udpResponseSize,omitempty"`
	MaxTCPClients   *int    `json:"maxTCPClients,omitempty"`
}

DNSFile is what the query path takes.

type DatabaseFile

type DatabaseFile struct {
	Path *string `json:"path,omitempty"`
}

DatabaseFile is where the store lives.

type File

type File struct {
	DNS      DNSFile      `json:"dns,omitempty"`
	API      APIFile      `json:"api,omitempty"`
	Database DatabaseFile `json:"database,omitempty"`
	Log      LogFile      `json:"log,omitempty"`
}

File is the document on disk.

type Flags

type Flags struct {
	DNSListen       *string
	APIListen       *string
	APIUI           *bool
	Database        *string
	UDPResponseSize *uint16
	MaxTCPClients   *int
	LogLevel        *string
}

Flags are the settings a command line supplied. A nil field is one the command line did not mention.

type LogFile

type LogFile struct {
	Level *string `json:"level,omitempty"`
}

LogFile is how loudly to report.

type Source

type Source string

Source is where a setting's value came from.

const (
	FromFlag        Source = "flag"
	FromEnvironment Source = "environment"
	FromFile        Source = "file"
	FromDefault     Source = "default"
)

The four places a setting can come from, strongest first.

type Value

type Value[T any] struct {
	Value  T
	Source Source
}

Value is one setting, and where it came from.

Jump to

Keyboard shortcuts

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