config

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MPL-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

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

Index

Constants

View Source
const WakeACPCapDefault int64 = 50000

WakeACPCapDefault is the default per-turn token cap for via=acp when the binding does not set cap. Zero in both places refuses ACP.

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 (0600) via a temp-file rename for atomicity. Before overwriting, the existing file is copied to path+".bak" so the user can restore manually if the new config causes a startup failure.

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"`
	// RequireLocalToken forces token authentication even for loopback requests.
	// Default false: loopback callers (CLI, local agents, browser on 127.0.0.1) bypass
	// token auth, since OS-level user isolation already protects the API. Set true on
	// shared/multi-user hosts where the daemon should refuse anonymous local access.
	RequireLocalToken bool   `toml:"require_local_token" json:"require_local_token,omitempty"`
	KeyDir            string `toml:"key_dir" json:"key_dir"`
	LogFormat         string `toml:"log_format" json:"log_format"`
	LogLevel          string `toml:"log_level" json:"log_level"`
	// LogDebugComponents lists subsystem names whose DEBUG-level logs are emitted
	// regardless of log_level. Useful for targeted diagnostics without enabling
	// all DEBUG output. Recognized names: "ice", "punch", "natsense".
	// Has no effect when log_level is already "debug".
	LogDebugComponents []string `toml:"log_debug_components" json:"log_debug_components,omitempty"`

	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 string (default) uses the same port as listen_addr; "off" explicitly disables.
	// E.g. ":4121" or "0.0.0.0:4121" for explicit override.
	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"`
	// OpenBrowser controls whether a2ald opens the Web UI in the default browser on startup.
	// Default true; set false for headless servers or when running as a system service.
	OpenBrowser bool `toml:"open_browser" json:"open_browser"`
	// 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"`

	// LearnedPathFirst enables learned-path outbound selection in the DHT layer
	// (lastInbound, skipCold DeferICE). Default true; set false to fall back to
	// legacy direct-UDP for emergency rollback.
	LearnedPathFirst bool `toml:"learned_path_first" json:"learned_path_first"`

	// FilesRoot, if set, sandboxes object-path registration: mapped files
	// must sit under this directory. Empty means no extra path constraint.
	FilesRoot string `toml:"files_root" json:"files_root,omitempty"`

	// DisableRelay is the node-level default for relay usage on outbound connections.
	// When true, relay (TURN) candidates are excluded unless the per-call API field
	// override enables it. Default false (relay allowed).
	DisableRelay bool `toml:"disable_relay" json:"disable_relay,omitempty"`

	// Update controls the auto-update behaviour.
	Update UpdateConfig `toml:"update" json:"update,omitempty"`

	// Wake holds optional agent-wake settings. Empty AllowedCmds means no
	// extra restriction (default). Not exposed on PATCH /config.
	Wake WakeConfig `toml:"wake,omitempty" json:"wake,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. Update.Auto is true by default.

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".

type UpdateConfig added in v0.2.4

type UpdateConfig struct {
	// Auto enables background version checks and automatic binary replacement.
	// Default true. Set false to disable automatic updates entirely; the
	// "a2ald update" CLI command still works regardless of this setting.
	Auto bool `toml:"auto" json:"auto"`
}

UpdateConfig holds auto-update settings. Only Auto is user-facing; all timing constants live in the updater package.

type WakeConfig added in v0.3.5

type WakeConfig struct {
	// AllowedCmds, when non-empty, is the executable whitelist. Bind and
	// spawn both check it. Empty / omitted = unrestricted.
	AllowedCmds []string `toml:"allowed_cmds,omitempty" json:"allowed_cmds,omitempty"`
	// AcpCap is the default ACP per-turn token cap when the binding omits cap.
	// Zero means no default; via=acp then requires a positive bind cap.
	AcpCap int64 `toml:"acp_cap,omitempty" json:"acp_cap,omitempty"`
}

WakeConfig is the optional local policy for the agent-wake bridge.

Jump to

Keyboard shortcuts

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