This repository has been archived on 2026-11-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
WGTools-Extended/README.md
T
asminme affe28ad71
Wydanie WGTools-Extended / release (push) Failing after 16s
1.0.0
2026-10-30 00:35:08 +01:00

312 lines
20 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# WGTools-Extended
Projekt jest w trakcie rozbudowy na podstawie WGTools. Aktualizator oryginalnego projektu jest odłączony.
Konta istniejące przed rozbudową zachowują rolę administratora. Pierwsze konto jest administratorem, a kolejne są tworzone bez dostępu do sieci. Administrator przypisuje dostęp do sieci oraz osobno zezwala na dodawanie klientów, edycję klientów i zarządzanie przekierowaniami. Mechanizm uprawnień jest w trakcie weryfikacji i nie powinien jeszcze być używany jako zabezpieczenie produkcyjne.
Na stronie serwera można ustawić podstawowy adres IPv4 SNAT dla wybranej sieci. Adres musi być przypisany do wskazanego interfejsu. Zapis restartuje działający interfejs WireGuard i może na chwilę rozłączyć klientów.
Można też ograniczyć przychodzący ruch UDP WireGuard do adresu IPv4, interfejsu wejściowego albo obu jednocześnie. Przy aktywnym ograniczeniu ruch IPv6 na ten port jest blokowany. Zmiana restartuje działający interfejs.
Workflow Gitea tworzy wydanie dla tagu `vX.Y.Z`, zgodnego z plikiem `VERSION`. Korzysta z runnera `docker-builder` oraz wymaga sekretu repozytorium `GITEA_RELEASE_TOKEN` z prawem tworzenia wydań. Plik `.bin` jest archiwum źródłowym gzip i można go wgrać w ustawieniach. Pakiety nie są podpisywane; administrator musi sam sprawdzić ich pochodzenie. Aktualizacja tworzy kopię zapasową i w razie błędu próbuje przywrócić poprzednią wersję.
Administrator przypisuje publiczne IPv4 do grup i sieci. Użytkownicy danej sieci mogą przekierować TCP, UDP lub oba protokoły z przypisanego adresu na adres klienta tej sieci. Program odrzuca konflikty między swoimi przekierowaniami i sprawdza lokalne nasłuchujące usługi; ręczne reguły zapory trzeba sprawdzić osobno. Zmiana przekierowania restartuje działający interfejs.
# WGTools — WireGuard Web UI & Server Management Panel
**WGTools** is an open-source, self-hosted **WireGuard web UI and server management panel** for **Debian and Ubuntu**. It provides a browser-based WireGuard GUI for day-to-day administration without manually editing `wg-quick` configuration files for routine tasks.
WGTools combines WireGuard installation and multi-interface management, clients and Site-to-Site peers, routing/NAT/firewall policy, VPS Relay, multi-server Nodes, monitoring, TOTP MFA, traceroute/ping route diagnostics, backups, scheduled access, HTTPS, Telegram administration and safe application updates in one UI.
> **Security note:** WGTools performs privileged network administration and its services run as `root`. The bundled web service starts on HTTP port `8341` by default. For Internet-facing installations, enable **Settings → HTTPS** to obtain a Let’s Encrypt certificate and move WGTools directly to a selected HTTPS port and a private access path, or place `8341` behind your own reverse proxy. Do not expose plain HTTP `8341` directly to the public Internet.
[Русская версия README](README.ru.md)
## Supported systems
WGTools supports **Debian and Ubuntu** hosts using `apt` and `systemd`.
The installer and VPS Relay preflight expect the normal Debian/Ubuntu networking toolchain (`iproute2`, `iptables`, `wg`/`wg-quick`, Python 3 and systemd). WireGuard itself can be installed from the WGTools Server page on a clean host.
## Screenshots
<details>
<summary><strong>Show WGTools screenshots</strong></summary>
<br>
### Getting started
#### First-user setup
![WGTools WireGuard web UI first-user setup](docs/screenshots/first-user-setup.png)
### Dashboard and monitoring
#### Dashboard with multiple WireGuard interfaces
![WGTools WireGuard dashboard and interface selector](docs/screenshots/dashboard-interface-selector.png)
### Server management
#### Multiple WireGuard interfaces
![WGTools server manager with multiple WireGuard interfaces](docs/screenshots/server-multi-interface.png)
### Clients and Site-to-Site
#### Client list
![WGTools WireGuard clients and peer status](docs/screenshots/clients-list.png)
#### Create a WireGuard client
![WGTools create WireGuard client dialog](docs/screenshots/create-client.png)
#### Create a Site-to-Site peer
![WGTools create WireGuard Site-to-Site peer dialog](docs/screenshots/create-site-to-site.png)
### Settings and CLI
#### General settings
![WGTools settings for theme language and status refresh](docs/screenshots/settings-general.png)
#### Root management console
![WGTools root CLI management console](docs/screenshots/wgtools-cli.png)
</details>
> Screenshots contain lab/example values. Never publish private keys, real client configuration QR codes, passwords, tokens or `.wgtbackup` contents.
## Highlights
### WireGuard server and interfaces
- Install WireGuard from the UI on a clean Debian/Ubuntu host.
- Create the first server (`wg0`) with an optional friendly **Display name**.
- Default first VPN pool: `10.0.0.0/24`, server address `10.0.0.1/24`.
- Add independent `wg1`, `wg2`, … interfaces with automatic suggestions for a non-overlapping pool, free UDP port and policy table. With the default layout, `wg1` is suggested as `10.0.1.0/24`.
- Global top-bar interface selector; Dashboard, Server, Clients and raw config follow the selected interface.
- Start, restart and stop the selected WireGuard interface.
- Internal Relay transport interfaces (`wgrly*`) are intentionally hidden from normal interface management.
### Routing, NAT and firewall
- IPv4 forwarding and NAT/MASQUERADE management.
- Uplink interface, gateway and local-network settings.
- Optional source policy-routing table per WireGuard interface.
- Managed static/site-to-site routes.
- Server access policy with tagged WGTools firewall rules and live reconciliation.
- Raw `/etc/wireguard/<interface>.conf` editor with validation, backup and rollback protection.
### Clients and site-to-site peers
- Normal WireGuard clients and site-to-site peers.
- Per-client VPN isolation from other WireGuard pool addresses without blocking access to the server itself, LAN, Site-to-site destinations or Internet allowed by the other policies.
- Automatic free VPN-address suggestion.
- Generated `.conf` files and QR codes for WGTools-managed clients.
- Optional PresharedKey (PSK).
- One safe **Rotate keys** action regenerates PrivateKey/PublicKey and also regenerates PSK when PSK is enabled; address, routes, group/policies, expiration/schedule, isolation, last seen and accumulated traffic are preserved, and a new config/QR must be issued afterward.
- PersistentKeepalive and DNS settings.
- Route presets: full tunnel, full tunnel except protected local networks, VPN + local networks, VPN only and custom routes.
- Per-client local-network exceptions and server-side access policy.
- Client groups with reusable policies/defaults and per-client overrides.
- Temporary clients with 1/3/6 hour, 1 day or custom expiration.
- Recurring access schedules by weekday and time, including overnight windows such as `22:00–06:00`.
- Live peer create/edit/delete via `wg syncconf` without restarting the whole interface during normal peer operations.
### VPS Relay
WGTools can use a public Debian/Ubuntu VPS as a WireGuard UDP Relay when the real WGTools server is behind NAT or otherwise hard to reach directly.
```text
WireGuard client
│ encrypted client WireGuard packets
▼
Public VPS Relay Agent
│ protected Home ↔ VPS transport
▼
WGTools / real WireGuard server
├── local networks
└── Internet (when the client policy allows it)
```
The Relay is a transport layer: it does **not** terminate the client's WireGuard session and does not become a separate Internet-exit VPN server. The real WireGuard server remains the WGTools host.
Relay features:
- SSH preflight before installation: OS, privileges, tools and UDP-port checks.
- Password and pasted SSH private key are used only for the current operation and are not stored by WGTools.
- One Relay Agent can keep multiple isolated tenants for different WGTools controllers.
- One WGTools installation can register multiple VPS Relay endpoints and assign clients to a selected Relay.
- Existing Relay Agent installations are reused instead of overwritten; free tenant UDP ports are selected automatically.
- Protected management/transport tunnel with health information.
- **Remove VPS** detaches the Relay from the local WGTools installation but intentionally leaves the remote tenant intact for disaster recovery.
- Adding the same VPS again can reconnect the existing tenant instead of creating another one.
- Migration restore can rebuild the home side of a preserved Relay from the restored WGTools state.
### WGTools Nodes
WGTools installations can be linked through a hidden `wgnode0` Hub-and-Spoke WireGuard network. The HUB uses one Nodes port number for **UDP WireGuard** and **protected TCP pairing**; when the HUB is behind NAT, forward that port for both protocols.
- Spoke setup needs only a node name, HUB `host:port`, one-time code and optional additional routed networks.
- The one-time code pins the HUB Node-control certificate fingerprint before its secret is sent.
- After pairing, topology, status, version and read-only remote-client data synchronize only through `wgnode0`, not through the WGTools web URL.
- Local interface VPN pools and configured Site-to-Site peer remote networks are published automatically; Site-to-Site publication is based on configuration and does not disappear when that peer is offline.
- Ordinary WireGuard clients of a remote Node can access locally published networks without return routes on each LAN router; WGTools applies narrow return-path NAT only to remote VPN client pools.
- The optional panel URL is informational metadata for **Open panel** and may change independently without breaking Nodes.
- Full `.wgtbackup` migration/restore preserves the HUB Node-control identity used by already-paired Spokes.
### Dashboard and monitoring
- WireGuard state, selected-interface address/port, peer counts and durable lifetime handshake/RX/TX statistics. Traffic counters survive WireGuard/host restarts and can be reset manually from the Dashboard.
- CPU, memory and network-rate metrics.
- Rolling 24-hour graphs with minimum/average/maximum summaries.
- Search/filtering for peer lists.
- Dedicated **Server → Trace** diagnostics with ping + traceroute, per-hop RTT/loss, latency-jump highlighting and an interactive OpenStreetMap route view with pan/zoom and clickable hops.
### Terminal console
Run `wgtools` as root to open the local boxed management menu. It shows the current panel URL/private HTTPS path plus WGTools, WireGuard, Nodes, Telegram, timers and local Relay Agent status, and provides panel controls, WireGuard status/start/stop/restart actions, logs, HTTP rescue, emergency MFA disable for a selected user, and two clearly separated removal paths: a soft uninstall that preserves WireGuard/reusable data and a destructive FULL CLEANUP.
### HTTPS
- Optional built-in HTTPS without Nginx/Caddy/Traefik: WGTools can serve TLS directly with Uvicorn on a user-selected TCP port (`443` by default).
- Let’s Encrypt certificates can be requested for a domain or a public IP address. IP certificates use Let’s Encrypt’s short-lived profile and therefore depend on automatic renewal.
- Certificate issuance/renewal uses Certbot standalone validation, so TCP `80` must be reachable from the Internet while ACME validation runs.
- WGTools checks local TCP `80` plus the selected HTTPS port before issuance/enabling and never stops or replaces an unrelated web server.
- Automatic renewal is enabled with a dedicated systemd timer while built-in HTTPS is active; successful renewal reloads WGTools.
- Built-in HTTPS requires an administrator-defined panel path such as `/MyPrivateWGToolsPath/`. Requests outside that prefix receive `404`; authentication is still required normally inside the path.
- Settings shows the `fullchain.pem` and `privkey.pem` paths with copy buttons so the same certificate files can be referenced by other software on the host.
- Built-in HTTPS can be disabled to return WGTools to its normal HTTP port when a user prefers NPM, Caddy, Traefik or another reverse proxy.
### Authentication, mail and Telegram
- First-run admin creation and local WGTools user management with optional per-user e-mail addresses.
- Optional per-user TOTP MFA compatible with **Google Authenticator**, 2FAS, Aegis and other standard authenticator apps. Enrollment uses a QR code (with a manual setup key fallback), and WGTools generates one-time recovery codes. Root can emergency-disable MFA from the local `wgtools` CLI if the authenticator device and recovery codes are lost.
- Optional SMTP password recovery with STARTTLS/TLS/plain SMTP support, a one-time 6-digit code valid for 15 minutes, request/attempt limits, and identical public responses that do not reveal whether an account exists. Password changes invalidate older sessions for that user.
- Administrators can send a reset code directly from Settings → Users; SMTP configuration and test delivery live under Settings → Mail.
- Passwords stored as salted PBKDF2-HMAC-SHA256 hashes.
- Optional Telegram Bot with an allow-list of numeric Telegram user IDs.
- Telegram status, interface selection, client creation/removal and config/QR re-issue. WireGuard Start/Restart/Stop controls are grouped under a dedicated **Server** item beside **Interface**. Navigation appends new bot messages without overwriting earlier screens, keeping the recent history available for reuse. After sending a config/QR, the refreshed client picker appears below the files; destructive confirmations are bound to the current prompt. Cyrillic client names receive readable transliterated `.conf` filenames instead of the generic fallback.
### Audit
- **Settings → Audit** opens a searchable audit journal with timestamp, actor, action, object and result.
- Web changes record the local WGTools username. Telegram state-changing actions record `@username` when available and always include the numeric Telegram user ID.
- The Telegram menu has a read-only **Audit** shortcut and `/audit` command; browse the latest 20 events and older/newer pages (including changes made by other WGTools administrators).
- Telegram client create/delete, explicit config/QR re-issue and WireGuard Start/Stop/Restart actions are audited; meaningful failures and denied mutating attempts are recorded without logging ordinary menu navigation or read-only status views.
- WireGuard client connection history records client name, time and endpoint IP when a client connects after a meaningful offline gap or its endpoint IP changes.
- The last successful client handshake is kept as durable last-seen state, so restarting the host or WireGuard interface does not turn a previously connected client into `Never`.
- Application updates audit the safety `.wgtbackup`, successful completion, useful failures and automatic rollback results.
- Audit retention is 30 days with a 10,000-row safety cap.
- Passwords, reset codes, WireGuard private keys, PSKs, Telegram Bot tokens, SMTP passwords, Relay `control_token`, SSH credentials, full client configs and QR contents are redacted or never written.
### Backups and disaster recovery
WGTools has two backup layers:
1. **Automatic configuration history** before configuration-changing operations.
2. **Portable `.wgtbackup` migration/disaster-recovery archive**.
A full `.wgtbackup` can include:
- all detected WireGuard interface configs and their running/stopped state;
- WGTools SQLite database with users/e-mail addresses, preferences, SMTP settings and VPS Relay records;
- managed client metadata, client private keys and PSKs;
- client groups, schedules/expiration state and interface display-name metadata;
- Telegram configuration/token and SMTP credentials when configured;
- forwarding sysctl state;
- Relay controller/tenant identity, management token and home transport key needed to reconnect a preserved remote Relay tenant.
The remote VPS filesystem itself is not copied into `.wgtbackup`; for transparent Relay disaster recovery, the Relay Agent/tenant must still exist on that VPS.
> Let’s Encrypt certificate lineages under `/etc/letsencrypt` are host-level files and are not copied into `.wgtbackup`. After migrating WGTools to another host, request the built-in HTTPS certificate again. A normal WGTools uninstall intentionally leaves `/etc/letsencrypt` untouched so an existing certificate can still be used by other software.
> `.wgtbackup` files contain secrets, including saved SMTP credentials when configured. Protect them like passwords or private SSH keys and never attach one to a public issue.
### Aktualizacje
Administrator wgrywa zaufany pakiet `.bin` w ustawieniach. Przed instalacją powstają kopia danych i archiwum aplikacji. W razie błędu program próbuje przywrócić poprzednią wersję. Aktualizacje online oryginalnego projektu są odłączone.
## Quick install
```bash
sudo bash install.sh
```
The local installer runs [`scripts/install.sh`](scripts/install.sh) from the checked-out source tree.
Open the printed URL (normally `http://SERVER-IP:8341`) and create the first WGTools account.
WireGuard is intentionally not installed silently by the bootstrap installer. On a clean server, use **Server → Install WireGuard**.
### Inspect before installing
```bash
# Pobierz kod WGTools-Extended z własnego repozytorium.
cd WGTools
less install.sh
less scripts/install.sh
less scripts/wgtools-helper
sudo ./scripts/install.sh
```
To install a specific public release:
```bash
git checkout v0.40.4
sudo ./scripts/install.sh
```
## Installed paths
| Path | Purpose |
|---|---|
| `/opt/wgtools` | Application source and Python virtual environment |
| `/var/lib/wgtools` | SQLite database, session secret, managed client state, backups and Relay home-side metadata |
| `/etc/wgtools/wgtools.env` | Runtime environment settings |
| `/usr/local/libexec/wgtools-helper` | Privileged helper used by the web application |
| `/etc/systemd/system/wgtools*.service` | WGTools web/Telegram/expiry services |
| `/etc/wireguard/*.conf` | User-managed WireGuard interface configurations |
| `/var/lib/wgtools-relay` | VPS Relay Agent state when this host is used as a Relay VPS |
| `/opt/wgtools-relay` | VPS Relay Agent code when this host is used as a Relay VPS |
WGTools does not create an additional Linux user. The services run as root because they manage WireGuard, routes, firewall state and protected configuration files.
## Network and privacy
WGTools has no analytics, advertising or application telemetry to the project maintainer. It does not upload your WireGuard keys, peer list, local topology, users or traffic counters.
Expected outbound connections are limited to enabled features:
- **Gitea:** releases are published by the project workflow; updates are uploaded manually by the administrator.
- **Telegram:** only when Telegram Bot integration is enabled.
- **APT repositories:** package installation on Debian/Ubuntu.
See [PRIVACY.md](PRIVACY.md) and [SECURITY.md](SECURITY.md).
## Uninstall and complete cleanup
Removal is built into the root `wgtools` console, so routine uninstall/cleanup does not require copying shell commands from the documentation.
The CLI provides two deliberately separate actions:
- **Uninstall WGTools** — removes the panel, services, CLI and internal Nodes/local Relay-home transports while preserving normal WireGuard and reusable WGTools state for reinstall/recovery.
- **FULL CLEANUP** — destructive cleanup for a dedicated host. It removes WGTools state/backups, Nodes, local Relay state, WireGuard interfaces/configuration and WireGuard packages. It requires typing `DELETE ALL` before execution. Remote Relay VPS hosts are never contacted automatically.
Run the local management console as `root` with `wgtools` and choose the required removal action from the **Removal** section.
## Security
WGTools is a privileged administration application. Before exposing it outside a trusted network, read [SECURITY.md](SECURITY.md).
For security reports, do not publish private keys, `.wgtbackup` archives, passwords, bot tokens or production configuration in a public issue.
## License
See [LICENSE](LICENSE).