[PR #7100] feat(nodes): show per-client live speed for clients served by nodes #6652

Open
opened 2026-11-08 05:52:42 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/7100
Author: @bazil1981
Created: 11/7/2026
Status: 🔄 Open

Base: main ← Head: feat/node-client-speed-main


📝 Commits (1)

  • 2c052ca feat(nodes): show per-client live speed for clients served by nodes

📊 Changes

7 files changed (+257 additions, -35 deletions)

View changed files

📝 docs/public/openapi.json (+3 -2)
📝 frontend/public/openapi.json (+3 -2)
📝 frontend/src/hooks/useClients.ts (+11 -4)
📝 frontend/src/pages/api-docs/websocket-events.ts (+3 -2)
📝 frontend/src/test/clients-summary.test.tsx (+35 -0)
➕ internal/web/job/node_client_speed_test.go (+86 -0)
📝 internal/web/job/node_traffic_sync_job.go (+116 -25)

📄 Description

The clients page shows a live up/down speed for each client, but only for traffic seen by the local Xray (and TUIC) poll. Clients connected through a managed node never got a speed, even though the master already pulls their cumulative counters from the node every 5s; only per-inbound node speed (nodeTraffics) was derived.

NodeTrafficSyncJob now diffs each node's per-client counters (taken from the inbound list snapshot it already fetches) against the previous successful poll, using the same normalization as the per-inbound node speed: deltas are scaled to the 5s window by real elapsed time, idle counters hold their change timestamp, and resets rebaseline. Baselines are kept per node, so a client served by several nodes is summed correctly, and are pruned when a node is deleted.

The deltas go out as a separate traffic event with clientTrafficSource "node" (the existing clientTraffics/source/interval shape already used by TUIC), so the clients page keeps them apart from the local Xray samples and adds them up instead of overwriting each other.

Claude-Session: https://claude.ai/code/session_01CtECBQEVCFxy9hEwY8TgAi

Summary

Why

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Documentation
  • Tests only
  • Build / CI / tooling
  • Other

Areas affected

  • Frontend (UI / panel pages)
  • Backend (API endpoints, login, settings)
  • Xray config generation
  • Subscription (share links / Clash / JSON)
  • Statistics / traffic counters
  • Database / migrations
  • Install / upgrade script
  • Docker image
  • Multi-node (sub-nodes)
  • Telegram bot

How was this tested?

Screenshots / recordings

Breaking changes

Checklist

  • I tested the change locally and confirmed the described behavior.
  • I added or updated tests for the new behavior (when applicable).
  • go build ./... and the test suite pass locally.
  • For frontend changes: npm run lint, npm run typecheck, and npm run build pass.
  • I updated the Wiki / README / API docs if user-facing behavior changed.
  • My commits follow the project's existing message style.
  • I have no unrelated changes mixed into this PR.

🔄 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/7100 **Author:** [@bazil1981](https://github.com/bazil1981) **Created:** 11/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/node-client-speed-main` --- ### 📝 Commits (1) - [`2c052ca`](https://github.com/MHSanaei/3x-ui/commit/2c052caac66b9a2f08a7e9aa4ed70d2912da727b) feat(nodes): show per-client live speed for clients served by nodes ### 📊 Changes **7 files changed** (+257 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `docs/public/openapi.json` (+3 -2) 📝 `frontend/public/openapi.json` (+3 -2) 📝 `frontend/src/hooks/useClients.ts` (+11 -4) 📝 `frontend/src/pages/api-docs/websocket-events.ts` (+3 -2) 📝 `frontend/src/test/clients-summary.test.tsx` (+35 -0) ➕ `internal/web/job/node_client_speed_test.go` (+86 -0) 📝 `internal/web/job/node_traffic_sync_job.go` (+116 -25) </details> ### 📄 Description The clients page shows a live up/down speed for each client, but only for traffic seen by the local Xray (and TUIC) poll. Clients connected through a managed node never got a speed, even though the master already pulls their cumulative counters from the node every 5s; only per-inbound node speed (nodeTraffics) was derived. NodeTrafficSyncJob now diffs each node's per-client counters (taken from the inbound list snapshot it already fetches) against the previous successful poll, using the same normalization as the per-inbound node speed: deltas are scaled to the 5s window by real elapsed time, idle counters hold their change timestamp, and resets rebaseline. Baselines are kept per node, so a client served by several nodes is summed correctly, and are pruned when a node is deleted. The deltas go out as a separate traffic event with clientTrafficSource "node" (the existing clientTraffics/source/interval shape already used by TUIC), so the clients page keeps them apart from the local Xray samples and adds them up instead of overwriting each other. Claude-Session: https://claude.ai/code/session_01CtECBQEVCFxy9hEwY8TgAi ## Summary <!-- What does this PR do? One or two sentences. --> ## Why <!-- What problem does this solve, or what use case does it enable? Link related issues here: "Closes #123", "Refs #456". --> ## Type of change - [ ] Bug fix - [ ] New feature - [ ] Refactoring (no behavior change) - [ ] Documentation - [ ] Tests only - [ ] Build / CI / tooling - [ ] Other ## Areas affected - [ ] Frontend (UI / panel pages) - [ ] Backend (API endpoints, login, settings) - [ ] Xray config generation - [ ] Subscription (share links / Clash / JSON) - [ ] Statistics / traffic counters - [ ] Database / migrations - [ ] Install / upgrade script - [ ] Docker image - [ ] Multi-node (sub-nodes) - [ ] Telegram bot ## How was this tested? <!-- Concrete steps the reviewer can repeat. For UI changes: which page, which actions, which browser. For backend: which endpoint, which payload, which response. Mention any new unit/integration tests added. --> ## Screenshots / recordings <!-- Required for UI changes. Drag images or GIFs here. Remove if N/A. --> ## Breaking changes <!-- Does this change require existing users to update their config, run a migration, or change their API calls? If yes, describe the migration path. Write "None" if there are no breaking changes. --> ## Checklist - [ ] I tested the change locally and confirmed the described behavior. - [ ] I added or updated tests for the new behavior (when applicable). - [ ] `go build ./...` and the test suite pass locally. - [ ] For frontend changes: `npm run lint`, `npm run typecheck`, and `npm run build` pass. - [ ] I updated the Wiki / README / API docs if user-facing behavior changed. - [ ] My commits follow the project's existing message style. - [ ] I have no unrelated changes mixed into this PR. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#6652
No description provided.