add optional web UI: busybox httpd + shell CGI, dark theme

- /etc/init.d/wirecon-web supervises `busybox httpd` on WEB_PORT (8080).
- /var/www/wirecon: single-page UI with Status / Config / Logs tabs.
  - Status auto-refreshes every 5s: service states + wg0 endpoint,
    handshake age, MTU, rx/tx.
  - Config edits wg0.conf + wirecon.conf, saves atomically, restarts
    dependents, surfaces their output.
  - Logs tails /var/log/wirecon-{watchdog,monitor}.log.
- CGI returns plain text (key=value or raw) — no JSON-escape pain.
- HTTP Basic Auth template in /etc/wirecon/httpd.conf.
- Disable via `rc-service wirecon-web stop && rc-update del wirecon-web`.
This commit is contained in:
d4nn13 committed 2026-04-19 18:55:36 +02:00
1 parent 2d07a590e2
commit 4e7e0f34ba
12 files changed
+543 -4

No files matched your search

+32 -2
View File
@@ -6,6 +6,7 @@ WireGuard **client** tooling for an unprivileged Alpine LXC on Proxmox. Connects
- an OpenRC **watchdog** that detects stale handshakes / ping loss and re-dials fast
- a continuous **monitor** that emits structured logs for post-mortem analysis
- an **MTU probe** that finds the real path MTU via DF-ping binary search
- an optional **web UI** (busybox httpd + CGI, dark theme) for status, config editing, and log viewing — switch off anytime to save resources
The server side is intentionally out of scope — point the LXC at any existing WireGuard endpoint.
@@ -46,24 +47,29 @@ vi /etc/wirecon/wirecon.conf # PEER_IP + watchdog thresholds (optional)
rc-update add wg-quick.wg0 default && rc-service wg-quick.wg0 start
rc-update add wirecon-watchdog default && rc-service wirecon-watchdog start
rc-update add wirecon-monitor default && rc-service wirecon-monitor start
rc-update add wirecon-web default && rc-service wirecon-web start # optional
tail -F /var/log/wirecon-watchdog.log /var/log/wirecon-monitor.log
```
Then open **`http://<lxc-ip>:8080/`** in a browser.
## Layout
```
lxc/
install.sh idempotent apk + OpenRC installer (runs inside the LXC)
bootstrap.sh clones repo into /opt/wirecon then calls install.sh
etc/init.d/ OpenRC services: wirecon-watchdog, wirecon-monitor
etc/wirecon/wirecon.conf tunable thresholds (peer IP, handshake age, MTU bounds…)
etc/init.d/ OpenRC services: wirecon-watchdog, wirecon-monitor, wirecon-web
etc/wirecon/wirecon.conf tunable thresholds (peer IP, handshake age, MTU bounds, WEB_PORT…)
etc/wirecon/httpd.conf busybox httpd config (HTTP Basic Auth template)
etc/wireguard/wg0.conf.example
usr/local/bin/
wirecon-watchdog.sh one tick: handshake age + in-tunnel ping → reconnect if needed
wirecon-watchdog-loop.sh supervise-daemon target that re-runs the tick every WATCHDOG_INTERVAL
wirecon-monitor.sh long-running structured-log emitter
wirecon-mtu-probe.sh DF-ping binary search → recommended WG MTU
var/www/wirecon/ web UI assets + CGI scripts (status / config / logs)
proxmox/
create-lxc.sh host-side LXC provisioner (the one-liner above)
@@ -97,3 +103,27 @@ tail -F /var/log/wirecon-watchdog.log /var/log/wirecon-monitor.log
grep event=reconnect /var/log/wirecon-watchdog.log
awk -F'rtt_ms=' '/rtt_ms=/{split($2,a," "); print $0}' /var/log/wirecon-monitor.log
```
## Web UI
Optional. Serves at `http://<lxc-ip>:8080/` — dark theme, three tabs:
- **Status** — running/stopped state for each service, live wg0 endpoint + handshake age + rx/tx (auto-refresh every 5s).
- **Config** — edit `/etc/wireguard/wg0.conf` and `/etc/wirecon/wirecon.conf` in-browser; saving triggers a restart of the affected services and returns their stdout.
- **Logs** — tail of `wirecon-watchdog.log` and `wirecon-monitor.log`.
Runs on **busybox httpd** (~2 MiB RSS) with shell CGI — no Python/Go runtime needed. Disable anytime:
```
rc-service wirecon-web stop
rc-update del wirecon-web
```
**Security:** the UI edits `wg0.conf` (contains private keys) and restarts services, so expose it on the LAN only. Enable HTTP Basic Auth by adding a line to `/etc/wirecon/httpd.conf`:
```
# generate hash: openssl passwd -1 'your-password'
/:admin:$1$salt$hash
```
Change `WEB_PORT` / `WEB_BIND` in `/etc/wirecon/wirecon.conf` and restart `wirecon-web` to move it.