Skip to content

Commit 7677f9f

Browse files
author
Delta-Kronecker
committed
fix: tun-helper silently crashes — add top-level catch + diagnostic progress
Main() had try/finally but no catch: any unhandled exception in RunKeeper() killed the helper without writing an error to tun-result.txt, leaving the launcher stuck at 'enabling...'. - catch Ex -> write 'error: ExceptionType: message' to result file - two intermediate progress markers ('cleaning up', 'routing') so the launcher can show where TUN setup stalls
1 parent 908db2f commit 7677f9f

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

scripts/tun-helper.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ private static int RunKeeper()
403403
if (!TorUp(2000)) { WriteResult("error: tor SOCKS (127.0.0.1:9050) is not up"); return 1; }
404404
if (GetStateValue(ReadState(), "status") == "on") { WriteResult("error: TUN is already on"); return 1; }
405405

406+
WriteResult("enabling... (cleaning up)");
407+
406408
// Kill orphaned xray.exe from earlier attempts first: a stale
407409
// holder wedges wintun ("Failed to register rings") and every
408410
// later attempt times out. The only xray.exe on the system is
@@ -426,6 +428,7 @@ private static int RunKeeper()
426428
// physical gateway for the relay /32 routes (TUN is not up yet,
427429
// so the best route to 0/0 IS the physical default)
428430
MibIpForwardRow phys;
431+
WriteResult("enabling... (routing)");
429432
if (GetBestRoute(0, 0, out phys) != NO_ERROR)
430433
{
431434
WriteResult("error: no IPv4 default route");
@@ -520,6 +523,12 @@ private static int Main(string[] args)
520523
return 1;
521524
}
522525
try { return RunKeeper(); }
526+
catch (Exception ex)
527+
{
528+
try { WriteResult("error: " + ex.GetType().Name + ": " + ex.Message); }
529+
catch { }
530+
return 1;
531+
}
523532
finally { try { TunMutex.ReleaseMutex(); } catch { } }
524533
}
525534
if (arg == "off")

0 commit comments

Comments
 (0)