Skip to content

Commit 9a0924b

Browse files
committed
Revert "Cap pre-auth handshake recv at 5 s so bad-protocol clients fail fast"
This reverts commit 9b9b1ff.
1 parent 9b9b1ff commit 9a0924b

2 files changed

Lines changed: 2 additions & 29 deletions

File tree

je_auto_control/utils/remote_desktop/host.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@
3838
InputDispatcher = Callable[[Mapping[str, Any]], Any]
3939

4040
_AUTH_TIMEOUT_S = 60.0
41-
# Ceiling for the pre-auth handshake step (TLS wrap + WS upgrade GET).
42-
# Legitimate handshakes complete in milliseconds; 5 s is generous enough
43-
# to absorb scheduler starvation on slow CI runners but short enough to
44-
# fast-fail when a client speaks the wrong protocol (e.g. plain-TCP auth
45-
# bytes hitting a WS server). Kept distinct from _AUTH_TIMEOUT_S so the
46-
# subsequent auth-message exchange retains its longer budget.
47-
_HANDSHAKE_RECV_TIMEOUT_S = 5.0
4841
_DEFAULT_QUALITY = 70
4942

5043

@@ -561,18 +554,6 @@ def _accept_loop(self) -> None:
561554
continue
562555
except OSError:
563556
return
564-
# accept() returns a new socket that INHERITS the listener's
565-
# 0.5 s timeout. That is fine for the accept poll itself but
566-
# fatally tight for the handshake that follows: a slow CI
567-
# runner can't deliver the TLS / WS upgrade request inside
568-
# 500 ms, the recv times out, server drops, and the client's
569-
# separate auth wait ticks down to its own timeout. Promote
570-
# to a handshake-specific budget — long enough for runner
571-
# starvation, short enough to fast-fail on protocol mismatch.
572-
try:
573-
client_sock.settimeout(_HANDSHAKE_RECV_TIMEOUT_S)
574-
except OSError:
575-
pass
576557
wrapped = self._maybe_wrap_tls(client_sock, address)
577558
if wrapped is None:
578559
continue
@@ -613,9 +594,7 @@ def _maybe_wrap_tls(self, client_sock: socket.socket,
613594
if self._ssl_context is None:
614595
return client_sock
615596
try:
616-
# Use the handshake-specific budget so a peer that never
617-
# speaks TLS (or cuts off mid-ClientHello) fails fast.
618-
client_sock.settimeout(_HANDSHAKE_RECV_TIMEOUT_S)
597+
client_sock.settimeout(_AUTH_TIMEOUT_S)
619598
wrapped = self._ssl_context.wrap_socket(
620599
client_sock, server_side=True,
621600
)

je_auto_control/utils/remote_desktop/ws_host.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@
1717
WsProtocolError, server_handshake,
1818
)
1919

20-
# Ceiling for the WS upgrade exchange. A legitimate handshake on
21-
# loopback completes in microseconds; 5 s easily absorbs scheduler
22-
# starvation on a loaded CI runner while still letting the server
23-
# fast-fail when a peer never sends "\r\n\r\n" (e.g. a plain-TCP
24-
# viewer pointed at a WS host). The auth exchange that follows uses
25-
# its own, much longer budget defined in :mod:`host`.
26-
_HANDSHAKE_TIMEOUT_S = 5.0
20+
_HANDSHAKE_TIMEOUT_S = 60.0
2721

2822

2923
class WebSocketDesktopHost(RemoteDesktopHost):

0 commit comments

Comments
 (0)