Commit Graph

43 Commits

Author SHA1 Message Date
infosave d771af866c fix(awg2): mirror server obfuscation params in client config (fixes no-connect)
Clients were created successfully but could not connect: the AmneziaWG
handshake requires the client's obfuscation params (Jc/Jmin/Jmax/S1-S4/
H1-H4/I1-I5) to EXACTLY match the server's, and they did not.

Two causes, both fixed:
- syncServerKeysFromContainer() read params from `wg show` first and only
  accepted H1-H4 in the AWG-2.0 "a-b" range format, dropping the single-value
  H1-H4 used by classic AmneziaWG servers (the official Amnezia image). It
  also skipped the complete wg0.conf read once `wg show` returned partial
  data. Now the server config file (awg0.conf/wg0.conf) is the primary,
  format-agnostic source; `wg show` is a fallback that accepts single values
  and ranges.
- create() filled any param missing from the (incomplete) sync with awg2
  defaults — injecting H1-H4 ranges, S3/S4 and I1 onto a classic server that
  uses none of them. Now client params mirror the server's synced params
  verbatim; defaults are used only when nothing was synced at all. Empty
  AWG lines (params the server does not use) are stripped from the rendered
  config so the client carries exactly the server's set.

Verified end-to-end on a live server: a real amneziawg-go client built from
the generated config completes the handshake
("latest handshake: 14 seconds ago", bidirectional transfer) — params
(jc/s1/s2/h1-h4) match the server exactly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 13:41:24 +03:00
infosave 0d72579edd fix(awg2): auto-detect wg/awg tool inside container (real cause of issue #50)
Live testing against an AmneziaWG 2.0 server revealed the actual root cause
of "Failed to generate client keys": the official Amnezia container image
ships the userspace tool only as `wg` (a patched AmneziaWG binary) and has
NO `awg` binary, while the panel hardcoded `awg` for AWG2. `awg genkey` then
failed with "sh: awg: not found". (amneziawg-go ships `awg` with `wg`
symlinked, so both names work there — but the Amnezia image does not.)

- generateClientKeys(): detect the tool inside the container
  (`command -v awg || command -v wg`) instead of hardcoding `awg`.
- addClientToServer(): resolve the tool via new resolveWgTool() helper so
  `wg set` / `wg-quick up` (peer apply) also work on the Amnezia image.
- executeServerCommand(): delegate to VpnServer::executeCommand so SSH key
  auth + docker sudo auto-detection apply to all 19 call sites (it was
  password-only before).

Verified end-to-end on a live AWG2 server: pre-fix code fails with
"Failed to generate client keys: sh: awg: not found"; fixed code creates
the client, generates keys, and the peer appears in `wg show wg0`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 12:13:15 +03:00
infosave b819eb35b0 fix(awg2): resolve issue #50 client key generation and install timeout
Issue #50 (AmneziaWG 2.0 / awg2): "Failed to generate client keys" when
creating clients, and "Invalid server response" on first install.

- VpnClient::generateClientKeys() built its own password-only SSH command
  (PubkeyAuthentication=no, no sudo), bypassing VpnServer::executeCommand.
  That broke key-based servers and hosts where docker requires sudo. Route
  it through executeCommand so SSH-key auth and docker sudo auto-detection
  apply, matching every other remote operation.
- VpnClient::getNextClientIP() read /opt/amnezia/awg/wg0.conf only; AWG2
  uses awg0.conf. Read awg0.conf first, fall back to wg0.conf.
- deploy route: lift PHP time limit (set_time_limit(0) + ignore_user_abort)
  so the multi-minute awg2 docker build is not killed mid-request, which
  produced the truncated, non-JSON "Invalid server response".
- migration 070: drop `--no-cache` from the awg2 docker build so layers are
  reused, making installs and retries fast and idempotent.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-29 10:31:59 +03:00
infosave2007 f04f9dd1cb refactor: enhance SSH command handling and auto-detect sudo requirements for Docker commands 2026-04-24 16:15:04 +03:00
infosave2007 6006628f64 feat: add multi-protocol support for AWG2 with dynamic tool selection and configuration path resolution 2026-04-23 18:00:09 +03:00
infosave2007 ebcf09df08 fix: cast shell_exec output to string to prevent null pointer exceptions during split 2026-04-23 16:17:32 +03:00
infosave2007 8fd8dd092c feat: implement AIVPN host binary fallback and update installation script for prebuilt binary 2026-04-21 18:56:05 +03:00
infosave2007 7bacc94e9c feat: update QR code generation to use vpn:// format with JSON and zlib compression 2026-04-20 21:15:35 +03:00
infosave2007 c29162ddb9 feat: add support for AWG2 QR code generation and vpn:// URL configuration 2026-04-20 19:52:33 +03:00
infosave2007 08e0a3499c feat: update AWG2 configuration handling in InstallProtocolManager and VpnClient 2026-04-20 18:25:35 +03:00
infosave2007 5d88728333 feat: enhance AWG2 support with additional parameters and backward compatibility improvements 2026-04-15 20:26:48 +03:00
infosave2007 bb960645d7 feat: enhance VpnClient to support multi-protocol metadata and improve key generation error handling 2026-04-04 16:15:10 +03:00
infosave2007 1574f54bef feat: enhance AWG2 protocol handling by adding config directory management and fixing empty peer block in install script 2026-04-04 16:02:11 +03:00
infosave2007 51d5d13c41 feat: enhance SQL migration handling and add Docker installation instructions for remote servers 2026-04-04 15:48:15 +03:00
infosave2007 c38c3d1c83 feat: Add AIVPN support and enhance client statistics tracking
- Introduced AIVPN server detection and statistics fetching in ServerMonitoring.
- Implemented AIVPN client statistics handling in VpnClient, including raw and offset counters for traffic.
- Enhanced AWG parameters to include S3 and S4.
- Updated database schema to accommodate new AIVPN statistics fields.
- Added a script for remote reset and reinstallation of protocols.
- Improved client view template to ensure proper display of connection instructions.
- Added translations for connection instructions in multiple languages.
- Ensured host-level NAT for AWG subnet in VpnServer.
2026-04-04 15:27:40 +03:00
infosave2007 da72a5b3ed feat: enhance VpnClient and VpnServer for improved command execution and configuration handling 2026-04-04 12:45:04 +03:00
infosave2007 65e6a2dd0b feat: add support for awg2, mtproxy, and aivpn protocols, and implement user role-based access control. 2026-04-04 09:56:49 +03:00
infosave2007 f6a854f5ab feat: Allocate proper IP address for clients and expose getNextClientIP method 2026-02-13 20:40:04 +03:00
infosave2007 327ebd85e9 feat: Enhance online client tracking by including recent handshake counts for WireGuard/AWG 2026-02-05 19:34:02 +03:00
infosave2007 f4fa6ec941 fix: Do not inherit client_id from server protocols (prevents duplicate UUIDs) 2026-01-30 15:58:15 +03:00
infosave2007 1627fc105e fix: Prevent X-ray client UUID reuse 2026-01-30 15:38:18 +03:00
infosave2007 1c95b34cf6 feat: Enforce 1 user 1 connection for X-ray and fix active stats speed 2026-01-30 15:04:23 +03:00
infosave2007 ed2cf87418 fix(awg): reload wg0 interface after adding client to apply AWG params
Without interface reload, AWG obfuscation params (Jc, S1, S2, H1-H4) are not
applied to the kernel, and connections fail because client uses AWG but
server uses standard WireGuard protocol.
2026-01-27 15:17:16 +03:00
infosave2007 3dae76c41a fix(awg): reserve server gateway IP (.1) in client IP assignment
Previously only .0 was reserved, causing first client to get 10.8.1.1 (server IP).
Now both .0 and .1 are reserved, clients start from 10.8.1.2.
2026-01-27 15:12:49 +03:00
infosave2007 dad3aa93f4 feat: XRay Reality key backup and restoration
- Modified migrations/048_enable_xray_stats.sql to accept existing keys via env vars (PRIVATE_KEY, SHORT_ID)
- Updated InstallProtocolManager.php to extract and store reality_private_key after XRay installation
- Added key restoration logic in buildExports() to reuse saved keys during reinstallation
- Fixed VpnClient.php to correctly parse JSON stats output from XRay API
- Security fix: removed exposed port 2375 from docker-compose.yml (dind container)
2026-01-26 21:41:26 +03:00
infosave2007 a92a12073f Fix: Case-sensitive AWG params and XRay Identifier logic 2026-01-24 20:34:07 +03:00
infosave2007 86d67226d5 Fix: Client deletion UI, Enable XRay stats, fix dns_servers schema 2026-01-24 19:53:23 +03:00
infosave2007 de10268ab4 fix(qr): Generate full X-Ray Client config JSON to match Native Amnezia format 2026-01-24 14:56:13 +03:00
infosave2007 fdbb18c9df fix(qr): Pass raw VLESS URI in last_config without JSON wrapper 2026-01-24 14:50:55 +03:00
infosave2007 5097186757 fix(qr): Use raw URI for X-Ray QR codes to ensure compatibility 2026-01-24 14:35:12 +03:00
infosave2007 57e331239c feat(xray): Implement universal client addition with fallback
- Added InstallProtocolManager::addClient and fallback logic for X-Ray VLESS
  to update server configuration (server.json) and restart container.
- Updated VpnClient::create to invoke InstallProtocolManager::addClient for
  scripted protocols, enabling dynamic user addition.
- Ensured UUID generation for X-Ray clients.
2026-01-24 14:08:43 +03:00
infosave2007 dde0ff9ea1 fix(qr): Use raw VLESS URI in last_config->config
Instead of generating a JSON config for X-Ray, pass the raw VLESS URI string
wrapped in a JSON object  inside .
This matches the behavior of WireGuard config handling in the master branch
and is likely the expected format for Amnezia Android X-Ray import.
2026-01-24 13:48:57 +03:00
infosave2007 25ff0949ce fix(xray): Fix X-Ray install script and QR code generation
- Fix docker run command in install script (use single line instead of
  backslash continuations which break when stored in MySQL)
- Handle new xray x25519 output format that uses 'Password' instead of 'Public key'
- Make addClientToServer method public for backup restore functionality
- Created migration 046 with complete fix for X-Ray VLESS protocol
2026-01-24 13:03:05 +03:00
infosave2007 bbab877eac feat: ssh auth, protocol management, and cleanup 2026-01-23 17:55:40 +03:00
AmneziaVPN 69c93b2f51 Update VpnClient.php
fix new ip
2025-11-29 23:21:14 +03:00
Oleg Kirichenko 19d0e65a57 Merge pull request #4 from themgmd/master
Добавлена возможность подключить сервер с нестандартным ssh портом
2025-11-10 17:30:42 +03:00
infosave2007 2de1b58fa4 feat: implement automatic metrics collection and monitoring system 2025-11-10 15:19:36 +03:00
hasani f3751918b1 fix port 2025-11-10 13:38:07 +03:00
infosave2007 7c9136152b feat: Implement server and client metrics collection and monitoring
- Added a new PHP script for collecting server metrics every 30 seconds.
- Created a ServerMonitoring class to handle metrics collection for CPU, RAM, Disk, and Network.
- Introduced database tables for storing server and client metrics.
- Updated server view template to display real-time metrics using Chart.js.
- Added translations for monitoring UI elements.
- Created a new monitoring template for detailed server metrics visualization.
- Implemented client speed tracking and display in the monitoring UI.
2025-11-08 15:35:17 +03:00
infosave2007 932a893d69 feat: sanitize client name input to allow only letters, numbers, underscores, and dashes 2025-11-08 13:56:11 +03:00
infosave2007 b6cf9cbab7 Add traffic limit functionality
- Add traffic_limit field to vpn_clients table (migration 007)
- Add traffic limit management methods in VpnClient class
- Add API endpoints: set-traffic-limit, traffic-limit-status, overlimit
- Add UI for setting limits when creating clients
- Add traffic limit column in clients table with visual indicators
- Add automatic traffic limit check via cron (bin/check_traffic_limits.php)
- Add translations for traffic limits (6 languages)
- Update README with traffic limit documentation
2025-11-08 09:56:25 +03:00
infosave2007 1f91f17f57 Add multilingual support with translations for German, Russian, French, and Chinese
Added time limits and backup functions for servers
2025-11-08 09:14:20 +03:00
infosave2007 a33af60f2d Add project files 2025-11-07 13:34:06 +03:00