config

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package config holds Phase 3 daemon TOML settings (library layer; daemon owns persistence).

Index

Constants

This section is empty.

Variables

View Source
var RestartRequiredKeys = []string{
	"listen_addr", "quic_listen_addr", "bootstrap", "api_addr", "key_dir",
	"disable_upnp", "fallback_host", "min_observed_peers",
	"ice_signal_url", "ice_signal_urls", "ice_stun_urls", "ice_turn_urls",
	"turn_servers", "ice_publish_turns", "signal_listen_addr",
}

RestartRequiredKeys lists config keys that need daemon restart after change.

Functions

func ApplyEnv

func ApplyEnv(c *Config)

ApplyEnv overlays known A2AL_* variables (subset).

func Save

func Save(path string, c Config) error

Save writes c to path as TOML (0644) via a temp-file rename for atomicity.

Types

type Config

type Config struct {
	ListenAddr       string   `toml:"listen_addr" json:"listen_addr"`
	QUICListenAddr   string   `toml:"quic_listen_addr" json:"quic_listen_addr"`
	Bootstrap        []string `toml:"bootstrap" json:"bootstrap"`
	DisableUPnP      bool     `toml:"disable_upnp" json:"disable_upnp"`
	FallbackHost     string   `toml:"fallback_host" json:"fallback_host"`
	MinObservedPeers int      `toml:"min_observed_peers" json:"min_observed_peers"`
	APIAddr          string   `toml:"api_addr" json:"api_addr"`
	APIToken         string   `toml:"api_token" json:"api_token"`
	KeyDir           string   `toml:"key_dir" json:"key_dir"`
	LogFormat        string   `toml:"log_format" json:"log_format"`
	LogLevel         string   `toml:"log_level" json:"log_level"`

	ICESignalURL  string   `toml:"ice_signal_url" json:"ice_signal_url"`
	ICESignalURLs []string `toml:"ice_signal_urls" json:"ice_signal_urls"`
	ICESTUNURLs   []string `toml:"ice_stun_urls" json:"ice_stun_urls"`
	// ICETURNURLs is the legacy TURN URL list with embedded credentials (user:pass@host).
	// Use TURNServers for new deployments.
	ICETURNURLs []string `toml:"ice_turn_urls" json:"ice_turn_urls"`
	// TURNServers lists TURN relay servers with structured credential configuration.
	TURNServers []TURNServerConfig `toml:"turn_servers" json:"turn_servers"`
	// ICEPublishTurns is deprecated; new nodes do not publish turns[] to the DHT.
	ICEPublishTurns []string `toml:"ice_publish_turns" json:"ice_publish_turns"`
	// SignalListenAddr is the TCP listen address for the embedded ICE signaling hub.
	// Empty or "off" disables the hub (default). Only enable on bootstrap/infrastructure nodes.
	// E.g. ":4121" shares the DHT port over TCP.
	SignalListenAddr string `toml:"signal_listen_addr" json:"signal_listen_addr"`
	// AutoPublish controls whether the daemon publishes the node identity to the DHT
	// on startup and on a schedule (default true). When false, the node stays off the DHT
	// as a discoverable endpoint while still participating in routing.
	AutoPublish bool `toml:"auto_publish" json:"auto_publish"`
	// BootstrapAssistMode enables passive routing and supplemental store writes for network resilience.
	// Not included in user-facing documentation.
	BeaconMode bool `toml:"beacon_mode" json:"beacon_mode,omitempty"`
	// BootstrapNodeIDs lists NodeID hex strings that bootstrap peers must match.
	// When non-empty, any bootstrap peer whose NodeID is not in this list is rejected.
	// Applies to config-supplied and DNS-discovered bootstrap addresses.
	BootstrapNodeIDs []string `toml:"bootstrap_node_ids" json:"bootstrap_node_ids,omitempty"`
}

Config is the a2ald configuration (spec Phase 3).

func Default

func Default() Config

Default returns a copy with zero values filled to spec defaults.

func LoadFile

func LoadFile(path string) (Config, error)

LoadFile reads TOML from path into a new Config merged over Default().

func (*Config) KeyDirOrDefault

func (c *Config) KeyDirOrDefault(dataDir string) string

KeyDirOrDefault returns the directory for node.key; empty KeyDir means <dataDir>/keys.

func (*Config) Validate

func (c *Config) Validate() error

Validate returns an error if fields are invalid.

type TURNServerConfig added in v0.1.4

type TURNServerConfig struct {
	URL            string `toml:"url" json:"url"`
	CredentialType string `toml:"credential_type" json:"credential_type"`
	Username       string `toml:"username" json:"username"`
	// Credential is the static password (static), HMAC shared secret (hmac),
	// or Authorization header value for the REST API call (rest_api).
	Credential    string `toml:"credential" json:"credential"`
	CredentialURL string `toml:"credential_url" json:"credential_url"`
}

TURNServerConfig is the TOML/JSON-serializable form of a TURN relay server. CredentialType selects the credential method: "static" (default), "hmac", or "rest_api".

Jump to

Keyboard shortcuts

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