mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #7101] [Feature]: Master-controlled global IP limit across all nodes #6653
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#6653
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 @xAlokyx on GitHub (Nov 7, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/7101
Is your feature request related to a problem?
In my multi-node setup, the IP limit configured on the master does not effectively restrict concurrent use of the same subscription across different nodes.
For example, one subscriber has access to three node servers and an IP limit of 1 configured on the master. Three devices with three different public IP addresses can connect simultaneously, one device to each node, and all three connections remain active without the master enforcing the limit.
The required limit is one concurrent unique public IP across the entire subscription, regardless of which node is used. Adding nodes should not multiply the subscriber's effective IP allowance. This is an IP-address limit, not an exact device count: multiple devices behind the same public IP may share one IP slot.
Describe the solution you'd like
Please provide reliable master-controlled enforcement of a single global IP limit per client across the master and every assigned node.
I understand that the current project already has cross-node IP synchronization and cluster-wide counting logic. This request focuses on making end-to-end master-controlled enforcement work for the scenario above. If this behavior is already supported, please clarify the required master/node settings and prerequisites so this can be diagnosed as a configuration problem or a bug.
Alternatives you've considered
Independent per-node limits do not meet this requirement: with three nodes and a limit of 1 on each, the same subscription could still be used from three different IPs at the same time. Manual monitoring and manually repeating bans on every node are difficult to maintain.
Concrete use case
Observed in my setup: all three different IPs remain connected.
Expected: the master evaluates the combined three-IP usage against the single global limit of 1 and coordinates enforcement on the nodes. Only one unique public IP should remain permitted under the configured policy; moving the excess connections to another assigned node must not bypass the limit.
Mockups, screenshots, or examples
No response
Which parts of the panel would this affect?
Multi-node (sub-nodes)
Are you willing to help?
Before submitting
@github-actions[bot] commented on GitHub (Nov 7, 2026):
Most of this already exists on the default branch, but it is not a central "master decides, nodes obey" design. Each node runs its own IP-limit job and counts the other nodes' recent IPs toward the client's limit. Every node has to be set up to enforce it, though, and there is one gap in the code that could explain your three surviving connections. I need a few details from your setup (listed at the end) to tell which of these you hit.
How the cluster-wide limit works today
CheckClientIpJob(internal/web/job/check_client_ip_job.go, scheduled ininternal/web/web.go:360) reads the live IPs for each client from Xray's online-stats API and writes them to that panel'sinbound_client_ipsrow.node_traffic_sync_job.go:453-470pulls each node's rows (FetchAllClientIps→MergeNodeClientIps), merges them into the master's row for the same email, then pushes the merged rows back to that node (GetNodeInboundClientIps→PushAllClientIps). On the node they land inMergeInboundClientIps(internal/web/controller/server.go:544-551). After this step every node holds the union of IPs for the clients it hosts.partitionLiveIps(check_client_ip_job.go) counts an IP as live if it is connected to this node or was seen anywhere in the last 120 s:selectIpsToBanthen keeps the newestlimitIpIPs and bans the older ones. The ban goes through that node's own fail2ban (publishBans→3x-ipllog) plus a temporary Xray disconnect (disconnectClientTemporarily). Every node bans the same older IPs, including ones not connected to it, so moving a banned IP to another node doesn't get around the limit.In your example (A, then B, then C, limit 1), each node should end up banning A and B, and only C stays connected.
Prerequisites on every node, not just the master
x-uimenu →22. IP Limit Management). On Linux,resolveEnforceturns enforcement off when the binary is missing: The job then only records IPs and bans nothing.XUI_ENABLE_FAIL2BANmust not befalsein the node's service environment.falseturns off enforcement and leaves only tracking (#6722).GET/POST /panel/api/server/clientIps), and the master must reach it. Failures show in the master log asnode traffic sync: fetch client ips from <node> failedorpush client ips to <node> failed.limitIphas to reach the node.hasLimitIpreads the node's ownclients.limit_ip.A gap that could defeat it even when set up correctly (inference, not confirmed)
The timestamp stored in the shared row is Xray's
lastSeenfor the IP, not the time of the scan. The code says this value can be old for a connection that is still open (processObserved: "A live connection's lastSeen may be its old start time."), because the core refreshes it only on a new dispatch (selectAdvancedSinceLastBan). The local node always counts its own connection. The other nodes get that old timestamp through the master, and once it is older than 120 s,partitionLiveIpsputs the IP in the historical bucket and leaves it out of the count.So a device that keeps one long connection open (mux, a single gRPC/XHTTP stream) can stop counting on the other nodes. The fresh "seen now" stamp the job does write (
recordLocalAttribution→node_client_ips) is only used to show which node an IP is on. Enforcement never reads it. Whether this is what happened in your case depends on how your clients connect, which I can't see from here.What I could not confirm
The issue also asks for an aggregated count and enforcement/sync-failure status on the master's UI, and for ban/unban decisions made centrally. Today bans are decided per node by the logic above. I did not find a central ban list sent to nodes. That part is a real feature request.
Please reply with
fail2ban-client status 3x-ipl, and whetherXUI_ENABLE_FAIL2BANis set in the service environment.[LIMIT_IP]/[LimitIP]lines from a node's log while A, B and C are connected, and anynode traffic sync: ... client ipswarnings from the master's log.Related: #6587 (an earlier lost-update bug in this same shared row, now closed).
Verdict: Insufficient information. Cross-node enforcement already exists, but whether your setup is a configuration problem or the lastSeen gap above depends on the details requested.
This reply was generated automatically; a maintainer may follow up.