Skip to content

Commit

Permalink
fix quake2 and formatted
Browse files Browse the repository at this point in the history
  • Loading branch information
dgibbs64 committed Nov 1, 2023
1 parent 8830bad commit f29194f
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions lgsm/modules/query_gsquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@
import socket
import sys

engine_types=('protocol-valve','protocol-quake3','protocol-quake3','protocol-gamespy1','protocol-unreal2','ut3','minecraft','minecraftbe','jc2mp','mumbleping','soldat','teeworlds')
engine_types = ('protocol-valve', 'protocol-quake2', 'protocol-quake3', 'protocol-gamespy1',
'protocol-unreal2', 'ut3', 'minecraft', 'minecraftbe', 'jc2mp', 'mumbleping', 'soldat', 'teeworlds')


class gsquery:
server_response_timeout = 2
default_buffer_length = 1024
sourcequery=('protocol-valve','avalanche3.0','barotrauma','madness','quakelive','realvirtuality','refractor','source','goldsrc','spark','starbound','unity3d','unreal4','wurm')
idtech2query=('protocol-quake3','idtech2','quake','iw2.0')
idtech3query=('protocol-quake3','iw3.0','ioquake3','qfusion')
minecraftquery=('minecraft','lwjgl2')
minecraftbequery=('minecraftbe',)
jc2mpquery=('jc2mp',)
mumblequery=('mumbleping',)
soldatquery=('soldat',)
twquery=('teeworlds',)
unrealquery=('protocol-gamespy1','unreal')
unreal2query=('protocol-unreal2','unreal2')
unreal3query=('ut3','unreal3')
sourcequery = ('protocol-valve', 'avalanche3.0', 'barotrauma', 'madness', 'quakelive', 'realvirtuality',
'refractor', 'source', 'goldsrc', 'spark', 'starbound', 'unity3d', 'unreal4', 'wurm')
idtech2query = ('protocol-quake2', 'idtech2', 'quake', 'iw2.0')
idtech3query = ('protocol-quake3', 'iw3.0', 'ioquake3', 'qfusion')
minecraftquery = ('minecraft', 'lwjgl2')
minecraftbequery = ('minecraftbe',)
jc2mpquery = ('jc2mp',)
mumblequery = ('mumbleping',)
soldatquery = ('soldat',)
twquery = ('teeworlds',)
unrealquery = ('protocol-gamespy1', 'unreal')
unreal2query = ('protocol-unreal2', 'unreal2')
unreal3query = ('ut3', 'unreal3')

def __init__(self, arguments):
self.argument = arguments
Expand All @@ -48,7 +51,8 @@ def __init__(self, arguments):
elif self.argument.engine in self.soldatquery:
self.query_prompt_string = b'\x69\x00'
elif self.argument.engine in self.twquery:
self.query_prompt_string = b'\x04\x00\x00\xff\xff\xff\xff\x05' + bytearray(511)
self.query_prompt_string = b'\x04\x00\x00\xff\xff\xff\xff\x05' + \
bytearray(511)
elif self.argument.engine in self.unrealquery:
self.query_prompt_string = b'\x5C\x69\x6E\x66\x6F\x5C'
elif self.argument.engine in self.unreal2query:
Expand All @@ -74,7 +78,8 @@ def responding(self):
connection = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
connection.settimeout(self.server_response_timeout)
try:
self.connected = connection.connect((self.argument.address, int(self.argument.port)))
self.connected = connection.connect(
(self.argument.address, int(self.argument.port)))
except socket.timeout:
self.fatal_error('Request timed out', 1)
except Exception:
Expand All @@ -95,6 +100,7 @@ def responding(self):
else:
self.exit_success(str(self.response))


def parse_args():
parser = argparse.ArgumentParser(
description='Allows querying of various game servers.',
Expand Down Expand Up @@ -142,10 +148,12 @@ def parse_args():
)
return parser.parse_args()


def main():
arguments = parse_args()
server = gsquery(arguments)
server.responding()


if __name__ == '__main__':
main()

0 comments on commit f29194f

Please sign in to comment.