[PR #5488] [MERGED] fix(nodes): cloned-node attribution, node-hosted client display (online/speed/counts), and sync robustness #5898

Closed
opened 2026-11-02 04:04:52 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/MHSanaei/3x-ui/pull/5488
Author: @MHSanaei
Created: 6/22/2026
Status: ✅ Merged
Merged: 6/22/2026
Merged by: @MHSanaei

Base: main ← Head: fix/cloned-node-duplicate-guid


📝 Commits (10+)

  • af94179 fix(nodes): keep cloned nodes (shared panelGuid) in separate attribution buckets
  • 98c9ba1 fix(nodes): extend duplicate-GUID hardening to master collisions, IP attribution, and a heartbeat warning
  • 846b8b3 fix(node-sync): log the client-IP-attribution 404 once per node, not every cycle
  • 7458ed4 fix(nodes): remap a cloned node's own-panelGuid origin so the inbound page shows online
  • e0ac65a fix(node-sync): don't delete a node's central inbounds when its snapshot is empty
  • 5aa8777 fix(email): stay silent when SMTP notifications are disabled
  • f96e877 fix(nodes): count only expired/exhausted as 'ended', not disabled clients
  • 2ce5891 feat(nodes): show live speed for node-hosted inbounds
  • eedb65b fix(nodes): normalize node-inbound speed by elapsed time to avoid recovery spikes
  • 32e97cd fix(inbounds): keep last speed across page navigation instead of blanking

📊 Changes

21 files changed (+891 additions, -146 deletions)

View changed files

📝 frontend/public/openapi.json (+12 -0)
📝 frontend/src/generated/examples.ts (+2 -0)
📝 frontend/src/generated/schemas.ts (+10 -0)
📝 frontend/src/generated/types.ts (+2 -0)
📝 frontend/src/generated/zod.ts (+2 -0)
📝 frontend/src/pages/inbounds/list/InboundList.tsx (+6 -1)
📝 frontend/src/pages/inbounds/list/useInboundColumns.tsx (+12 -12)
📝 frontend/src/pages/inbounds/useInbounds.ts (+44 -16)
📝 frontend/src/pages/nodes/NodeList.tsx (+30 -9)
📝 frontend/src/schemas/node.ts (+2 -0)
📝 internal/database/model/model.go (+2 -0)
📝 internal/web/job/node_traffic_sync_job.go (+105 -7)
📝 internal/web/service/email/subscriber.go (+3 -0)
📝 internal/web/service/inbound_node.go (+60 -12)
📝 internal/web/service/inbound_node_ips.go (+31 -7)
📝 internal/web/service/inbound_node_ips_test.go (+2 -2)
📝 internal/web/service/node.go (+180 -52)
➕ internal/web/service/node_client_breakdown_test.go (+87 -0)
📝 internal/web/service/node_origin_guid_test.go (+98 -0)
➕ internal/web/service/node_shared_guid_test.go (+162 -0)

...and 1 more files

📄 Description

Fixes a cluster of multi-node panel issues found while debugging a fleet whose nodes were cloned from one disk image (so they share a panelGuid) and whose inbounds had been delete+recreated. Centered on node attribution, but also brings the Nodes page client display to parity with the Inbounds page and hardens the node sync.

1. Cloned / duplicate-panelGuid attribution (#4983 hardening)

#4983 keys online + inbound + IP attribution by panelGuid, assuming it's globally unique. Cloned node servers ship an identical panelGuid, which collapsed several physical nodes into one bucket (online cross-attributed, counts merged).

  • Treat a panelGuid as ambiguous when more than one direct node reports it, or it equals the master's own panelGuid, and fall back to a node-unique key. Applied consistently to origin_node_guid, the online tree (+ self-key remap), effectiveNodeGuid, GUID-keyed IP attribution, and node deletion. sharedNodeGuids/ambiguousNodeGuids compute the collision set.
  • Remap a node's own-panelGuid origin: these builds report their own inbounds' origin as their (shared) panelGuid, so origin_node_guid stayed the shared value while online was keyed by the node-unique key — the inbound page then read an empty bucket and showed everyone offline. Now resolved through the same key.
  • Throttled heartbeat warning when a node reports a panelGuid already used by another node or the master, so the operator knows to regenerate it.

2. Node-hosted inbound display parity

  • Speed for node-hosted inbounds: the dashboard derives speed from a traffics delta feed that only the local Xray poll produced. The node sync now diffs per-inbound cumulative totals and broadcasts nodeTraffics; the frontend applies traffics to local inbounds and nodeTraffics to node inbounds within their own scope (no clobbering). Deltas are normalized by real elapsed time so a node recovering from an outage shows its average rate, not an impossible one-tick spike. Speed is also cached across page navigation so it no longer blanks for a poll on return.
  • Active / Disabled / Ended counts on the Nodes page, matching the Inbounds page (depleted = expired/exhausted only; disabled is its own bucket).
  • These counts are classified by client email, not client_traffics.inbound_id — that column goes stale after an inbound is delete+recreated, so filtering by it dropped almost every row and undercounted (active showed ~5 instead of ~1100).

3. Node-sync robustness & log noise

  • Don't delete a node's central inbounds when its snapshot is empty. A node mid-restart / with a transient DB error can return an empty inbound list with success=true, which previously wiped its central inbounds and all their clients (observed: a node showing 0 clients but still online).
  • Log the old-build clientIpsByGuid 404 once per node (re-armed on recovery) instead of every ~10s cycle.

4. UI / layout

  • Rebalance the Inbounds table column widths so it fills width without gaps.
  • Widen the Nodes "Clients" column and tighten the chip padding so the count chips render on one tidy line like the Inbounds list.

5. Unrelated small fix

  • Email subscriber stays silent when SMTP notifications are disabled (it was attempting a send on every login and logging "smtp host not configured").

Tests

Added coverage for the ambiguity disambiguation (node-vs-node and node-vs-master), effectiveNodeKey, the per-node count split, the empty-snapshot guard, the cloned-node origin remap, and the email-based breakdown (proven against a deliberately stale inbound_id). go build, go vet, the full service/job suites, and the frontend typecheck pass.

Note: includes frontend changes, so web/dist must be rebuilt (npm run build) before go build for them to land in the binary. Attribution logic runs on the master.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/MHSanaei/3x-ui/pull/5488 **Author:** [@MHSanaei](https://github.com/MHSanaei) **Created:** 6/22/2026 **Status:** ✅ Merged **Merged:** 6/22/2026 **Merged by:** [@MHSanaei](https://github.com/MHSanaei) **Base:** `main` ← **Head:** `fix/cloned-node-duplicate-guid` --- ### 📝 Commits (10+) - [`af94179`](https://github.com/MHSanaei/3x-ui/commit/af941798c67ec65ed056db05c7052ccd9d30e4ec) fix(nodes): keep cloned nodes (shared panelGuid) in separate attribution buckets - [`98c9ba1`](https://github.com/MHSanaei/3x-ui/commit/98c9ba1f91247b21b2654e657bc26f5d4b787143) fix(nodes): extend duplicate-GUID hardening to master collisions, IP attribution, and a heartbeat warning - [`846b8b3`](https://github.com/MHSanaei/3x-ui/commit/846b8b338ecd90bbf53b3d1adc368df588fab25b) fix(node-sync): log the client-IP-attribution 404 once per node, not every cycle - [`7458ed4`](https://github.com/MHSanaei/3x-ui/commit/7458ed406447126672ecddb3a4c2c02009bff29f) fix(nodes): remap a cloned node's own-panelGuid origin so the inbound page shows online - [`e0ac65a`](https://github.com/MHSanaei/3x-ui/commit/e0ac65a05f6f0625f4ee956a1fe7740e885feb18) fix(node-sync): don't delete a node's central inbounds when its snapshot is empty - [`5aa8777`](https://github.com/MHSanaei/3x-ui/commit/5aa87774d7c5497faee8470444f95f419dc5b7db) fix(email): stay silent when SMTP notifications are disabled - [`f96e877`](https://github.com/MHSanaei/3x-ui/commit/f96e877370febbbc7df7975b3467dd0a6465f16e) fix(nodes): count only expired/exhausted as 'ended', not disabled clients - [`2ce5891`](https://github.com/MHSanaei/3x-ui/commit/2ce5891f5f1852b6d8f744ee43a00da6f789ae22) feat(nodes): show live speed for node-hosted inbounds - [`eedb65b`](https://github.com/MHSanaei/3x-ui/commit/eedb65bcc18d0b2203baecbedf8fd221c528c769) fix(nodes): normalize node-inbound speed by elapsed time to avoid recovery spikes - [`32e97cd`](https://github.com/MHSanaei/3x-ui/commit/32e97cda5a018d6dec637d9825c9a7391eab4c84) fix(inbounds): keep last speed across page navigation instead of blanking ### 📊 Changes **21 files changed** (+891 additions, -146 deletions) <details> <summary>View changed files</summary> 📝 `frontend/public/openapi.json` (+12 -0) 📝 `frontend/src/generated/examples.ts` (+2 -0) 📝 `frontend/src/generated/schemas.ts` (+10 -0) 📝 `frontend/src/generated/types.ts` (+2 -0) 📝 `frontend/src/generated/zod.ts` (+2 -0) 📝 `frontend/src/pages/inbounds/list/InboundList.tsx` (+6 -1) 📝 `frontend/src/pages/inbounds/list/useInboundColumns.tsx` (+12 -12) 📝 `frontend/src/pages/inbounds/useInbounds.ts` (+44 -16) 📝 `frontend/src/pages/nodes/NodeList.tsx` (+30 -9) 📝 `frontend/src/schemas/node.ts` (+2 -0) 📝 `internal/database/model/model.go` (+2 -0) 📝 `internal/web/job/node_traffic_sync_job.go` (+105 -7) 📝 `internal/web/service/email/subscriber.go` (+3 -0) 📝 `internal/web/service/inbound_node.go` (+60 -12) 📝 `internal/web/service/inbound_node_ips.go` (+31 -7) 📝 `internal/web/service/inbound_node_ips_test.go` (+2 -2) 📝 `internal/web/service/node.go` (+180 -52) ➕ `internal/web/service/node_client_breakdown_test.go` (+87 -0) 📝 `internal/web/service/node_origin_guid_test.go` (+98 -0) ➕ `internal/web/service/node_shared_guid_test.go` (+162 -0) _...and 1 more files_ </details> ### 📄 Description Fixes a cluster of multi-node panel issues found while debugging a fleet whose nodes were cloned from one disk image (so they share a `panelGuid`) and whose inbounds had been delete+recreated. Centered on node attribution, but also brings the **Nodes page** client display to parity with the **Inbounds page** and hardens the node sync. ## 1. Cloned / duplicate-`panelGuid` attribution (#4983 hardening) `#4983` keys online + inbound + IP attribution by `panelGuid`, assuming it's globally unique. Cloned node servers ship an identical `panelGuid`, which collapsed several physical nodes into one bucket (online cross-attributed, counts merged). - Treat a `panelGuid` as **ambiguous** when more than one direct node reports it, or it equals the master's own `panelGuid`, and fall back to a node-unique key. Applied consistently to `origin_node_guid`, the online tree (+ self-key remap), `effectiveNodeGuid`, GUID-keyed IP attribution, and node deletion. `sharedNodeGuids`/`ambiguousNodeGuids` compute the collision set. - Remap a node's **own-`panelGuid` origin**: these builds report their own inbounds' origin as their (shared) `panelGuid`, so `origin_node_guid` stayed the shared value while online was keyed by the node-unique key — the inbound page then read an empty bucket and showed everyone offline. Now resolved through the same key. - Throttled **heartbeat warning** when a node reports a `panelGuid` already used by another node or the master, so the operator knows to regenerate it. ## 2. Node-hosted inbound display parity - **Speed** for node-hosted inbounds: the dashboard derives speed from a `traffics` delta feed that only the local Xray poll produced. The node sync now diffs per-inbound cumulative totals and broadcasts `nodeTraffics`; the frontend applies `traffics` to local inbounds and `nodeTraffics` to node inbounds within their own scope (no clobbering). Deltas are **normalized by real elapsed time** so a node recovering from an outage shows its average rate, not an impossible one-tick spike. Speed is also cached across page navigation so it no longer blanks for a poll on return. - **Active / Disabled / Ended counts** on the Nodes page, matching the Inbounds page (depleted = expired/exhausted only; disabled is its own bucket). - These counts are classified by **client email**, not `client_traffics.inbound_id` — that column goes stale after an inbound is delete+recreated, so filtering by it dropped almost every row and undercounted (active showed ~5 instead of ~1100). ## 3. Node-sync robustness & log noise - **Don't delete a node's central inbounds when its snapshot is empty.** A node mid-restart / with a transient DB error can return an empty inbound list with `success=true`, which previously wiped its central inbounds and all their clients (observed: a node showing 0 clients but still online). - Log the old-build `clientIpsByGuid` **404 once per node** (re-armed on recovery) instead of every ~10s cycle. ## 4. UI / layout - Rebalance the Inbounds table column widths so it fills width without gaps. - Widen the Nodes "Clients" column and tighten the chip padding so the count chips render on one tidy line like the Inbounds list. ## 5. Unrelated small fix - Email subscriber stays silent when SMTP notifications are disabled (it was attempting a send on every login and logging "smtp host not configured"). ## Tests Added coverage for the ambiguity disambiguation (node-vs-node and node-vs-master), `effectiveNodeKey`, the per-node count split, the empty-snapshot guard, the cloned-node origin remap, and the email-based breakdown (proven against a deliberately stale `inbound_id`). `go build`, `go vet`, the full `service`/`job` suites, and the frontend typecheck pass. > Note: includes frontend changes, so `web/dist` must be rebuilt (`npm run build`) before `go build` for them to land in the binary. Attribution logic runs on the master. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-02 04:04:52 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#5898
No description provided.