Changes from Build 12
Ignore iOS sleep()/wake() to prevent connection thrashing
iOS was calling sleep()/wake() extremely aggressively — observed 105 events per hour with cycles as short as 0.5s. Each sleep() triggered a full teardown of all 10 DTLS+TURN connections, and each wake() rebuilt them from scratch, re-fetching VK credentials and solving a fresh slider captcha every time. Cycles shorter than a rebuild made the tunnel permanently unstable (870 total sessions, 94 captcha solves in one test hour).
sleep()/wake() are now no-ops in PacketTunnelProvider. TURN allocations have a 10-minute lifetime so they survive short iOS freezes; DTLS connection IDs let the peer tolerate source port changes. The existing watchdog (2-minute lastRecvTime threshold) remains as a safety net for genuinely dead tunnels.
Probe checkbox captcha at most once per global session
Once VK starts returning status=ERROR on the checkbox captchaNotRobot.check step, it keeps doing so until the app disconnects. A package-level atomic flag is now set the first time the check returns non-OK, and every subsequent solveCaptchaPoW call in the same connect cycle skips the wait + check call and jumps straight to the slider solver — saving ~2-3 seconds per captcha session.
Diagnostic logging for runDTLSSession and runTURN
Every goroutine exit path in runDTLSSession and runTURN now logs its error along with ctx.Err() state. pion 'Failed to read' / 'Exiting loop' debug messages are no longer filtered. This already revealed the root cause of the mysterious simultaneous death of all 10 sessions: WiFi→cellular handoff invalidates all connectedUDPConn source addresses at once, returning 'can't assign requested address' from WriteTo. The recovery path (new creds + TURN reallocation + slider captcha) now works autonomously while the phone is asleep.
Test results
1+ hour test on iPhone SE3 with sleep/wake, WiFi↔cellular handoffs, and long idle periods:
- Reconnects = 10 (one per connection during a single WiFi→cellular handoff)
- Captcha solves = 2-3 total (vs 94 in build 12)
- conns 10/10 stable throughout
- Zero unexplained cascades