Skip to content

Commit 3a4b855

Browse files
committed
bg: soften sidecar readiness gate for non-MasterDnsVPN sidecars
awaitExternalProcessesReady previously threw IOException (hard VPN-start failure) for any sidecar that didn't bind within maxOf(1s, connectionTestTimeout). MasterDnsVPN genuinely needs that gate (it crashed if dialed before binding), but Mieru/Naive/TrojanGo/Hysteria were historically fire-and-forget with first-dial retry. Now only MasterDnsVPN throws on timeout; the others log a warning and continue. (Greptile, PR #18 follow-up)
1 parent 972db68 commit 3a4b855

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

app/src/main/java/io/nekohasekai/sagernet/bg/proto/BoxInstance.kt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,16 @@ abstract class BoxInstance(
294294
if (pending.isNotEmpty()) delay(50)
295295
}
296296
if (pending.isNotEmpty()) {
297-
throw IOException("sidecar listener not ready on port(s): ${pending.joinToString()}")
297+
// MasterDnsVPN must have its listener up before the first dial (it crashed
298+
// otherwise), so a timeout there is fatal. Other sidecars (Mieru/Naïve/
299+
// TrojanGo/Hysteria) were historically fire-and-forget: the first sing-box
300+
// dial retries, so a slow bind shouldn't hard-fail VPN start — log and continue.
301+
val message = "sidecar listener not ready on port(s): ${pending.joinToString()}"
302+
if (hasMasterDnsVpn) {
303+
throw IOException(message)
304+
} else {
305+
Logs.w("$message; continuing (sing-box will retry the connection)")
306+
}
298307
}
299308
}
300309
}

0 commit comments

Comments
 (0)