[PR #5458] [CLOSED] feat(wireguard): manage WireGuard peers as clients on the Clients tab #5887

Closed
opened 2026-11-02 04:04:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5458
Author: @mrAntonD
Created: 6/21/2026
Status: ❌ Closed

Base: main ← Head: main


📝 Commits (10+)

  • 1e9290f feat(wireguard): manage WG peers as clients on the Clients page
  • 67ed0c8 fix(wg): fix peer data loss, delete error, QR/info for WireGuard clients
  • 053200e feat(wg): show config text and download button in QR modal
  • f7c09e4 fix(wg): next IP suggestion, QR public key, and malformed JSON on add
  • 236e49c fix(wg): toggle enable/disable and show config in QR modal
  • 9231c00 feat(wg): download config in info/edit modals, preserve wgPeer on hydrate
  • fe18197 feat(wg): hide subscription/links blocks for WireGuard clients
  • 13ff78a perf(wg): patch peers[] in-place instead of full DB rebuild on add/update/del
  • f4317c9 fix(ci): register WgPeerSettings in codegen and document WG client endpoints
  • 962b9a3 fix(ci): regenerate openapi.json after adding WG client endpoint docs

📊 Changes

28 files changed (+1777 additions, -494 deletions)

View changed files

📝 frontend/public/openapi.json (+233 -2)
📝 frontend/src/generated/examples.ts (+12 -2)
📝 frontend/src/generated/schemas.ts (+39 -1)
📝 frontend/src/generated/types.ts (+9 -0)
📝 frontend/src/generated/zod.ts (+10 -0)
📝 frontend/src/hooks/useClients.ts (+3 -0)
📝 frontend/src/pages/api-docs/endpoints.ts (+31 -0)
📝 frontend/src/pages/clients/ClientFormModal.tsx (+293 -110)
📝 frontend/src/pages/clients/ClientInfoModal.tsx (+175 -96)
📝 frontend/src/pages/clients/ClientQrModal.tsx (+111 -13)
📝 frontend/src/pages/clients/ClientsPage.tsx (+33 -2)
📝 frontend/src/pages/inbounds/form/InboundFormModal.tsx (+1 -7)
📝 frontend/src/pages/inbounds/form/protocols/wireguard.tsx (+3 -123)
📝 frontend/src/pages/inbounds/info/InboundInfoModal.tsx (+11 -84)
📝 frontend/src/pages/inbounds/useInbounds.ts (+15 -2)
📝 frontend/src/schemas/client.ts (+9 -0)
📝 internal/database/model/model.go (+47 -22)
📝 internal/web/controller/inbound.go (+92 -0)
📝 internal/web/service/client_crud.go (+70 -6)
📝 internal/web/service/client_link.go (+3 -0)

...and 8 more files

📄 Description

Summary

  • WireGuard peer management moved to Clients tab: peers are now created/edited/deleted from the Clients page like any other protocol; the Inbounds form retains WG settings (key, MTU, etc.) but the peer list is removed from it
  • Auto-migration on upgrade: existing settings.peers[] are migrated to the clients table on first startup — no data loss
  • Peer count on Inbounds tab: WireGuard inbounds now show active peer count

Key changes

Backend

  • model.go — WgPeerSettings struct + wg_settings column on ClientRecord; MarshalJSON/UnmarshalJSON expose it as wgPeer in API responses
  • client_wg_apply.go — AddWgClient, UpdateWgClient, DelWgClient: full CRUD; each mutation rebuilds settings.peers[] from the clients table
  • client_wg_peers.go — syncWgPeersFromClients, wgPeerToRecord, SyncWgInbound
  • inbound.go — UpdateInbound preserves settings.peers[] when the form omits them; inboundWgPublicKey derives server public key from secretKey via curve25519; GetInboundOptions exposes wgPublicKey
  • client_crud.go — Delete() routes WG inbounds through DelWgClient (fixes "invalid clients format" error)
  • client_paging.go — ClientSlim includes wgPeer so next-IP suggestion works from the paged list
  • inbound_migration.go — MigrateWgPeers syncs existing peers to clients table on startup
  • inbound.go controller — WG CRUD endpoints under /panel/api/inbounds/wg/

Frontend

  • ClientFormModal — WG fields (public/private key, PSK, allowed IPs, keepalive) when WG inbound selected; irrelevant fields hidden; auto-suggests next sequential IP
  • ClientQrModal — generates WireGuard .conf ([Interface] + [Peer]); supports .conf download
  • ClientInfoModal — WG-specific fields shown; non-applicable ones hidden
  • useInbounds — WireGuard added to TRACKED_PROTOCOLS; peer count read from settings.peers

Test plan

  • Existing WG inbound: open Clients tab, verify peers migrated automatically
  • Add new WG peer: form shows WG fields, auto-suggests next available IP
  • QR button: shows WireGuard .conf with correct keys and endpoint
  • Info button: shows peer-specific fields
  • Delete: peer removed from both DB and xray config
  • Edit WG inbound (save form): existing peers are preserved
  • Inbounds tab: WireGuard shows peer count

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5458 **Author:** [@mrAntonD](https://github.com/mrAntonD) **Created:** 6/21/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (10+) - [`1e9290f`](https://github.com/MHSanaei/3x-ui/commit/1e9290f864245246070acd5b5ef52c6e4ae6a01a) feat(wireguard): manage WG peers as clients on the Clients page - [`67ed0c8`](https://github.com/MHSanaei/3x-ui/commit/67ed0c842d35bb814401845116c5e8d1e8c36761) fix(wg): fix peer data loss, delete error, QR/info for WireGuard clients - [`053200e`](https://github.com/MHSanaei/3x-ui/commit/053200ed71f996c9a9ab3336819409a03e2da509) feat(wg): show config text and download button in QR modal - [`f7c09e4`](https://github.com/MHSanaei/3x-ui/commit/f7c09e4214bac8fa56eb7685acf8c5b9278f6b10) fix(wg): next IP suggestion, QR public key, and malformed JSON on add - [`236e49c`](https://github.com/MHSanaei/3x-ui/commit/236e49cf1ae4e6921b402cc74102b4b0b9e3e133) fix(wg): toggle enable/disable and show config in QR modal - [`9231c00`](https://github.com/MHSanaei/3x-ui/commit/9231c00062348abd066a9e36423f248381728e7f) feat(wg): download config in info/edit modals, preserve wgPeer on hydrate - [`fe18197`](https://github.com/MHSanaei/3x-ui/commit/fe18197d30bc0c05d243c080069cffa58c2679f4) feat(wg): hide subscription/links blocks for WireGuard clients - [`13ff78a`](https://github.com/MHSanaei/3x-ui/commit/13ff78a8a4c8025cf65a7f794cd9127a0b2d3b19) perf(wg): patch peers[] in-place instead of full DB rebuild on add/update/del - [`f4317c9`](https://github.com/MHSanaei/3x-ui/commit/f4317c997222512b9b5d8b0d7b5e9e99912cca0c) fix(ci): register WgPeerSettings in codegen and document WG client endpoints - [`962b9a3`](https://github.com/MHSanaei/3x-ui/commit/962b9a3bc1d0d08cc0c8b690e33b6e0a10a03b12) fix(ci): regenerate openapi.json after adding WG client endpoint docs ### 📊 Changes **28 files changed** (+1777 additions, -494 deletions) <details> <summary>View changed files</summary> 📝 `frontend/public/openapi.json` (+233 -2) 📝 `frontend/src/generated/examples.ts` (+12 -2) 📝 `frontend/src/generated/schemas.ts` (+39 -1) 📝 `frontend/src/generated/types.ts` (+9 -0) 📝 `frontend/src/generated/zod.ts` (+10 -0) 📝 `frontend/src/hooks/useClients.ts` (+3 -0) 📝 `frontend/src/pages/api-docs/endpoints.ts` (+31 -0) 📝 `frontend/src/pages/clients/ClientFormModal.tsx` (+293 -110) 📝 `frontend/src/pages/clients/ClientInfoModal.tsx` (+175 -96) 📝 `frontend/src/pages/clients/ClientQrModal.tsx` (+111 -13) 📝 `frontend/src/pages/clients/ClientsPage.tsx` (+33 -2) 📝 `frontend/src/pages/inbounds/form/InboundFormModal.tsx` (+1 -7) 📝 `frontend/src/pages/inbounds/form/protocols/wireguard.tsx` (+3 -123) 📝 `frontend/src/pages/inbounds/info/InboundInfoModal.tsx` (+11 -84) 📝 `frontend/src/pages/inbounds/useInbounds.ts` (+15 -2) 📝 `frontend/src/schemas/client.ts` (+9 -0) 📝 `internal/database/model/model.go` (+47 -22) 📝 `internal/web/controller/inbound.go` (+92 -0) 📝 `internal/web/service/client_crud.go` (+70 -6) 📝 `internal/web/service/client_link.go` (+3 -0) _...and 8 more files_ </details> ### 📄 Description ## Summary - **WireGuard peer management moved to Clients tab**: peers are now created/edited/deleted from the Clients page like any other protocol; the Inbounds form retains WG settings (key, MTU, etc.) but the peer list is removed from it - **Auto-migration on upgrade**: existing `settings.peers[]` are migrated to the `clients` table on first startup — no data loss - **Peer count on Inbounds tab**: WireGuard inbounds now show active peer count ## Key changes ### Backend - `model.go` — `WgPeerSettings` struct + `wg_settings` column on `ClientRecord`; `MarshalJSON`/`UnmarshalJSON` expose it as `wgPeer` in API responses - `client_wg_apply.go` — `AddWgClient`, `UpdateWgClient`, `DelWgClient`: full CRUD; each mutation rebuilds `settings.peers[]` from the clients table - `client_wg_peers.go` — `syncWgPeersFromClients`, `wgPeerToRecord`, `SyncWgInbound` - `inbound.go` — `UpdateInbound` preserves `settings.peers[]` when the form omits them; `inboundWgPublicKey` derives server public key from `secretKey` via curve25519; `GetInboundOptions` exposes `wgPublicKey` - `client_crud.go` — `Delete()` routes WG inbounds through `DelWgClient` (fixes "invalid clients format" error) - `client_paging.go` — `ClientSlim` includes `wgPeer` so next-IP suggestion works from the paged list - `inbound_migration.go` — `MigrateWgPeers` syncs existing peers to clients table on startup - `inbound.go` controller — WG CRUD endpoints under `/panel/api/inbounds/wg/` ### Frontend - `ClientFormModal` — WG fields (public/private key, PSK, allowed IPs, keepalive) when WG inbound selected; irrelevant fields hidden; auto-suggests next sequential IP - `ClientQrModal` — generates WireGuard `.conf` (`[Interface]` + `[Peer]`); supports `.conf` download - `ClientInfoModal` — WG-specific fields shown; non-applicable ones hidden - `useInbounds` — WireGuard added to `TRACKED_PROTOCOLS`; peer count read from `settings.peers` ## Test plan - [ ] Existing WG inbound: open Clients tab, verify peers migrated automatically - [ ] Add new WG peer: form shows WG fields, auto-suggests next available IP - [ ] QR button: shows WireGuard `.conf` with correct keys and endpoint - [ ] Info button: shows peer-specific fields - [ ] Delete: peer removed from both DB and xray config - [ ] Edit WG inbound (save form): existing peers are preserved - [ ] Inbounds tab: WireGuard shows peer count --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:48 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5887
No description provided.