Skip to content

Commit 195fff1

Browse files
committed
review: cap strict (URL-test) readiness window so total stays bounded
Per Greptile: in strict mode the non-MasterDnsVPN readiness window reused the full connectionTestTimeout, so a slow-binding sidecar could roughly double the perceived URL-test duration (readiness wait + the test itself). Cap the strict readiness wait at min(2s, timeout); a healthy sidecar binds well under a second. MasterDnsVPN keeps its required 60s window.
1 parent e4cb8a8 commit 195fff1

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,11 @@ abstract class BoxInstance(
278278
}
279279
val readinessTimeoutMs = if (hasMasterDnsVpn) {
280280
maxOf(60_000L, DataStore.connectionTestTimeout.toLong())
281+
} else if (strict) {
282+
// URL test: a healthy sidecar binds well under a second. Cap the readiness
283+
// wait so a slow/unbound sidecar can't make the total perceived test time
284+
// roughly double the configured timeout (readiness wait + the url test itself).
285+
minOf(2_000L, maxOf(1_000L, DataStore.connectionTestTimeout.toLong()))
281286
} else {
282287
maxOf(1_000L, DataStore.connectionTestTimeout.toLong())
283288
}

0 commit comments

Comments
 (0)