Commit Graph
30 Commits
Author SHA1 Message Date
tbenandClaude Opus 5.5 0d8daab3d0 Apply client changes to the running tunnel without a restart
Saving a client or rule restarted the whole host tunnel (wg-quick down/up)
and re-ran the firewall manager setup, which was slow and briefly dropped
every client on the host.

Client and rule changes now sync peers with `wg syncconf` and re-run the
PostUp script, skipping the firewalld/ufw step. Host creation and edits
still do a full restart.

PostUp now loads the per-host chains with `iptables-restore --noflush`, so
re-running it on a live tunnel swaps the rules atomically instead of
leaving the chains empty between flush and re-add.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-03 08:30:41 +01:00
tbenandClaude Opus 5.5 77ced6cc52 Add editing of client access rules
Saved rules and client form drafts can now be edited through the rule
modal. On the Rules tab, saving re-runs client setup so the firewall
matches, and both add and edit ask for confirmation.

Comma-separated destinations were rejected because drafts were validated
before being split; validate each one after splitting instead. When
editing, the first destination updates the rule and the rest are added
as new rules.

Pin the id in the client_rules PUT handler so a request body can't
change it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 14:27:10 +01:00
tben cbd5451ab7 Run the Caddy TLS ingress as a Docker container
Caddy previously ran as a host binary in /opt/caddy with a wgui-caddy
systemd/OpenRC unit. Only Caddy is containerized; the app still runs on the
host as root because it shells out to wg, ip and iptables.

- Add caddy-container-commands.ts as the single source of truth for the
  run/exec/validate/inspect argument arrays. Every value stays a separate
  argv element, the image is pinned to caddy:2.11.4-alpine, and the
  entrypoint is set explicitly because some mirrors publish the image with
  a null Entrypoint (which made Docker exec "run" as a binary).
- Rewrite install-caddy.sh: require_docker with distro-specific hints,
  pull + recreate the container, assert it is running and echo the daemon
  error instead of discarding it, normalize the admin socket path in
  existing Caddyfiles, and clean up a legacy native install only after the
  container is up so the ingress port is never unbound. Add
  --purge-legacy / --purge for hosts that want to drop the old install
  without installing the container.
- Move the admin socket to /var/lib/wgui/caddy/admin.sock so it lives
  inside the mounted Caddy dir and reloads work over docker exec.
- Validate candidate configs in a throwaway container, mounting the TLS
  dir read-only as well: provisioning the tls app loads every certificate
  referenced by a tls directive, so without that mount a route with a
  certificate failed validation and its Caddyfile was never committed.
- Report docker-based installed/version/service_active, skip
  validate/reload with a warning when the image is absent, and update the
  system setup tool check to look for docker.
- Issue certificates with a docker exec reload command and chown files to
  root:root, since the container reads them through a read-only mount.
- Update the Setup UI copy and docs (README, AGENTS.md).

Also drops the unused EmptyContent import and a stray debug log in the
client route form, and stops passing the unsupported cancel_href prop to
ClientRouteForm from the route add/edit pages.
2026-10-21 14:34:16 +01:00
tben 42feb73264 Update Reverse proxy and TLS configuration on Caddy 2026-10-21 13:01:33 +01:00
tben ed4a6f3ec8 Add TLS feature with Caddy 2026-10-21 09:13:59 +01:00
tbenandClaude Opus 5.5 fe4b1b02d1 Remove unused dependencies and dead code, refresh AGENTS.md
- Drop unused email module and media text extraction path
- Remove 12 unused dependencies
- Remove unused imports in server.ts
- Add typecheck and test scripts
- Rewrite AGENTS.md to describe this project

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-15 21:09:27 +01:00
tbenandClaude Opus 5.5 617400c19f Enforce client ownership in clients CRUD put/post
Non-super-admin PUT updated the client whose id equalled the user's id;
it now updates the requested client only if the user owns it. POST no
longer lets non-super-admins overwrite existing clients by id.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-15 21:09:27 +01:00
tbenandClaude Opus 5.5 cd707465f4 Harden admin API routes and shell usage
- Require admin auth on interface-local-ip, network-interfaces,
  next-listen-port and public-ip (interface-local-ip and public-ip
  allowed unauthenticated command injection as root)
- Validate interface names and call ip/curl via execFileSync
- Write host/client WireGuard configs with fs instead of shell
  heredocs, validating IPs, AllowedIPs, endpoint and listen port
- Replace rm -rf/cat/mkdir/chmod/test shell calls with fs APIs
- Refuse private media requested through the public media route

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-15 21:09:27 +01:00
tbenandClaude Opus 5.5 178f98104c Fix type-check after bun-sqlite 1.2.0 upgrade
Import types from @moduletrace/bun-sqlite/types now that the package
has an exports map, and guard optional ctx.props in signup server fn.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-15 21:09:27 +01:00
tben dbae73a746 Add firewall rules logic for all hosts 2026-09-27 14:25:27 +01:00
tben 8ed5fd1845 Update clients fetch function 2026-09-27 06:59:16 +01:00
tben 400831246f Fix iptables internet forwarding bug. Update UI errors. 2026-09-27 06:08:07 +01:00
tben a681354eab Update host update form for main host (host 0) 2026-09-20 20:48:47 +01:00
tben f05384d8fe Add admin setup page 2026-09-20 18:15:51 +01:00
tben aa0a292943 Updates 2026-09-20 17:04:17 +01:00
tben 69111e461e Refactor main host setup 2026-09-20 15:37:57 +01:00
tben 3c1d2b61f6 Update hosts form 2026-09-20 13:48:35 +01:00
tben a9ebd8fb75 Update hosts form 2026-09-20 12:51:12 +01:00
tben 8b40a876a1 Add public IP field and Network interface to host form 2026-09-20 12:22:54 +01:00
tben 25b64281f8 Add user change password 2026-09-20 11:48:02 +01:00
tben 6e3319b21c Updates 2026-09-20 10:49:14 +01:00
tben 3d122036ce Fix secure cookies bug 2026-09-20 07:33:43 +01:00
tben 8ec44ee0a7 Updates 2026-09-20 07:27:29 +01:00
tben d5536b49d9 Updates 2026-09-20 04:14:32 +01:00
tben cda6cff34f Complete client form 2026-09-17 08:43:00 +01:00
tben e0d105beb9 Major updates 2026-09-14 07:56:13 +01:00
tben ad94385bcb Improve wg-ui host setup: IP availability checks and current-user install script
- setup-main-host-button: live availability status, grab-next-subnet helper, error/success feedback
- setup-wireguard-host: harden generated shell scripts with set -e
- check-private-ip-address-availability: add user access check, drop manual body validation
- setup-main-host: pass host object with wg_ip_address
- install-wg-ui.sh: run service as the invoking user (root or sudo) instead of a dedicated wgui user, and skip systemd/OpenRC daemon setup when NODE_ENV=development
2026-09-13 11:43:26 +01:00
tben 86eb3a0b05 Add host setup functions and client components 2026-09-13 10:52:30 +01:00
tben 9cfbde9c9a Update login pipeline. Limit login to only password 2026-09-12 14:20:07 +01:00
tben 4d75af0418 First Commit 2026-09-12 13:56:36 +01:00