diff --git a/opengsq/protocol_socket.py b/opengsq/protocol_socket.py index 9e65821..d10b975 100644 --- a/opengsq/protocol_socket.py +++ b/opengsq/protocol_socket.py @@ -100,10 +100,10 @@ def error_received(self, exc): pass -class UDPClient(Socket): +class UdpClient(Socket): @staticmethod async def communicate(protocol: ProtocolBase, data: bytes): - with UDPClient() as udpClient: + with UdpClient() as udpClient: udpClient.settimeout(protocol._timeout) await udpClient.connect((protocol._host, protocol._port)) udpClient.send(data) @@ -113,10 +113,10 @@ def __init__(self): super().__init__(SocketKind.SOCK_DGRAM) -class TCPClient(Socket): +class TcpClient(Socket): @staticmethod async def communicate(protocol: ProtocolBase, data: bytes): - with TCPClient() as tcpClient: + with TcpClient() as tcpClient: tcpClient.settimeout(protocol._timeout) await tcpClient.connect((protocol._host, protocol._port)) tcpClient.send(data) diff --git a/opengsq/protocols/ase.py b/opengsq/protocols/ase.py index 94f74a2..835aa79 100644 --- a/opengsq/protocols/ase.py +++ b/opengsq/protocols/ase.py @@ -1,7 +1,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.exceptions import InvalidPacketException from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import UDPClient +from opengsq.protocol_socket import UdpClient class ASE(ProtocolBase): @@ -12,7 +12,7 @@ class ASE(ProtocolBase): _response = b'EYE1' async def get_status(self) -> dict: - response = await UDPClient.communicate(self, self._request) + response = await UdpClient.communicate(self, self._request) header = response[:4] if header != self._response: diff --git a/opengsq/protocols/battlefield.py b/opengsq/protocols/battlefield.py index 44a688e..4487a04 100644 --- a/opengsq/protocols/battlefield.py +++ b/opengsq/protocols/battlefield.py @@ -1,6 +1,6 @@ from opengsq.binary_reader import BinaryReader from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import TCPClient +from opengsq.protocol_socket import TcpClient class Battlefield(ProtocolBase): @@ -72,7 +72,7 @@ async def get_players(self) -> list: return players async def __get_data(self, request: bytes): - response = await TCPClient.communicate(self, request) + response = await TcpClient.communicate(self, request) return self.__decode(response) def __decode(self, response: bytes): diff --git a/opengsq/protocols/doom3.py b/opengsq/protocols/doom3.py index d0a7f0e..a215d38 100644 --- a/opengsq/protocols/doom3.py +++ b/opengsq/protocols/doom3.py @@ -3,7 +3,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.exceptions import InvalidPacketException from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import UDPClient +from opengsq.protocol_socket import UdpClient class Doom3(ProtocolBase): @@ -18,7 +18,7 @@ class Doom3(ProtocolBase): async def get_info(self, strip_color=True): request = b'\xFF\xFFgetInfo\x00ogsq\x00' - response = await UDPClient.communicate(self, request) + response = await UdpClient.communicate(self, request) # Remove the first two 0xFF br = BinaryReader(response[2:]) diff --git a/opengsq/protocols/gamespy1.py b/opengsq/protocols/gamespy1.py index e825e3c..85a82da 100644 --- a/opengsq/protocols/gamespy1.py +++ b/opengsq/protocols/gamespy1.py @@ -2,7 +2,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import UDPClient +from opengsq.protocol_socket import UdpClient class GameSpy1(ProtocolBase): @@ -74,7 +74,7 @@ async def get_teams(self) -> list: return self.__parse_as_object(await self.__connect_and_send(self.__Request.TEAMS)) # Receive packets and sort it - async def __get_packets_response(self, udpClient: UDPClient): + async def __get_packets_response(self, udpClient: UdpClient): payloads = {} packet_count = -1 @@ -104,7 +104,7 @@ async def __get_packets_response(self, udpClient: UDPClient): async def __connect_and_send(self, data) -> BinaryReader: # Connect to remote host - with UDPClient() as udpClient: + with UdpClient() as udpClient: udpClient.settimeout(self._timeout) await udpClient.connect((self._host, self._port)) diff --git a/opengsq/protocols/gamespy2.py b/opengsq/protocols/gamespy2.py index 6a3cb8c..6581287 100644 --- a/opengsq/protocols/gamespy2.py +++ b/opengsq/protocols/gamespy2.py @@ -2,7 +2,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import UDPClient +from opengsq.protocol_socket import UdpClient class GameSpy2(ProtocolBase): @@ -17,7 +17,7 @@ class Request(Flag): async def get_status(self, request: Request = Request.INFO | Request.PLAYERS | Request.TEAMS) -> dict: """Retrieves information about the server including, Info, Players, and Teams.""" data = b'\xFE\xFD\x00\x04\x05\x06\x07' + self.__get_request_bytes(request) - response = await UDPClient.communicate(self, data) + response = await UdpClient.communicate(self, data) # Remove the first 5 bytes { 0x00, 0x04, 0x05, 0x06, 0x07 } br = BinaryReader(response[5:]) diff --git a/opengsq/protocols/gamespy3.py b/opengsq/protocols/gamespy3.py index 9def5bd..25690af 100644 --- a/opengsq/protocols/gamespy3.py +++ b/opengsq/protocols/gamespy3.py @@ -3,7 +3,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.exceptions import InvalidPacketException from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import UDPClient +from opengsq.protocol_socket import UdpClient class GameSpy3(ProtocolBase): @@ -14,7 +14,7 @@ class GameSpy3(ProtocolBase): async def get_status(self): """Retrieves information about the server including, Info, Players, and Teams.""" # Connect to remote host - with UDPClient() as udpClient: + with UdpClient() as udpClient: udpClient.settimeout(self._timeout) await udpClient.connect((self._host, self._port)) @@ -76,7 +76,7 @@ async def get_status(self): return result - async def __read(self, udpClient: UDPClient) -> bytes: + async def __read(self, udpClient: UdpClient) -> bytes: packet_count = -1 payloads = {} diff --git a/opengsq/protocols/minecraft.py b/opengsq/protocols/minecraft.py index 5352512..0c5ffa7 100644 --- a/opengsq/protocols/minecraft.py +++ b/opengsq/protocols/minecraft.py @@ -5,7 +5,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.exceptions import InvalidPacketException from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import TCPClient +from opengsq.protocol_socket import TcpClient class Minecraft(ProtocolBase): @@ -29,7 +29,7 @@ async def get_status(self, version=47, strip_color=True) -> dict: request = b'\x00' + protocol + self._pack_varint(len(address)) + address + struct.pack('H', self._port) + b'\x01' request = self._pack_varint(len(request)) + request + b'\x01\x00' - with TCPClient() as tcpClient: + with TcpClient() as tcpClient: tcpClient.settimeout(self._timeout) await tcpClient.connect((self._host, self._port)) tcpClient.send(request) @@ -71,7 +71,7 @@ async def get_status(self, version=47, strip_color=True) -> dict: async def get_status_pre17(self, strip_color=True) -> dict: """Get ping info from a server that uses a version older than Minecraft 1.7""" - response = await TCPClient.communicate(self, b'\xFE\x01') + response = await TcpClient.communicate(self, b'\xFE\x01') br = BinaryReader(response) header = br.read_byte() diff --git a/opengsq/protocols/quake1.py b/opengsq/protocols/quake1.py index c4b258d..e5ad9b1 100644 --- a/opengsq/protocols/quake1.py +++ b/opengsq/protocols/quake1.py @@ -2,7 +2,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import UDPClient +from opengsq.protocol_socket import UdpClient class Quake1(ProtocolBase): @@ -89,7 +89,7 @@ def _get_player_match_collections(self, br: BinaryReader): async def _connect_and_send(self, data): header = b'\xFF\xFF\xFF\xFF' - response_data = await UDPClient.communicate(self, header + data + b'\x00') + response_data = await UdpClient.communicate(self, header + data + b'\x00') # Remove the last 0x00 if exists (Only if Quake1) if response_data[-1] == 0: diff --git a/opengsq/protocols/raknet.py b/opengsq/protocols/raknet.py index 8471a6d..b8fa8e1 100644 --- a/opengsq/protocols/raknet.py +++ b/opengsq/protocols/raknet.py @@ -1,7 +1,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.exceptions import InvalidPacketException from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import UDPClient +from opengsq.protocol_socket import UdpClient class Raknet(ProtocolBase): @@ -16,7 +16,7 @@ class Raknet(ProtocolBase): async def get_status(self) -> dict: request = self.__ID_UNCONNECTED_PING + self.__TIMESTAMP + self.__OFFLINE_MESSAGE_DATA_ID + self.__CLIENT_GUID - response = await UDPClient.communicate(self, request) + response = await UdpClient.communicate(self, request) br = BinaryReader(response) header = br.read_bytes(1) diff --git a/opengsq/protocols/samp.py b/opengsq/protocols/samp.py index 0a80b9a..ebd435a 100644 --- a/opengsq/protocols/samp.py +++ b/opengsq/protocols/samp.py @@ -3,7 +3,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.exceptions import InvalidPacketException from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import Socket, UDPClient +from opengsq.protocol_socket import Socket, UdpClient class Samp(ProtocolBase): @@ -55,7 +55,7 @@ async def __send_and_receive(self, data: bytes): request = self._request_header + packet_header # Validate the response - response = await UDPClient.communicate(self, request) + response = await UdpClient.communicate(self, request) header = response[:len(self._response_header)] if header != self._response_header: diff --git a/opengsq/protocols/satisfactory.py b/opengsq/protocols/satisfactory.py index e41189f..652f288 100644 --- a/opengsq/protocols/satisfactory.py +++ b/opengsq/protocols/satisfactory.py @@ -3,7 +3,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.exceptions import InvalidPacketException from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import UDPClient +from opengsq.protocol_socket import UdpClient class Satisfactory(ProtocolBase): @@ -19,7 +19,7 @@ async def get_status(self) -> dict: # Send message id, protocol version request = struct.pack('2b', 0, 0) + 'opengsq'.encode() - response = await UDPClient.communicate(self, request) + response = await UdpClient.communicate(self, request) br = BinaryReader(response) header = br.read_byte() diff --git a/opengsq/protocols/scum.py b/opengsq/protocols/scum.py index 2d45f4e..9de8efe 100644 --- a/opengsq/protocols/scum.py +++ b/opengsq/protocols/scum.py @@ -1,7 +1,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.exceptions import ServerNotFoundException from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import Socket, TCPClient +from opengsq.protocol_socket import Socket, TcpClient class Scum(ProtocolBase): @@ -41,7 +41,7 @@ async def query_master_servers() -> list: for host, port in Scum._master_servers: try: - with TCPClient() as tcpClient: + with TcpClient() as tcpClient: tcpClient.settimeout(5) await tcpClient.connect((host, port)) tcpClient.send(b'\x04\x03\x00\x00') diff --git a/opengsq/protocols/source.py b/opengsq/protocols/source.py index 67a62c5..e41480b 100644 --- a/opengsq/protocols/source.py +++ b/opengsq/protocols/source.py @@ -6,7 +6,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.exceptions import AuthenticationException, InvalidPacketException from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import TCPClient, UDPClient +from opengsq.protocol_socket import TcpClient, UdpClient class Source(ProtocolBase): @@ -187,7 +187,7 @@ async def get_rules(self) -> dict: async def __connect_and_send_challenge(self, header: __RequestHeader) -> bytes: # Connect to remote host - with UDPClient() as udpClient: + with UdpClient() as udpClient: udpClient.settimeout(self._timeout) await udpClient.connect((self._host, self._port)) @@ -217,7 +217,7 @@ async def __connect_and_send_challenge(self, header: __RequestHeader) -> bytes: return response_data - async def __receive(self, udpClient: UDPClient) -> bytes: + async def __receive(self, udpClient: UdpClient) -> bytes: total_packets = -1 payloads = dict() packets = list() @@ -285,7 +285,7 @@ def __is_gold_source_split(self, br: BinaryReader): # Check is it Gold Source packet split format return number == 0 and br.read().startswith(b'\xFF\xFF\xFF\xFF') - async def __parse_gold_source_packet(self, udpClient: UDPClient, packets: list): + async def __parse_gold_source_packet(self, udpClient: UdpClient, packets: list): total_packets = -1 payloads = dict() @@ -346,7 +346,7 @@ async def authenticate(self, password: str): """Authenticate the connection""" # Connect - self._tcpClient = TCPClient() + self._tcpClient = TcpClient() self._tcpClient.settimeout(self._timeout) await self._tcpClient.connect((self._host, self._port)) diff --git a/opengsq/protocols/teamspeak3.py b/opengsq/protocols/teamspeak3.py index bda71ae..f533563 100644 --- a/opengsq/protocols/teamspeak3.py +++ b/opengsq/protocols/teamspeak3.py @@ -1,5 +1,5 @@ from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import TCPClient +from opengsq.protocol_socket import TcpClient class Teamspeak3(ProtocolBase): @@ -23,7 +23,7 @@ async def get_channels(self): return self.__parse_rows(response) async def __send_and_receive(self, data: bytes): - with TCPClient() as tcpClient: + with TcpClient() as tcpClient: tcpClient.settimeout(self._timeout) await tcpClient.connect((self._host, self._port)) diff --git a/opengsq/protocols/unreal2.py b/opengsq/protocols/unreal2.py index 82a0984..03bcd37 100644 --- a/opengsq/protocols/unreal2.py +++ b/opengsq/protocols/unreal2.py @@ -3,7 +3,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.exceptions import InvalidPacketException from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import UDPClient +from opengsq.protocol_socket import UdpClient class Unreal2(ProtocolBase): @@ -15,7 +15,7 @@ class Unreal2(ProtocolBase): _PLAYERS = 0x02 async def get_details(self): - response = await UDPClient.communicate(self, b'\x79\x00\x00\x00' + bytes([self._DETAILS])) + response = await UdpClient.communicate(self, b'\x79\x00\x00\x00' + bytes([self._DETAILS])) # Remove the first 4 bytes \x80\x00\x00\x00 br = BinaryReader(response[4:]) @@ -56,7 +56,7 @@ async def get_details(self): return details async def get_rules(self): - response = await UDPClient.communicate(self, b'\x79\x00\x00\x00' + bytes([self._RULES])) + response = await UdpClient.communicate(self, b'\x79\x00\x00\x00' + bytes([self._RULES])) # Remove the first 4 bytes \x80\x00\x00\x00 br = BinaryReader(response[4:]) @@ -83,7 +83,7 @@ async def get_rules(self): return rules async def get_players(self): - response = await UDPClient.communicate(self, b'\x79\x00\x00\x00' + bytes([self._PLAYERS])) + response = await UdpClient.communicate(self, b'\x79\x00\x00\x00' + bytes([self._PLAYERS])) # Remove the first 4 bytes \x80\x00\x00\x00 br = BinaryReader(response[4:]) diff --git a/opengsq/protocols/vcmp.py b/opengsq/protocols/vcmp.py index 819745a..ad88d91 100644 --- a/opengsq/protocols/vcmp.py +++ b/opengsq/protocols/vcmp.py @@ -3,7 +3,7 @@ from opengsq.binary_reader import BinaryReader from opengsq.exceptions import InvalidPacketException from opengsq.protocol_base import ProtocolBase -from opengsq.protocol_socket import Socket, UDPClient +from opengsq.protocol_socket import Socket, UdpClient class Vcmp(ProtocolBase): @@ -46,7 +46,7 @@ async def __send_and_receive(self, data: bytes): request = self._request_header + packet_header # Validate the response - response = await UDPClient.communicate(self, request) + response = await UdpClient.communicate(self, request) header = response[:len(self._response_header)] if header != self._response_header: