mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-10-12 17:05:01 +03:00
1edb8b31bc
* fix(xray): keep balancer overrides across routing reloads A balancer override set from the panel lived only inside the running core. Every routing hot-apply (any Xray-settings save touching rules or balancers) and every node test through an outbound calls RoutingService.AddRule with shouldAppend=false, which rebuilds all balancers, so the override vanished silently even though the API docs promised it lasted until an Xray restart. The panel now records the overrides it sets, per core process, and re-applies them after its own routing reloads. Targets are validated against the running config: the core accepts any tag and then closes every connection routed to one it lacks, so an unknown target is refused, and an override whose outbound is removed is cleared instead of black-holing the balancer. Balancer targets resolve to their _bl_ loopback from the running config rather than the saved template. Restarting Xray still clears overrides, as documented. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KrJrzn9LKaPhMq9h3Fb5TV * fix(xray): serialize overrides and the node bridge with config applies Review of #6779 found two races. Neither path took the package lock that RestartXray holds while it changes the running core: - An override landing mid hot-apply was checked against the config snapshot the apply was replacing, so it could pin a balancer to an outbound the core had just removed. OverrideBalancer now takes the lock. - The node bridge's teardown checked overrides against the snapshot it took before the probe, which can run for seconds, so it dropped an override set meanwhile onto a newly saved outbound. The same stale snapshot drove the bridge's routing restore. That restore silently reverted rule changes saved during a probe. After a restart, it also pushed the old core's rules and overrides into the new core through the shared API port. The bridge is now built and torn down under the lock, which is not held while the probe runs. At teardown it restores the routing that the core's config holds then, and it leaves alone a core that was restarted meanwhile. With every caller under the package lock, balancerOverrideSet drops its own mutex.