mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-08 03:07:15 +00:00
738163699e
Real production bug, found via a live test connection that reset every ~10 seconds: ensureLocked's reconfigure-in-place branch called IpcSet unconditionally on every Ensure, including AmneziaWGJob's routine 10s reconcile tick even when nothing in the DB had changed. amneziawg-go's IpcSet always includes replace_peers=true (buildUAPIConfig), and its own handling of that op is device.RemoveAllPeers() -- unconditional, even when the new peer list is byte-identical to the old one. So every tick tore down and recreated every peer's live handshake/session state, and no connection could ever survive past one reconcile cycle. Root-caused with AMNEZIAWGNET_DEBUG (previous commit) showing "UAPI: Removing all peers" + peer Stopping/Starting exactly ~10s after a real handshake completed, matching AmneziaWGJob's own cadence precisely. Fixed by comparing the freshly rendered UAPI config string against what was last actually applied and skipping IpcSet entirely when identical -- reusing buildUAPIConfig's own exhaustive field coverage instead of a hand-maintained fingerprint that could drift out of sync with it. TestEnsureUnchangedInstanceDoesNotResetLivePeers verifies via device.LookupPeer pointer identity (confirmed to fail without this fix, not just pass trivially with it).