config

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config manages proximo's persisted user configuration and the on-disk paths it uses (TLS material, the embedded stack, etc.).

Index

Constants

View Source
const (
	// DefaultTLD is the default top-level domain used for local routing.
	// ".test" is reserved by RFC 6761 and never collides with mDNS (".local").
	DefaultTLD = "test"

	// DNSPort is the loopback UDP host port the DNS server is published on. A
	// high port avoids any privileged bind to :53; 5353 is intentionally
	// avoided because macOS mDNSResponder (Bonjour) already binds it.
	DNSPort = 5354

	// PeerDNSPort is the port the peer DNS service answers on, on this
	// machine's mesh address — the port a mesh routes the peer subtree to. It
	// shares the loopback port's number, on another address.
	PeerDNSPort = 5354

	// ObsHubPort is the loopback TCP host port the metrics hub is published on
	// (only when the observability profile is active) so the one-shot bootstrap
	// can reach the hub API directly, without depending on DNS/Traefik/TLS being
	// converged yet. A high, uncommon port avoids colliding with the hub's
	// default 8090.
	ObsHubPort = 48090

	// InspectAPIPort is the loopback TCP host port the Inspection hop publishes
	// its read API on, so `proximo errors` can reach it. The proxy side of the
	// hop is never published: only Traefik talks to it, over the stack network.
	InspectAPIPort = 48091

	// WatcherAPIPort is the loopback TCP host port the watcher publishes its
	// Incident read API on, so `proximo errors` can ask what the runtime declared
	// about a container. The watcher has no other listener: it is the one stack
	// service holding both the Docker socket and the event subscription, and this
	// is the only way anything on the host reads what it observed.
	WatcherAPIPort = 48092
)
View Source
const AddressRule = "" /* 176-byte string literal not displayed */

AddressRule is printed on every `config address`: the held-by-an-interface check catches a typo or a stale value, never a wrong-but-local address.

View Source
const (

	// InventorySubdir is the inventory's directory under DataDir; the stack's
	// compose file mounts __DATADIR__/inventory, the same name.
	InventorySubdir = "inventory"
)
View Source
const MachineRule = "" /* 186-byte string literal not displayed */

MachineRule is printed on every `config machine`, unconditionally: the one intervention available for a value whose fault cannot be detected.

Variables

This section is empty.

Functions

func AddressHeld added in v0.16.0

func AddressHeld(addr string, addrs []net.Addr) bool

AddressHeld reports whether one of addrs (as net.InterfaceAddrs returns them) is exactly addr. Exact, never subnet membership: a mesh range is typically a /8, and membership in it asserts almost nothing.

func DataDir added in v0.3.0

func DataDir() (string, error)

DataDir returns (creating if needed) the directory holding the stack's bind-mounted runtime data (Traefik routes/certs, Beszel metrics). It is the host side of the data bind mounts the materialized compose declares.

func Dir

func Dir() (string, error)

Dir returns (creating if needed) the per-user state home at $HOME/.proximo.

func HomePath added in v0.4.0

func HomePath() (string, error)

HomePath resolves the state-home path ($HOME/.proximo) without creating it, so callers that only need the location (RemoveHome, `config ca-path`) don't trigger side effects.

func InventoryDir added in v0.16.0

func InventoryDir() (string, error)

InventoryDir resolves, without creating it, the directory the watcher keeps the effective-route inventory in. It is a directory rather than the file because the file is replaced by rename: a consumer bind-mounting the file itself would keep the first inode it saw. `config inventory-dir` prints it.

func NormalizeMachine added in v0.16.0

func NormalizeMachine(raw string) (string, error)

NormalizeMachine validates a machine label: one DNS label of [a-z0-9-], lowercased, at most 63 octets. Whether it names a person is not something a machine can judge, so it is not checked — MachineRule is printed instead.

func NormalizePeerSuffix added in v0.16.0

func NormalizePeerSuffix(raw string) (string, error)

NormalizePeerSuffix validates a Peer suffix: at least two DNS labels of [a-z0-9-], lowercased, leading and trailing dots stripped. NormalizeTLD does not fit: it accepts exactly one label.

func NormalizeTLD

func NormalizeTLD(raw string) (string, error)

NormalizeTLD validates and normalizes a user-supplied TLD: it strips a leading dot, lowercases, enforces a single DNS label, and rejects reserved values.

func ParseAddress added in v0.16.0

func ParseAddress(raw string) (string, error)

ParseAddress validates the address proximo answers peer names with.

func PeerSuffixWarning added in v0.16.0

func PeerSuffixWarning(suffix string) string

PeerSuffixWarning returns advice for a suffix whose right-most label nobody reserved, or "" for a reserved one. It never rejects, as TLDWarning does not.

func RemoveHome added in v0.3.0

func RemoveHome() error

RemoveHome deletes the entire ~/.proximo state home (CA, secret, config, materialized stack, and bind-mounted data). uninstall calls it after the stack is down and host trust/resolver are reversed, for a full reversal. It resolves the path without creating it.

func SubDir

func SubDir(name string) (string, error)

SubDir returns (creating if needed) a named subdirectory under Dir.

func TLDWarning added in v0.12.0

func TLDWarning(tld string) string

TLDWarning returns advice for a TLD with no reservation behind it, or "" for a reserved one. It never rejects: the choice is the user's, but a label someone else may own shadows every public name under it.

Types

type Config

type Config struct {
	// TLD is the top-level domain routed to the local proximo (without a dot).
	TLD string `json:"tld"`

	// Machine is this machine's label in its peer names.
	Machine string `json:"machine,omitempty"`
	// PeerSuffix is the multi-label suffix every peer name lives under.
	PeerSuffix string `json:"peer_suffix,omitempty"`
	// Address is the address proximo answers this machine's peer names with:
	// the machine's own address on the mesh.
	Address string `json:"address,omitempty"`
	// TeamRoot is the absolute path of the team root certificate (PEM).
	TeamRoot string `json:"team_root,omitempty"`
	// TeamRootTrusted is the SHA-1 fingerprint of the team root last installed
	// in the trust stores: what uninstall removes, and what a replaced root
	// takes out first, whether or not TeamRoot still names that file.
	TeamRootTrusted string `json:"team_root_trusted,omitempty"`
	// MeshRemedy overrides the Remedy the mesh Check offers. Stored verbatim.
	MeshRemedy string `json:"mesh_remedy,omitempty"`
}

Config holds the user-configurable settings persisted to disk.

func Default

func Default() Config

Default returns a Config populated with default values.

func Load

func Load() (Config, error)

Load reads the persisted config, returning defaults when none exists yet.

func Peek added in v0.16.0

func Peek() (Config, error)

Peek is Load for a reader that must never write the host — a Check: it creates no state home on a machine that has none.

func (Config) Save

func (c Config) Save() error

Save persists the config to disk.

Jump to

Keyboard shortcuts

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