fix: stop VPN core when signaling auth fails - #3
Merged
Conversation
1.3.0 waited on signaling auth in Start() after opening the WebSocket, but auth failure or timeout returned without closing it. Connect then dropped the core without Stop(), so zombie sessions survived retries. Close that attempt on Start and reconnectLoop, and Stop the core when Connect fails. Co-authored-by: Warexpor <warexpor@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
1.3.0 made
VPNCore.Start()wait for signaling auth (authOK/authErr/ 15s timeout).connectSignaling()assignsv.signalingand opens the WebSocket before that wait. On auth failure or timeout,Start()returned the error without closing signaling.App.Connectthen wired and assigneda.vpn = newVPN, callednewVPN.Start(), and on error only nileda.vpnif it still pointed at that core. It never callednewVPN.Stop().The live
SignalingClient(and wired callbacks) survived a failed Connect. Disconnect could not clean it up becausea.vpnwas nil. Retrying Connect stacked more zombie sessions.OnDisconnectedon an orphaned core could also startreconnectLoop.reconnectLoophad the same hole: afterconnectSignaling()succeeded, auth failure/timeoutcontinued without closing that attempt’s WebSocket, so the next try opened another one.Fix
client/app.goConnect— ifnewVPN.Start()fails, nila.vpnwhen it still points atnewVPN, then callnewVPN.Stop().opMuis unchanged.client/vpncore/vpn.goStart— on auth error or auth timeout, callStop()before returning so signaling, TUN, and peers tear down.Stopalso nilsv.signalingso room ops fail with “not connected” instead of talking to a closed socket.reconnectLoop— on auth failure or timeout,closeSignalingAttempt()closes and nils that try’s signaling beforecontinue. That helper does not setstopping, so reconnect can still retry.Test
client/vpncore/lifecycle_test.gonow drives a local WebSocket that rejects auth.Startmust fail, the server must drop to zero live connections, andCreateRoom/JoinRoommust still fail. A second case checks thatStopafter a failed dial is safe to call twice.No version bump, changelog, or UI changes.