Add client configuration management with server connection settings
Refactor the PwrConfig struct to support the protocol-based architecture
by replacing rsync-oriented fields (NAS hostname, SSH user, rsync options)
with connection parameters for the pwr-server daemon. The new fields are
server_host for the NAS hostname or IP address, server_port defaulting to
9742, and server_psk storing a hex-encoded 256-bit pre-shared key for
HMAC-SHA256 authentication during the TLS handshake.
Certificate pinning is supported through an optional server_fingerprint
field that stores the SHA-256 hash of the server’s self-signed X.509
certificate. When set, the client rejects connections where the server
presents a certificate with a different fingerprint, preventing
man-in-the-middle attacks even if an attacker obtains a valid CA-signed
certificate for the server’s hostname.
Timeout configuration separates connection establishment (default 10
seconds) from long-running transfers (default 300 seconds) so users can
tune them independently. Path helpers provide the standard XDG config
directory layout: config.toml for connection settings, identity for the
age encryption keypair, and transactions.log for the JSONL audit trail.
The config_exists predicate lets callers check for prior initialization
without triggering the NoConfig error path. The load_config function maps
TOML parse errors into the TomlParse variant carrying the file path for
actionable error messages. A server_addr convenience method joins host
and port for use with TcpStream::connect. Three tests verify address
formatting, config path construction, and port default values.
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.