From 9ef9ffdbde37282f0240d7a19101801fdad71d8c Mon Sep 17 00:00:00 2001 From: mwiegand Date: Thu, 14 May 2026 21:24:41 +0200 Subject: [PATCH] chore(l4d2-web): clarify rcon req_id constants and helper docstring Add comment noting _EXEC_REQ_ID/_MARKER_REQ_ID are arbitrary client-chosen values unrelated to SERVERDATA_* packet-type constants. Update _connect_and_auth docstring to accurately reflect that OSError/socket.timeout propagate raw from post-connect send/recv, while only connect failure is wrapped in RconError. Co-Authored-By: Claude Sonnet 4.6 --- l4d2web/services/rcon.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/l4d2web/services/rcon.py b/l4d2web/services/rcon.py index 49bb699..19bd2cf 100644 --- a/l4d2web/services/rcon.py +++ b/l4d2web/services/rcon.py @@ -32,7 +32,9 @@ SERVERDATA_EXECCOMMAND = 2 SERVERDATA_AUTH_RESPONSE = 2 SERVERDATA_RESPONSE_VALUE = 0 -# req_id values used by execute_command +# req_id values for execute_command's exec + marker packets. +# These are arbitrary positive ints chosen by the client; the values +# happen to be unrelated to the SERVERDATA_* packet-type constants. _EXEC_REQ_ID = 2 _MARKER_REQ_ID = 0xC0DE @@ -68,10 +70,13 @@ class StatusResponse: def _connect_and_auth( sock: socket.socket, host: str, port: int, password: str ) -> None: - """Open TCP connection and authenticate. Raises: + """Open TCP connection and authenticate. - * RconError – on connect failure or i/o error during handshake - * RconAuthError – when the server returns req_id == -1 (bad password) + Raises: + RconError – on connect failure + RconAuthError – when the server returns req_id == -1 (bad password) + OSError / socket.timeout – raw, from the post-connect send/recv; + callers wrap these into RconError. """ try: sock.connect((host, port))