mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #6934] [Feature]: Expose AmneziaWG/WireGuard peer handshake time and per-peer traffic via API #4586
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4586
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @MaxRink on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6934
Is your feature request related to a problem?
With the built-in AmneziaWG inbound (v3.10.2, Docker), there is no way to see whether a peer is actually connected. The panel and API return per-inbound traffic, but there is no last-handshake time and no traffic counters per peer. AWG traffic also reaches Xray without a client email, so the per-client stats stay empty for AWG peers. Because the AWG device runs inside the panel process,
awg show/wg showare not available in the container to read this from outside.Describe the solution you'd like
Add the per-peer runtime state the WireGuard/AmneziaWG device already tracks to the inbound API:
lastHandshake(unix seconds, 0 if never)rx/txbytesendpoint(optional)It could go in the existing
GET /panel/api/inbounds/get/:id(orlist) response as apeerStatsarray keyed by peer public key or peer name, or in a separate endpoint such asGET /panel/api/inbounds/:id/peers. Showing "last handshake N min ago" next to each peer in the inbound UI would be a nice extra.Alternatives you've considered
awg show dumpfrom the host or container: there is no kernel or awg-go device visible outside the panel process.Concrete use case
I monitor a small AmneziaWG inbound (a few peers, one per device, including a travel router) with Prometheus. I want to alert when a peer has not completed a handshake for longer than X minutes while it should be online, and to graph per-device traffic. Today I can only see bytes per inbound.
Which parts of the panel would this affect?
Backend (API endpoints, login, settings); Statistics / traffic counters; Frontend (UI / panel pages)
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Oct 25, 2026):
Most of this already exists in v3.10.2. The panel reads each AmneziaWG peer's last handshake, rx/tx bytes, endpoint and allowed IPs from the embedded device, and serves them on
POST /panel/api/server/amneziawglogs/:count. That endpoint is server-wide, not per inbound, which is the only part of your request that is still missing.What you can use today
The endpoint was added in
effcccce(feat(amneziawg): add native AmneziaWG protocol support (#6105)) and is in the v3.10.0 and v3.10.2 tags. It is registered atinternal/web/controller/server.go:79:It sits under the
/panel/apigroup, so an API token works (Authorization: Bearer ...,internal/web/controller/api.go:46):Each item in
obj.peersis aPeerActivity(internal/web/service/server.go:1331-1343):inboundId,tag,interfaceemailendpoint,allowedIPshandshake0if the peer never connectedup/downrx_bytes/tx_bytesfor that peer (server.go:1418-1419)onlinetruewhen the last handshake is under 180 s old (amneziawgOnlineWindow = 180 * time.Second,server.go:1348)The
:countparameter caps how many rows come back: values outside 1–10000 fall back to 100 (server.go:1438-1440). The optionalfilterform field is a case-insensitive substring match on email, tag, interface, endpoint and allowed IPs, sofilter=<inbound tag>narrows the result to one inbound. In the UI, the same data is in the AmneziaWG log view on the Overview page (frontend/src/pages/index/AmneziaWGLogModal.tsx). For your Prometheus alert,now_ms - handshake > X*60000on eachemailshould work. The rx/tx values are the live device counters, so they start from zero again whenever the interface is recreated.There are two limits. Inbounds hosted on a node are skipped (
node_id IS NULLin the query atserver.go:1386). The opt-in kernel datapath (56ac8d0f, not yet in a release) is a separate path, so this does not apply to it.On "AWG peers have no client email"
The source does not match this. Decrypted AmneziaWG traffic goes into a loopback Xray SOCKS5 inbound and logs in with the peer's own client email as the username (
internal/amneziawgnet/relay.go:1-6,manager.go:221relay.RelayTCP(conn, peer.Email, dest)). The accounts for that inbound are built from the peers' emails (internal/web/service/xray.go:803-813). So per-client Xray stats should fill in for AWG clients, with one designed exception: port-forwarded bytes skip Xray (internal/amneziawgnet/portfwd.go:17). If a normal, non-port-forwarded AWG client's up/down really stays at 0 in the client list on v3.10.2, please open a separate bug report with the client's JSON and the inbound'ssettings. I can't check that path without them.What is still a feature request
There is a per-inbound service method,
InboundService.GetAmneziaWGDiagnostics(id)(internal/web/service/inbound_amneziawg.go:453), but no route uses it. AGET /panel/api/inbounds/:id/peers-style endpoint, or a per-peer "last handshake" column in the inbound's client list, would need new wiring. The underlying data is already collected byamneziawgnet.Diagnose(internal/amneziawgnet/diagnostics.go:50).No existing issue asks for this; none of the AmneziaWG issues I found (#6319, #6378, #6774) cover it.
Verdict: Feature request. Per-peer handshake and traffic are already exposed server-wide via
/panel/api/server/amneziawglogs/:countin v3.10.2; a per-inbound endpoint and an inline UI column are not.This reply was generated automatically; a maintainer may follow up.
@MaxRink commented on GitHub (Oct 25, 2026):
Thanks a lot for the detailed analysis, that was exactly the missing piece.
I verified
POST /panel/api/server/amneziawglogs/:counton v3.10.2 (Docker) with an API token:obj.peers[]hasemail,tag,interface,handshake(ms),up/downandonlineas you described. I now scrape it into Prometheus (per-peer last handshake, rx/tx and online) and alert when a peer that was connected in the last 24 h has had no handshake for 30 minutes, so the server-wide endpoint covers my monitoring need.I also confirmed the AmneziaWG flows enter the loopback SOCKS inbound with the peer's email as the user, so my statement about missing client emails was wrong; sorry about that. I have not seen a non-port-forwarded client stay at zero, so there is no bug to report for now.
From my side this can be closed as answered. A per-inbound endpoint (
GetAmneziaWGDiagnostics) or a "last handshake" column in the inbound client list would still be a nice extra, but I don't need it; feel free to keep it open for that or close it.