mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 21:18:19 +07:00
[GH-ISSUE #4982] [Bug]: Cyclic creation of connections #3500
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#3500
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 @slvy121 on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4982
Describe the bug
In version 3.1.0, I had two nodes connected. In the nodes section, I added both the current node and the second node on each node. This allowed the subscriptions on both servers to display connections from both nodes. When upgrading to any higher version, connections are created cyclically.
How I fixed this: I removed the connection between the two nodes. Then, I added a second node on the first node.
However, if I then add the first node on the second node (so that the subscription link displays connections from both nodes), duplicate connections will appear on one of the nodes again.
How to reproduce the problem
Expected behavior
If there were 2 connections on each server, then there should be only 4 in the general list (2 from one server and 2 from another), in the subscription for each server for the client there should only be 4 servers
Actual behavior
There will be a duplication of connections; if there were 2 on each server, there will be 6 or more
Relevant logs
Screenshots
No response
3x-ui version
3.2.8
Xray-core version
No response
How did you install 3x-ui?
install.sh script
Operating system
Ubuntu 24.04
Which parts of the panel are affected?
Multi-node (sub-nodes)
Browser (only if it is a UI bug)
No response
Is the panel behind a reverse proxy or CDN?
None
Before submitting
@github-actions[bot] commented on GitHub (Jun 5, 2026):
Thanks for the detailed reproduction steps — this is a real bug in the multi-node sync path.
Root cause
When the central panel syncs with a remote node it calls
panel/api/inbounds/liston that node (web/runtime/remote.go:393). That endpoint callsGetInbounds(web/service/inbound.go:225), which returns all inbounds for the user — including inbounds the remote node itself pulled from its own sub-nodes (i.e. rows wherenode_id IS NOT NULLon the remote panel).Because the
Inboundmodel serialisesNodeIDas"nodeId"withomitempty(database/model/model.go:64), those sub-node inbounds arrive in the snapshot with a non-nilnodeIdvalue.In
setRemoteTrafficLocked(web/service/inbound.go:1554), every snapshot entry whose tag is not already indexed under that node'stagToCentralmap triggerspickFreeTag. If the bare tag is already taken by the other node's inbound, the prefixed formn<id>-<tag>is chosen and a brand-new central inbound is created attributed to the current node (nodeID).ReconcileNodethen pushes that prefixed inbound back to the remote node. On the next sync the remote reports it again, and the cycle continues.Concrete example with two bidirectional nodes (server 1 ↔ server 2):
cn1-c← spurious duplicateThe spurious
n1-cis then reconciled back to S1, which reports it next cycle, and so on.Workaround
Until this is fixed: only add each server as a node on one side. Pick one panel as the "central" panel. Add both servers as nodes there. Do not also add the central panel as a node back on the sub-nodes. This breaks the bidirectional cycle: each sub-node's
/panel/api/inbounds/listwill only return its own local inbounds (no sub-node rows), so nothing spurious gets imported.Fix direction
In
setRemoteTrafficLocked(around line 1554 inweb/service/inbound.go), skip any snapshot inbound wheresnapIb.NodeID \!= nilbefore processing — those are sub-node inbounds of the remote panel, not native ones. The check is trivial:Alternatively (cleaner long-term): filter the
/panel/api/inbounds/listresponse inGetInboundsto excludenode_id IS NOT NULLrows when the request comes from a node-sync client, though that requires a way to distinguish the caller.