[PR #4123] [MERGED] ws/inbounds: realtime fixes + perf for 10k+ client inbounds #5606

Closed
opened 2026-10-31 20:48:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/4123
Author: @lolka1333
Created: 4/28/2026
Status: ✅ Merged
Merged: 5/5/2026
Merged by: @MHSanaei

Base: main ← Head: main


📝 Commits (10+)

  • d14c54d ws/inbounds: realtime fixes + perf for 10k+ client inbounds
  • 88d71da Remove hub_test.go file
  • 6ceddf8 fix: ws hub, inbound service, and frontend correctness
  • 33782ba Merge branch 'main' into main
  • 7324c97 Merge branch 'main' into main
  • 2bb3170 Merge branch 'main' into main
  • f0d6966 fix: chunk large IN ? queries and fix IPv6 same-origin check
  • 7f7bcb6 fix: chunk large IN ? queries and fix IPv6 same-origin check
  • df6b46d fix: unify clientStats cache, throttle clarity, hub constants
  • 7792715 fix(ui): align traffic/expiry cell columns across all rows

📊 Changes

16 files changed (+2335 additions, -1361 deletions)

View changed files

📝 web/assets/js/websocket.js (+170 -108)
📝 web/controller/inbound.go (+67 -9)
📝 web/controller/index.go (+4 -7)
📝 web/controller/setting.go (+3 -1)
📝 web/controller/websocket.go (+48 -87)
📝 web/html/component/aClientTable.html (+23 -31)
📝 web/html/component/aTableSortable.html (+244 -180)
📝 web/html/inbounds.html (+275 -135)
📝 web/html/settings/xray/outbounds.html (+116 -67)
📝 web/html/settings/xray/routing.html (+183 -113)
📝 web/html/xray.html (+510 -208)
📝 web/job/xray_traffic_job.go (+62 -25)
📝 web/service/inbound.go (+316 -63)
📝 web/session/session.go (+17 -9)
📝 web/websocket/hub.go (+256 -279)
📝 web/websocket/notifier.go (+41 -39)

📄 Description

What is the pull request?

Fixes correctness + performance bugs in the WebSocket realtime layer and inbound page.

  • WebSocket: removed dead code, fixed deadlock under burst load, panic-recovery with retry cap, throttling, slow-retry after reconnect exhaustion, case-insensitive origin check
  • Realtime updates: delta-based broadcast (client_stats), force non-nil onlineClients, total-traffic counter now updates without page reload
  • Online filter: works correctly when clients go offline (was stuck on stale state)
  • Performance: O(N²) → O(N) in updateClientTraffics, bulk delete client IPs, new /setEnable/:id lightweight endpoint — 10k-client inbound toggle goes from 5–10s to <100ms
  • Logout: persist session on update (fixes broken logout after password change)
  • UI: protocol tags flex layout, traffic-bar CSS normalized

Which part of the application is affected by the change?

  • Frontend
  • Backend

Type of Changes

  • Bug fix
  • New feature
  • Refactoring
  • Other

Screenshots

Снимок экрана 2026-04-29 084916 image

🔄 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/4123 **Author:** [@lolka1333](https://github.com/lolka1333) **Created:** 4/28/2026 **Status:** ✅ Merged **Merged:** 5/5/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `main` --- ### 📝 Commits (10+) - [`d14c54d`](https://github.com/MHSanaei/3x-ui/commit/d14c54d21d206e1d77976ab9356807bb9e8b1a98) ws/inbounds: realtime fixes + perf for 10k+ client inbounds - [`88d71da`](https://github.com/MHSanaei/3x-ui/commit/88d71dad5eeee86672af4ce9b04e65e81aebc969) Remove hub_test.go file - [`6ceddf8`](https://github.com/MHSanaei/3x-ui/commit/6ceddf83fdbadb5542b5312d0c4f835ad9b1f215) fix: ws hub, inbound service, and frontend correctness - [`33782ba`](https://github.com/MHSanaei/3x-ui/commit/33782bada7a2a393813b164a41d7e7090c646771) Merge branch 'main' into main - [`7324c97`](https://github.com/MHSanaei/3x-ui/commit/7324c97a2a6e95ce2b3e292cc08fbe1ced4f8547) Merge branch 'main' into main - [`2bb3170`](https://github.com/MHSanaei/3x-ui/commit/2bb3170ab0957fd502481b7780d622ae8a604ce3) Merge branch 'main' into main - [`f0d6966`](https://github.com/MHSanaei/3x-ui/commit/f0d69667245ca54dcc83aeb15ba7d4d085eb1fae) fix: chunk large IN ? queries and fix IPv6 same-origin check - [`7f7bcb6`](https://github.com/MHSanaei/3x-ui/commit/7f7bcb6893e75e16ad556be9411f6922cc95fa00) fix: chunk large IN ? queries and fix IPv6 same-origin check - [`df6b46d`](https://github.com/MHSanaei/3x-ui/commit/df6b46d9c94b54ef1cabecbbe6bdb6a6e73e90f1) fix: unify clientStats cache, throttle clarity, hub constants - [`7792715`](https://github.com/MHSanaei/3x-ui/commit/7792715dc41d147bf80fed41a5e5cd024f9b6dd6) fix(ui): align traffic/expiry cell columns across all rows ### 📊 Changes **16 files changed** (+2335 additions, -1361 deletions) <details> <summary>View changed files</summary> 📝 `web/assets/js/websocket.js` (+170 -108) 📝 `web/controller/inbound.go` (+67 -9) 📝 `web/controller/index.go` (+4 -7) 📝 `web/controller/setting.go` (+3 -1) 📝 `web/controller/websocket.go` (+48 -87) 📝 `web/html/component/aClientTable.html` (+23 -31) 📝 `web/html/component/aTableSortable.html` (+244 -180) 📝 `web/html/inbounds.html` (+275 -135) 📝 `web/html/settings/xray/outbounds.html` (+116 -67) 📝 `web/html/settings/xray/routing.html` (+183 -113) 📝 `web/html/xray.html` (+510 -208) 📝 `web/job/xray_traffic_job.go` (+62 -25) 📝 `web/service/inbound.go` (+316 -63) 📝 `web/session/session.go` (+17 -9) 📝 `web/websocket/hub.go` (+256 -279) 📝 `web/websocket/notifier.go` (+41 -39) </details> ### 📄 Description ## What is the pull request? Fixes correctness + performance bugs in the WebSocket realtime layer and inbound page. - **WebSocket**: removed dead code, fixed deadlock under burst load, panic-recovery with retry cap, throttling, slow-retry after reconnect exhaustion, case-insensitive origin check - **Realtime updates**: delta-based broadcast (`client_stats`), force non-nil `onlineClients`, total-traffic counter now updates without page reload - **Online filter**: works correctly when clients go offline (was stuck on stale state) - **Performance**: O(N²) → O(N) in `updateClientTraffics`, bulk delete client IPs, new `/setEnable/:id` lightweight endpoint — 10k-client inbound toggle goes from 5–10s to <100ms - **Logout**: persist session on update (fixes broken logout after password change) - **UI**: protocol tags flex layout, traffic-bar CSS normalized ## Which part of the application is affected by the change? - [x] Frontend - [x] Backend ## Type of Changes - [x] Bug fix - [ ] New feature - [x] Refactoring - [ ] Other ## Screenshots <img width="2788" height="1249" alt="Снимок экрана 2026-04-29 084916" src="https://github.com/user-attachments/assets/2c038652-e431-4651-a010-d779d2255778" /> <img width="2836" height="1138" alt="image" src="https://github.com/user-attachments/assets/c73ce555-1c52-4cc2-9d10-f425a9e34d47" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 20:48:08 +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#5606
No description provided.