From f55275a627f006efabd88a41402c240737c93906 Mon Sep 17 00:00:00 2001 From: Sunpy Date: Sun, 29 Mar 2020 23:43:08 +0200 Subject: [PATCH] Preparement for rcon support --- config.json | 1 + sampy/client/query.py | 34 ++++++++++++++++++++-------------- sampy/server.py | 3 ++- sampy/struct/server.py | 3 +++ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/config.json b/config.json index 6b9d7fa..69ef3bc 100644 --- a/config.json +++ b/config.json @@ -14,6 +14,7 @@ "port": 7777, "hostname": "Python > C", "password": "", + "rcon_password": "changeme", "max_players": 50, "mode": "debug", "language": "python" diff --git a/sampy/client/query.py b/sampy/client/query.py index a61ece0..9993b86 100644 --- a/sampy/client/query.py +++ b/sampy/client/query.py @@ -16,24 +16,14 @@ class QueryClient(BaseClient): b"i": self.query_i, b"r": self.query_r, b"c": self.query_c, - b"d": self.query_d + b"d": self.query_d, + b"p": self.query_p, + b"x": self.query_x } async def on_packet(self, packet: bytes): logger.debug("on_packet(%s)" % packet) - """ - if len(packet) != 11: # Just a ping with some random numbers at the end (14 bytes in total) - await self.send(packet) - return - """ - # ip ~~and port~~ the client connected to; (would be server ip ~~and port~~ if not though proxy) - # This could be used to check if client connected remotely in some way though a proxy - # SA:MP default server drops the connection if port does not match (when its client (not query protocol)) - #server_ip = ".".join((str(x) for x in struct.unpack(b"<4B", packet[4:8]))) - #server_port, = struct.unpack(b" bytes: - return packet \ No newline at end of file + return packet + + async def query_x(self, packet: bytes) -> bytes: + len_pswd, = struct.unpack_from(b"