mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5195] [Feature]: Per-Client Speed Limit (Bandwidth Throttling in KB/s or MB/s) #3643
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#3643
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 @hazindu on GitHub (Jun 11, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5195
Is your feature request related to a problem?
I'm always frustrated when a single client consumes the entire server bandwidth. Currently, 3X-UI allows limiting the Total Traffic Quota (GB) and Expiry Date, but there is no built-in way to throttle the actual connection speed (e.g., limiting a specific user to 10 Mbps). When managing a server with multiple users, a few heavy downloaders can negatively impact the latency and speed of everyone else.
Describe the solution you'd like
I would like to see "Up Speed" and "Down Speed" limit fields added to the Add/Edit Client modal in the UI. The panel should allow setting a maximum speed (in KB/s or MB/s) per individual client. The backend could implement this using Xray's built-in traffic shaping capabilities or by dynamically managing Linux 'tc' (traffic control) rules tied to the client's connection.
Alternatives you've considered
I have considered using Linux 'tc' (Traffic Control) commands manually via SSH, but it is extremely difficult to manage dynamically for individual UUIDs managed by Xray. Setting connection/IP limits helps slightly, but it doesn't solve the bandwidth monopolization issue.
Concrete use case
I manage a server where I provide free access to a considerable group of users. I need to limit their individual speeds to a specific fixed value (5 MB/s) so they can browse normally, but ensure they won't cause lag or high ping for other users who are playing online multiplayer games on the same server.
Mockups, screenshots, or examples
Which parts of the panel would this affect?
Frontend (UI / panel pages), Backend (API endpoints, login, settings), Xray config generation
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Jun 11, 2026):
Thanks for the detailed request and mockup — this is a well-understood pain point that has come up many times in this tracker.
Current state (confirmed in source)
There is no speed limiting in 3x-ui today. The
Clientstruct ininternal/database/model/model.gotracks onlyLimitIP,TotalGB,ExpiryTime, andEnable— no upload/download speed fields. The Xray config generation ininternal/xray/passes thepolicysection as-is (raw JSON from the panel's template), and it is not populated with any per-client rate values.Why it is non-trivial
Xray-core's policy levels control connection timeouts (
handshake,connIdle,uplinkOnly,downlinkOnly) and buffer sizes — not bandwidth caps. There is no native "max speed per user" knob in Xray-core's config. This is a known upstream limitation; per-client rate limiting is tracked in XTLS/Xray-core but not yet shipped.That means any implementation in 3x-ui would have to use Linux
tc(traffic control), which has its own challenges:tcrules keyed on IP cannot cleanly isolate one client's traffic.CAP_NET_ADMIN) and works differently in Docker vs. bare-metal installs.What a PR would need to touch
If someone wants to attempt this:
internal/database/model/model.go— addUpSpeedKBps/DownSpeedKBps(int) fields toClient,ClientRecord, and theMergeClientRecordlogic.internal/database/.tcrules via the OS (complex) or wait for upstream Xray-core support (blocked on upstream).Given the upstream limitation, a PR adding only the UI fields + DB columns and deferring enforcement is the realistic first step. Enforcement via
tccould follow separately.Prior related issues (for reference): #4333, #3263, #2522, #2934 — all requested the same feature; none were implemented.
@NewMreza commented on GitHub (Jun 11, 2026):
you can manage bandwidth on xray only if you specify 1 port per client, which is not related to xray at all but to server itself.
that's the only way i know