Documentation
¶
Overview ¶
Package config handles configuration file parsing, defaults, and path resolution. Config stored at ~/.config/pmux/config.toml.
Index ¶
- Constants
- func CommentedDefaultConfig() string
- func DefaultHostName() string
- func FormatEffective(cfg Config, sources ConfigSources) string
- func LoadConfigWithSources(path string) (Config, ConfigSources, error)
- type Config
- type ConfigSources
- type ConnectionConfig
- type IdentityConfig
- type Paths
- type ServerConfig
- type TmuxConfig
- type UpdateConfig
Constants ¶
const ( // DefaultServerURL is the production signaling server base URL. // Used for both HTTP endpoints and WebSocket (signaling.go converts to wss://). DefaultServerURL = "https://signal.pmux.io" // EnvServerURL is the legacy environment variable to override the signaling server URL. // Kept for backward compatibility; PMUX_SERVER_URL takes precedence if both are set. EnvServerURL = "PMUX_AGENT_SIGNAL_URL" // Environment variable names for config overrides. EnvNewServerURL = "PMUX_SERVER_URL" EnvKeyPath = "PMUX_KEY_PATH" EnvSocketName = "PMUX_SOCKET_NAME" EnvMaxConnections = "PMUX_MAX_CONNECTIONS" EnvSecretBackend = "PMUX_SECRET_BACKEND" EnvTmuxPath = "PMUX_TMUX_PATH" EnvLogLevel = "PMUX_LOG_LEVEL" EnvUpdateEnabled = "PMUX_UPDATE_ENABLED" EnvUpdateInterval = "PMUX_UPDATE_INTERVAL" )
Variables ¶
This section is empty.
Functions ¶
func CommentedDefaultConfig ¶
func CommentedDefaultConfig() string
CommentedDefaultConfig returns a well-commented default config.toml for use by `pmux init`. Values are commented out so they act as documentation without overriding defaults.
func DefaultHostName ¶
func DefaultHostName() string
DefaultHostName returns the OS hostname as a default host name.
func FormatEffective ¶
func FormatEffective(cfg Config, sources ConfigSources) string
FormatEffective returns a formatted string showing all config values with sources.
func LoadConfigWithSources ¶
func LoadConfigWithSources(path string) (Config, ConfigSources, error)
LoadConfigWithSources works like LoadConfig but also returns source annotations.
Types ¶
type Config ¶
type Config struct {
Name string `toml:"name,omitempty"`
LogLevel string `toml:"log_level,omitempty"`
Server ServerConfig `toml:"server"`
Identity IdentityConfig `toml:"identity"`
Connection ConnectionConfig `toml:"connection"`
Tmux TmuxConfig `toml:"tmux"`
Update UpdateConfig `toml:"update"`
}
Config holds user-editable Pocketmux configuration from config.toml.
func Defaults ¶
func Defaults() Config
Defaults returns the default configuration. The server URL uses https:// as the base URL; signaling.go converts to wss:// for WebSocket.
func LoadConfig ¶
LoadConfig reads the TOML config file and overlays defaults, file values, and environment variables. Returns a zero Config (not an error) if the file doesn't exist yet.
func (*Config) KeepaliveInterval ¶
KeepaliveInterval returns the parsed keepalive interval duration. Falls back to 30s if parsing fails.
func (*Config) ParseLogLevel ¶
ParseLogLevel returns the slog.Level corresponding to the configured log level. Accepted values (case-insensitive): "debug", "info", "warn", "error". Falls back to slog.LevelInfo for unrecognized values.
func (*Config) ReconnectInterval ¶
ReconnectInterval returns the parsed reconnect interval duration. Falls back to 5s if parsing fails.
func (*Config) ServerURL ¶
ServerURL returns the effective signaling server URL from the config. This replaces the old standalone ServerURL() function. The URL is resolved from: defaults → config file → env vars.
func (*Config) UpdateCheckInterval ¶ added in v0.0.7
UpdateCheckInterval returns the parsed update check interval duration. Falls back to 24h if parsing fails.
type ConfigSources ¶
type ConfigSources struct {
ServerURL configSource
KeyPath configSource
SecretBackend configSource
ReconnectInterval configSource
KeepaliveInterval configSource
MaxMobileConnections configSource
SocketName configSource
TmuxPath configSource
Name configSource
LogLevel configSource
UpdateEnabled configSource
UpdateCheckInterval configSource
}
ConfigSources records the origin of each config field for display.
type ConnectionConfig ¶
type ConnectionConfig struct {
ReconnectInterval string `toml:"reconnect_interval"` // duration string, e.g., "5s"
KeepaliveInterval string `toml:"keepalive_interval"` // duration string, e.g., "30s"
MaxMobileConnections int `toml:"max_mobile_connections"` // 1-20
}
ConnectionConfig holds connection tuning parameters.
type IdentityConfig ¶
type IdentityConfig struct {
KeyPath string `toml:"key_path"`
SecretBackend string `toml:"secret_backend"` // "auto", "keyring", or "file"
}
IdentityConfig holds Ed25519 identity path and secret storage configuration.
type Paths ¶
type Paths struct {
ConfigDir string // ~/.config/pmux
KeysDir string // ~/.config/pmux/keys
PairedDevices string // ~/.config/pmux/paired_devices.json
ConfigFile string // ~/.config/pmux/config.toml
}
Paths holds resolved filesystem paths for Pocketmux configuration and keys.
func DefaultPaths ¶
DefaultPaths returns the standard Pocketmux directory paths based on $HOME.
func (Paths) EnsureDirs ¶
EnsureDirs creates the config and keys directories if they don't exist.
type ServerConfig ¶
type ServerConfig struct {
URL string `toml:"url"`
}
ServerConfig holds signaling server configuration.
type TmuxConfig ¶
type TmuxConfig struct {
SocketName string `toml:"socket_name"`
TmuxPath string `toml:"tmux_path"` // Absolute path to tmux binary (resolved at init time)
}
TmuxConfig holds tmux-related configuration.
type UpdateConfig ¶ added in v0.0.7
type UpdateConfig struct {
Enabled bool `toml:"enabled"` // default true
CheckInterval string `toml:"check_interval"` // duration string, e.g., "24h"
}
UpdateConfig holds auto-update configuration.