Skip to content

Commit 332c29e

Browse files
authored
Merge pull request #27 from hawkff/chore/ci-and-sidecar-hardening
bg: soften sidecar readiness gate for non-MasterDnsVPN sidecars
2 parents 972db68 + 3a4b855 commit 332c29e

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)