Complete terminal management workflow

This commit is contained in:
2026-10-21 23:25:31 +03:00
parent f718f739b4
commit 2ccd67d64c
19 changed files with 7313 additions and 53 deletions
+69 -20
View File
@@ -1,13 +1,13 @@
# wireguard-admin
This repository contains the Rust package, startup boundary, validated settings
loader, client domain model, a byte-preserving WireGuard configuration editor,
encrypted client vault and read-only import APIs, recoverable saved-file
persistence, private backups, Commit, and previewed full restore. The library
also provides read-only WireGuard runtime observation, technical peer comparison,
bounded systemd restart handling, and explicit restart orchestration. The
terminal management interface is not implemented, and management startup is not
connected to these library operations.
This repository contains a root-only native terminal interface for one existing
WireGuard interface and configurable systemd service. It connects the validated
settings loader, byte-preserving server configuration editor, encrypted client
vault, recoverable saved-file persistence, backups, Commit, previewed restore,
explicit restart, read-only runtime statistics, and client file/QR delivery.
The interface keeps draft, saved, and applied states distinct. Commit saves
files; restore replaces saved state; only an explicit, verified restart applies
saved changes to the running interface.
The package requires Rust 1.97.1 or newer and uses the Rust 2024 edition. From
the repository root, run:
@@ -17,9 +17,11 @@ cargo run -- --help
cargo run -- --version
```
`--help` and `--version` work without root. Starting with no arguments requires
root; until the management interface is implemented, startup exits with an
error and does not read server configuration or vault files.
`--help` and `--version` work without root, settings, or a terminal. Starting
with no arguments requires root and a suitable interactive terminal. Settings
are read from `wireguard-admin.toml` beside the executable. If terminal checks
or saved-state recovery fail, startup exits before entering raw mode or
performing setup mutations.
## Settings
@@ -46,6 +48,32 @@ absolute. Settings validation checks syntax and values only; it does not
require the referenced files, directories, or service to exist and does not
perform DNS lookups.
## Terminal workflows
The client list supports arrow-key selection, Enter for details, `?` for help,
and `q` to exit. Exit warns when a draft would be discarded; it never commits
implicitly. From the list or details screen, the current shortcuts are:
| Key | Action |
| --- | --- |
| `n` | Create a client with automatic or manual dual-stack addresses |
| `r` / `d` | Rename or delete the selected supported peer by full public key |
| `p` / `x` | Review or discard the draft |
| `c` | Commit saved files after the mandatory backup |
| `R` | Preview explicit restart; confirm only after reviewing the choice |
| `o` / `O` | First file delivery / password-per-action reissue |
| `b` / `B` | List and preview backups / create a manual backup |
| `s` / `i` | Initial vault setup / import one selected client file |
| `!` | Inspect document and peer anomalies |
Forms use Enter to advance or submit, Tab to change fields/options, and Esc to
cancel. Backup restore previews identify the selected archive and require an
explicit confirmation. Restore does not prompt for the vault password and does
not restart WireGuard. Client configuration output is a disclosure: first
delivery requires a successful Commit in the same session; QR appears only
after file publication. Esc closes and clears a QR disclosure. Help in the
interface contains the full current shortcut list.
## Library configuration API
The library exposes `wireguard_admin::wireguard::ConfigDocument` for UTF-8
@@ -69,12 +97,10 @@ let updated = document.rename_client(&public_key, "office laptop")?;
let bytes_to_review = updated.render(); // no persistence or VPN operation
```
Management startup still exits with an explicit “not implemented” error after
its root check. Runtime and restart library behavior is covered with synthetic
fixtures and fake adapters; it has not been validated against a real WireGuard
interface or systemd service. Real WireGuard integration is deferred to the
isolated Alpine milestone, and real systemd/D-Bus acceptance requires the
disposable VM milestone.
Runtime and restart behavior has synthetic fixture and fake-adapter coverage;
it has not been accepted against a real WireGuard interface or systemd service.
Real WireGuard integration is deferred to the isolated Alpine milestone, and
real systemd/D-Bus acceptance requires the disposable VM milestone.
## Saved state, Commit, and backups
@@ -137,7 +163,30 @@ plaintext client files as a fallback. The result reports a secret-free failure
stage and warns when the current saved peer set has not been verified as applied
in this live session. Historical verification timestamps do not suppress that
warning after reopen. File output uses mode `0600`, explicit overwrite
confirmation, and separate QR failure reporting. These APIs have synthetic
fixture coverage; the TUI password prompt and terminal QR rendering are not
implemented.
confirmation, and separate QR failure reporting. These APIs and the TUI
password prompt/terminal QR display have synthetic fixture coverage. No
production configuration or key is included in the repository.
## Test commands and integration limits
Run the default synthetic workflow and UI checks as an unprivileged user:
```sh
cargo test --locked --test tui_workflow
cargo test --locked tui::
```
The first exercises setup, client staging, Commit, delivery, backup listing,
and restore through the serialized worker with temporary files and a fake
statistics reader. The second covers navigation/forms/rendering, delayed worker
behavior, terminal lifecycle seams, and QR sizing. Neither command starts the
management UI or uses host service/runtime mutation. See
[`docs/TESTING.md`](docs/TESTING.md) for full gates and the isolated Alpine
(M8) and disposable systemd VM (M9) boundaries. An actual PTY smoke run using
synthetic application/runtime adapters is included in `tui_workflow`; it uses
`script` and a fake unavailable-statistics reader, without root or host settings.
It checks an 80×24 to 40×8 to 80×24 resize sequence and terminal cleanup after
`q`. The workflow also checks that Esc clears a returned QR disclosure; the
focused renderer test checks complete quiet-zone fit. Do not use the development
host's settings or VPN as a substitute.