mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5218] [Feature]: Per-client bandwidth throttling / QoS (Traffic Shaping) #3655
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#3655
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 @dead-man1 on GitHub (Jun 12, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5218
Is your feature request related to a problem?
On high-bandwidth servers (e.g., 1 Gbps), a single client can easily saturate the server's network interface, leading to packet loss and high latency for all other clients sharing the same inbound.
Describe the solution you'd like
It would be incredibly useful if the panel could implement traffic shaping at the system level. A potential implementation could involve configuring Xray to apply specific socket marks (fwmark) per client/UUID routing, and having the 3x-ui panel automatically manage Linux tc (Traffic Control) classes to throttle those specific marks.
Alternatives you've considered
I haven't found any native way to do this in Xray or 3x-ui. Manual tc configuration is too complex and gets overwritten/reset when the panel restarts or configs change.
Concrete use case
I manage a server with 1 Gbps uplink. I need the ability to cap a specific client at 30 Mbps to ensure fair resource allocation and prevent one user from choking the connection for everyone else.
Mockups, screenshots, or examples
No specific UI mockup, but adding a 'Speed Limit (Mbps)' input field in the 'Add/Edit Client' dialog would be perfect.
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 12, 2026):
Per-client bandwidth rate limiting is not implemented anywhere in the current codebase. The feature request is valid and not a duplicate of any existing issue.
What currently exists for per-client limits
The
Clientstruct (internal/database/model/model.go) has two per-client constraint fields, neither of which is a rate/bandwidth limit:LimitIP(limit_ip) — caps the number of concurrent IP connections per clientTotalGB(total_gb) — a cumulative data-volume quota; the client is disabled once the quota is exhausted, not throttledThere is no
maxUpMbps,maxDownMbps, or any equivalent field. The frontend schemas (frontend/src/schemas/protocols/inbound/) and the Xray config generation code (internal/xray/) confirm the same: no rate-limiting data is emitted to Xray-core.Why Xray-core cannot do this natively
Xray-core's policy system (
internal/xray/config.go, policy levels) exposes connection-timeout fields (connIdle,uplinkOnly,downlinkOnly) and abufferSizefor memory tuning, but no per-user bandwidth cap.statsUserOnline(used by the IP-limit job) is the only per-user policy feature the panel currently uses. There is no per-email or per-UUID rate-limit knob in any of the supported protocols (VLESS, VMess, Trojan, Shadowsocks, Hysteria2, WireGuard).The
uplinkMbps/downlinkMbpslabels that appear in the translation files (internal/web/translation/en-US.json:532-533) belong to the XHTTP transport stream settings, not client-level caps.On the proposed
fwmark+tcapproachThe approach described — assigning per-client socket marks combined with Linux
tcclasses — is technically viable as a host-level workaround, but Xray-core does not currently support settingSO_MARKon a per-email/per-UUID basis on inbound-accepted sockets. It can set an outboundmark, which would require routing each client through a dedicated outbound — a significant change to how configs are generated today.An alternative that stays entirely within the kernel is to apply
tcrules keyed on the source IP of accepted connections (possible since the panel already tracks per-IP activity ininternal/web/job/), but that breaks per-client isolation when multiple clients share a NAT address.Scope of a proper implementation
Any implementation would touch at minimum:
Clientmodel andClientRecord(database migration required)tcrules on inbound restarts — with correct handling ofNET_ADMINcapability in Docker deployments (docker-compose.ymlalready grantsNET_ADMIN/NET_RAWfor the fail2ban job)This is a substantive feature that requires a design decision on the enforcement mechanism before a PR could be accepted. If you plan to implement it, opening a design discussion or draft PR early would be the best way to align on approach.
This reply was generated automatically; a maintainer may follow up.