Browse Source

Update info.py

pull/58/head
Bluscream 8 months ago
committed by GitHub
parent
commit
b41394a042
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 190
      a2s/info.py

190
a2s/info.py

@ -1,4 +1,6 @@
import io import io
from dataclasses import dataclass, field
from typing import Optional
from a2s.exceptions import BrokenMessageError, BufferExhaustedError from a2s.exceptions import BrokenMessageError, BufferExhaustedError
from a2s.defaults import DEFAULT_TIMEOUT, DEFAULT_ENCODING from a2s.defaults import DEFAULT_TIMEOUT, DEFAULT_ENCODING
@ -12,80 +14,31 @@ from a2s.datacls import DataclsMeta
A2S_INFO_RESPONSE = 0x49 A2S_INFO_RESPONSE = 0x49
A2S_INFO_RESPONSE_LEGACY = 0x6D A2S_INFO_RESPONSE_LEGACY = 0x6D
@dataclass
class SourceInfo(metaclass=DataclsMeta): class SourceInfo(): # metaclass=DataclsMeta
protocol: int
"""Protocol version used by the server""" """Protocol version used by the server"""
protocol: Optional[int] = None
server_name: str server_name: Optional[str] = None
"""Display name of the server""" map_name: Optional[str] = None
folder: Optional[str] = None
map_name: str game: Optional[str] = None
"""The currently loaded map""" app_id: Optional[int] = None
player_count: Optional[int] = None
folder: str max_players: Optional[int] = None
"""Name of the game directory""" bot_count: Optional[int] = None
server_type: Optional[str] = None
game: str platform: Optional[str] = None
"""Name of the game""" password_protected: Optional[bool] = None
vac_enabled: Optional[bool] = None
app_id: int version: Optional[str] = None
"""App ID of the game required to connect""" edf: Optional[int] = 0
port: Optional[int] = None
player_count: int steam_id: Optional[int] = None
"""Number of players currently connected""" stv_port: Optional[int] = None
stv_name: Optional[str] = None
max_players: int keywords: Optional[str] = None
"""Number of player slots available""" game_id: Optional[int] = None
ping: Optional[float] = None
bot_count: int
"""Number of bots on the server"""
server_type: str
"""Type of the server:
'd': Dedicated server
'l': Non-dedicated server
'p': SourceTV relay (proxy)"""
platform: str
"""Operating system of the server
'l', 'w', 'm' for Linux, Windows, macOS"""
password_protected: bool
"""Server requires a password to connect"""
vac_enabled: bool
"""Server has VAC enabled"""
version: str
"""Version of the server software"""
# Optional:
edf: int = 0
"""Extra data field, used to indicate if extra values are
included in the response"""
port: int
"""Port of the game server."""
steam_id: int
"""Steam ID of the server"""
stv_port: int
"""Port of the SourceTV server"""
stv_name: str
"""Name of the SourceTV server"""
keywords: str
"""Tags that describe the gamemode being played"""
game_id: int
"""Game ID for games that have an app ID too high for 16bit."""
# Client determined values:
ping: float
"""Round-trip delay time for the request in seconds"""
@property @property
def has_port(self): def has_port(self):
@ -107,75 +60,30 @@ class SourceInfo(metaclass=DataclsMeta):
def has_game_id(self): def has_game_id(self):
return bool(self.edf & 0x01) return bool(self.edf & 0x01)
class GoldSrcInfo(metaclass=DataclsMeta): @dataclass
address: str class GoldSrcInfo(): # metaclass=DataclsMeta
"""IP Address and port of the server""" """IP Address and port of the server"""
address: Optional[str] = None
server_name: str server_name: Optional[str] = None
"""Display name of the server""" map_name: Optional[str] = None
folder: Optional[str] = None
map_name: str game: Optional[str] = None
"""The currently loaded map""" player_count: Optional[int] = None
max_players: Optional[int] = None
folder: str protocol: Optional[int] = None
"""Name of the game directory""" server_type: Optional[str] = None
platform: Optional[str] = None
game: str password_protected: Optional[bool] = None
"""Name of the game""" is_mod: Optional[bool] = None
vac_enabled: Optional[bool] = None
player_count: int bot_count: Optional[int] = None
"""Number of players currently connected""" mod_website: Optional[str] = None
mod_download: Optional[str] = None
max_players: int mod_version: Optional[int] = None
"""Number of player slots available""" mod_size: Optional[int] = None
multiplayer_only: Optional[bool] = False
protocol: int uses_hl_dll: Optional[bool] = True
"""Protocol version used by the server""" ping: Optional[float] = None
server_type: str
"""Type of the server:
'd': Dedicated server
'l': Non-dedicated server
'p': SourceTV relay (proxy)"""
platform: str
"""Operating system of the server
'l', 'w' for Linux and Windows"""
password_protected: bool
"""Server requires a password to connect"""
is_mod: bool
"""Server is running a Half-Life mod instead of the base game"""
vac_enabled: bool
"""Server has VAC enabled"""
bot_count: int
"""Number of bots on the server"""
# Optional:
mod_website: str
"""URL to the mod website"""
mod_download: str
"""URL to download the mod"""
mod_version: int
"""Version of the mod installed on the server"""
mod_size: int
"""Size in bytes of the mod"""
multiplayer_only: bool = False
"""Mod supports multiplayer only"""
uses_hl_dll: bool = True
"""Mod uses a custom DLL"""
# Client determined values:
ping: float
"""Round-trip delay time for the request in seconds"""
def info(address, timeout=DEFAULT_TIMEOUT, encoding=DEFAULT_ENCODING): def info(address, timeout=DEFAULT_TIMEOUT, encoding=DEFAULT_ENCODING):

Loading…
Cancel
Save