mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-07-22 12:36:07 +00:00
fix(node-sync): don't delete a node's central inbounds when its snapshot is empty
The central-inbound sweep deletes any central inbound whose tag is absent from the node's snapshot, with no guard for an empty snapshot. A node mid-restart or with a transient DB error (e.g. Postgres 57P01) can return an empty inbound list with success=true, which wiped all of that node's central inbounds and their clients (and reset traffic history on re-create) — observed on the Germany node: 0 clients but still 44 online (online survives because it comes from the snapshot's online tree, not the central inbound). Skip the sweep entirely when the snapshot reports zero inbounds; a real per-inbound deletion still sweeps via a non-empty snapshot that omits one tag.
This commit is contained in:
@@ -499,6 +499,15 @@ func (s *InboundService) setRemoteTrafficLocked(nodeID int, snap *runtime.Traffi
|
||||
if dirty {
|
||||
continue
|
||||
}
|
||||
if len(snapTags) == 0 {
|
||||
// A node mid-restart or with a transient DB error can return an empty
|
||||
// inbound list with success=true. Treat "zero inbounds reported" as
|
||||
// "nothing to say", not "delete all my inbounds" — otherwise a blip
|
||||
// wipes the node's central inbounds and every client on them (and
|
||||
// resets traffic history on re-create). A real per-inbound deletion
|
||||
// still sweeps, because the node keeps reporting its other inbounds.
|
||||
continue
|
||||
}
|
||||
if _, kept := snapTags[c.Tag]; kept {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user