-
Notifications
You must be signed in to change notification settings - Fork 0
bg: soften sidecar readiness gate for non-MasterDnsVPN sidecars #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -294,7 +294,16 @@ abstract class BoxInstance( | |
| if (pending.isNotEmpty()) delay(50) | ||
| } | ||
| if (pending.isNotEmpty()) { | ||
| throw IOException("sidecar listener not ready on port(s): ${pending.joinToString()}") | ||
| // MasterDnsVPN must have its listener up before the first dial (it crashed | ||
| // otherwise), so a timeout there is fatal. Other sidecars (Mieru/Naïve/ | ||
| // TrojanGo/Hysteria) were historically fire-and-forget: the first sing-box | ||
| // dial retries, so a slow bind shouldn't hard-fail VPN start — log and continue. | ||
| val message = "sidecar listener not ready on port(s): ${pending.joinToString()}" | ||
| if (hasMasterDnsVpn) { | ||
| throw IOException(message) | ||
| } else { | ||
| Logs.w("$message; continuing (sing-box will retry the connection)") | ||
| } | ||
|
Comment on lines
296
to
+306
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Condition checks whether MasterDnsVPN is configured, not whether it failed to bind. The Current behavior: If MasterDnsVPN is configured and binds successfully, but another sidecar (e.g., Mieru) is slow, the code still throws because 🐛 Proposed fix to check pending ports specifically if (pending.isNotEmpty()) {
- // MasterDnsVPN must have its listener up before the first dial (it crashed
- // otherwise), so a timeout there is fatal. Other sidecars (Mieru/Naïve/
- // TrojanGo/Hysteria) were historically fire-and-forget: the first sing-box
- // dial retries, so a slow bind shouldn't hard-fail VPN start — log and continue.
+ // MasterDnsVPN must have its listener up before the first dial (it crashes
+ // otherwise), so a timeout on its port is fatal. Other sidecars (Mieru/Naïve/
+ // TrojanGo/Hysteria) were historically fire-and-forget: sing-box retries,
+ // so a slow bind shouldn't hard-fail VPN start — log and continue.
+ val masterDnsVpnPorts = config.externalIndex.flatMap { idx ->
+ idx.chain.entries
+ .filter { it.value.requireBean() is MasterDnsVpnBean }
+ .map { it.key }
+ }.toSet()
+ val hasPendingMasterDnsVpn = pending.any { it in masterDnsVpnPorts }
val message = "sidecar listener not ready on port(s): ${pending.joinToString()}"
- if (hasMasterDnsVpn) {
+ if (hasPendingMasterDnsVpn) {
throw IOException(message)
} else {
Logs.w("$message; continuing (sing-box will retry the connection)")
}
}🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.