mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #5248] [Bug]: ip limit problem #3673
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#3673
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 @NewMreza on GitHub (Jun 12, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/5248
Describe the bug
in some clients, there is this problem that ip limit doesn't work properly.
it's only 1 internet on 1 device connected to it but it shows many IPs connected. this bug has been there since v3
sometimes it goes up to 50 IPs connected to 1 client in only a couple of minutes and the usage of it is normal(it's like 1 customer using it only, not 50)
i've read all patches whenever an update was dropped hoping this problem would be fixed but never got fixed.
How to reproduce the problem
i really don't know but it happens by chance on some clients, happend to me right now so i'm sure it's not a fake acting from my customers, although 50 IPs connected in a few minutes was enough to prove.
Expected behavior
1 IP connected
Actual behavior
up to 50 IPs connected in 1-2 minutes
Relevant logs
Screenshots
3x-ui version
3.3.1
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
ubuntu 22.04
Which parts of the panel are affected?
Statistics / traffic counters
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
Yes — Cloudflare (proxied DNS)
Before submitting
@github-actions[bot] commented on GitHub (Jun 12, 2026):
The root cause here is Cloudflare's proxied (orange-cloud) DNS mode, not a bug in the IP limit logic itself.
Why you see dozens of IPs for one device
When Cloudflare proxies traffic, the TCP connection to your origin server is made by a Cloudflare edge node, not by the client directly. Each new or reused connection can arrive from a different Cloudflare edge IP. Xray's
statsUserOnlinepolicy — and, in the fallback path, the access log — both record the TCP source address, which is whichever Cloudflare edge server handled that connection. A single mobile client generating a handful of reconnects in a few minutes can produce 20–50 distinct Cloudflare edge addresses; the panel displays exactly what Xray reports.Confirmed in source
The IP addresses displayed by the panel come from the Xray core's online-stats gRPC API (
internal/xray/api.go:GetOnlineUsers) or from access-log parsing (internal/web/job/check_client_ip_job.go:processLogFile). Neither path does any filtering or rewriting of those source IPs — the panel shows them as-is.Fix: configure
trustedXForwardedForon the inboundXray has a
sockoptoption calledtrustedXForwardedFor. When a connection arrives from a CIDR listed there, Xray reads theX-Forwarded-Forheader (which Cloudflare sets to the real client IP) and uses that value as the connection's source address for logging and stats. Configuring it with Cloudflare's published IP ranges will make IP limit count real client IPs instead of Cloudflare edge IPs.The panel exposes this field in the inbound editor: Transport tab → Socket Settings → Trusted X-Forwarded-For (confirmed in
frontend/src/pages/inbounds/form/transport/sockopt.tsx).Steps:
Prerequisites
trustedXForwardedForin sockopt. The bundled core in 3.3.1 (v1.260327.1-0.20260601021109-94ffd50060f1) is recent enough.Why only some clients are affected
Clients connecting directly to the origin (without Cloudflare proxy) show one real IP. Only those whose traffic routes through Cloudflare's edge exhibit the inflated count.
This reply was generated automatically; a maintainer may follow up.