From 2c608af8bd5860517013814f17e2172d8e255cc8 Mon Sep 17 00:00:00 2001 From: philippj Date: Thu, 20 May 2021 21:12:09 +0200 Subject: [PATCH] Fixed a typo and added support for new A2S Info challenge #298 --- steam/game_servers.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/steam/game_servers.py b/steam/game_servers.py index e76c6b5..3ac54b6 100644 --- a/steam/game_servers.py +++ b/steam/game_servers.py @@ -242,7 +242,7 @@ def _handle_a2s_response(sock): sock.settimeout(0.3) return _handle_a2s_multi_packet_response(sock, packet) else: - raise RuntimeError("Invalid reponse header - %d" % header) + raise RuntimeError("Invalid response header - %d" % header) def _handle_a2s_multi_packet_response(sock, packet): @@ -305,7 +305,7 @@ def _unpack_multipacket_header(payload_offset, packet): raise RuntimeError("Unexpected payload_offset - %d" % payload_offset) -def a2s_info(server_addr, timeout=2, force_goldsrc=False): +def a2s_info(server_addr, timeout=2, force_goldsrc=False, challenge=0): """Get information from a server .. note:: @@ -320,6 +320,8 @@ def a2s_info(server_addr, timeout=2, force_goldsrc=False): :type force_goldsrc: :class:`bool` :param timeout: (optional) timeout in seconds :type timeout: float + :param challenge: (optional) optionally supply a challenge in accordance to a2s protocol changes from December 2020 + :type challenge: int :raises: :class:`RuntimeError`, :class:`socket.timeout` :returns: a dict with information or `None` on timeout :rtype: :class:`dict` @@ -329,7 +331,11 @@ def a2s_info(server_addr, timeout=2, force_goldsrc=False): ss.settimeout(timeout) # request server info - ss.send(_pack('