Commit Graph
7 Commits
  • fix(node): import a newly selected node inbound instead of sweeping it
    Saving the node form writes the grown selection and marks the node dirty
    in one transaction. On the next tick ReconcileNode runs before the
    snapshot merge, and its delete sweep treats a selected tag with no
    central row as "deleted on the master" — so an inbound the operator just
    ticked in the picker (or every unselected one, when switching the node
    to "all") is deleted from the node before the import that would have
    created its row ever runs.
    
    Nothing on disk separates "pending import" from "deleted while the node
    was unreachable", but the pre-adoption guard already expresses the
    former: while inbounds_adopted_at is zero the sweep waits for a clean
    sync to adopt. A save that grows the managed set now zeroes it again,
    and the same clean sync re-stamps it, so the offline-delete sweep is
    only deferred by one successful sync, not disabled.
    
    The trade: an inbound deleted on the master while the node was
    unreachable is re-imported instead of swept if the operator grows the
    node's selection during that same outage. That is visible and
    recoverable, where the previous behaviour destroyed a live inbound.
    
    Closes #6329
  • fix(node): sweep a selected inbound the node reports without its prefix
    In "selected" sync mode the reconcile sweep built its set of managed tags
    verbatim from node.InboundTags. A panel-created node inbound is stored with
    an n<id>- prefix (composeInboundTag) and pushed to the node with that prefix
    stripped (wireInbound), so the tag the node reports never matched the set and
    the sweep skipped it.
    
    The effect is the case the sweep exists for: an operator deletes a node
    inbound while the node is offline, and the node keeps serving it — and its
    clients — indefinitely. Only unprefixed tags were unaffected, which is why
    the existing selected-mode test did not catch it.
    
    nodeSelectedTagSet already builds both tag forms for exactly this reason and
    is used by the snapshot filter; the sweep now uses it too, so the two agree.
  • fix(node): adopt a matching deployed inbound instead of recreating it (#6197)
    * fix(node): adopt compatible origin inbounds without mutation
    
    * fix(nodes): preserve ambiguous and adopted aliases
    
    ---------
    
    Co-authored-by: n0ctal <293235942+n0ctal@users.noreply.github.com>
  • fix(node): never sweep a node's inbounds before their first adoption
    Adding a node imports nothing; its pre-existing inbounds only become
    central rows on the first clean traffic-sync tick. But any save of the
    node (switching sync mode, picking tags after "Load inbounds from
    node") marks it config-dirty, and the next tick then ran ReconcileNode
    before that first adoption: with zero central rows the delete sweep saw
    every remote tag as undesired and destroyed the node's real inbounds -
    in "all" mode all of them - disconnecting live clients with no
    confirmation, and the master then reported "record not found".
    
    Track the first completed clean sync in nodes.inbounds_adopted_at and
    skip the sweep (pushes still run) until it is set, so "absent locally"
    can no longer be conflated with "deleted on the master". A node that
    has synced before still sweeps normally, including the offline
    last-inbound-deleted case. Existing nodes are seeded as adopted on
    upgrade to keep their behavior unchanged.
    
    Closes #5898
  • fix(node): stop one rejected inbound from starving a node's traffic sync
    A legacy socks inbound (predating the socks-to-mixed protocol rename) fails the node's request validation when pushed. ReconcileNode aborted on the first failed inbound and syncOne then skipped the traffic snapshot entirely and never cleared ConfigDirty, so the whole node re-failed every tick and the master stopped deducting traffic for every client on that node, exactly as reported in #5685.
    
    Three-part fix: ReconcileNode now pushes every inbound and runs the delete sweep even past individual failures, returning the failures joined; syncOne logs a failed reconcile but continues with the traffic pull (dirty stays set, so reconcile retries and the merge stays in its conservative mode); and a migration renames legacy socks inbounds to mixed, which has an identical settings shape, removing the known trigger.
    
    Closes #5685
  • feat(node): per node outbound routing (#5275)
    * feat: add per-node outbound routing for panel-to-node connections
    
    * feat(ui): add outbound tag selector to node form with i18n
    
    * fix(xray): avoid potential overflow warning in node egress rule allocation
    
    * chore: run "npm run gen"
    
    * fix
    
    ---------
    
    Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>
  • feat: allow selecting inbounds synchronized from nodes (#5178)
    * feat: select node inbounds for synchronization
    
    Allow node owners to import either all remote inbounds or an explicit tag-based selection. Add remote inbound discovery, persistence, snapshot filtering, API documentation, tests, and localized UI labels.
    
    * fix
    
    * fix: scope node reconcile and orphan sweep to selected inbound tags
    
    In 'selected' sync mode unselected inbounds never enter the panel DB, so
    ReconcileNode treated them as undesired and deleted them from the node the
    first time it went config-dirty. Reconcile now only sweeps remote tags that
    are part of the selection; everything else on the node is unmanaged.
    
    Panel-created or renamed inbounds on a selected-mode node also vanished:
    their tag was outside the selection, so the next traffic pull filtered them
    out of the snapshot and the orphan sweep silently dropped the central row.
    AddInbound/UpdateInbound now allow the tag on the node before committing.
    
    ---------
    
    Co-authored-by: Sanaei <ho3ein.sanaei@gmail.com>