Browse Source

fix quake2 and formatted

pull/4740/head
Daniel Gibbs 1 year ago
parent
commit
f29194f089
No known key found for this signature in database GPG Key ID: 2076B128385E8C55
  1. 38
      lgsm/modules/query_gsquery.py

38
lgsm/modules/query_gsquery.py

@ -10,23 +10,26 @@ import argparse
import socket import socket
import sys 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: class gsquery:
server_response_timeout = 2 server_response_timeout = 2
default_buffer_length = 1024 default_buffer_length = 1024
sourcequery=('protocol-valve','avalanche3.0','barotrauma','madness','quakelive','realvirtuality','refractor','source','goldsrc','spark','starbound','unity3d','unreal4','wurm') sourcequery = ('protocol-valve', 'avalanche3.0', 'barotrauma', 'madness', 'quakelive', 'realvirtuality',
idtech2query=('protocol-quake3','idtech2','quake','iw2.0') 'refractor', 'source', 'goldsrc', 'spark', 'starbound', 'unity3d', 'unreal4', 'wurm')
idtech3query=('protocol-quake3','iw3.0','ioquake3','qfusion') idtech2query = ('protocol-quake2', 'idtech2', 'quake', 'iw2.0')
minecraftquery=('minecraft','lwjgl2') idtech3query = ('protocol-quake3', 'iw3.0', 'ioquake3', 'qfusion')
minecraftbequery=('minecraftbe',) minecraftquery = ('minecraft', 'lwjgl2')
jc2mpquery=('jc2mp',) minecraftbequery = ('minecraftbe',)
mumblequery=('mumbleping',) jc2mpquery = ('jc2mp',)
soldatquery=('soldat',) mumblequery = ('mumbleping',)
twquery=('teeworlds',) soldatquery = ('soldat',)
unrealquery=('protocol-gamespy1','unreal') twquery = ('teeworlds',)
unreal2query=('protocol-unreal2','unreal2') unrealquery = ('protocol-gamespy1', 'unreal')
unreal3query=('ut3','unreal3') unreal2query = ('protocol-unreal2', 'unreal2')
unreal3query = ('ut3', 'unreal3')
def __init__(self, arguments): def __init__(self, arguments):
self.argument = arguments self.argument = arguments
@ -48,7 +51,8 @@ class gsquery:
elif self.argument.engine in self.soldatquery: elif self.argument.engine in self.soldatquery:
self.query_prompt_string = b'\x69\x00' self.query_prompt_string = b'\x69\x00'
elif self.argument.engine in self.twquery: 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: elif self.argument.engine in self.unrealquery:
self.query_prompt_string = b'\x5C\x69\x6E\x66\x6F\x5C' self.query_prompt_string = b'\x5C\x69\x6E\x66\x6F\x5C'
elif self.argument.engine in self.unreal2query: elif self.argument.engine in self.unreal2query:
@ -74,7 +78,8 @@ class gsquery:
connection = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) connection = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
connection.settimeout(self.server_response_timeout) connection.settimeout(self.server_response_timeout)
try: 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: except socket.timeout:
self.fatal_error('Request timed out', 1) self.fatal_error('Request timed out', 1)
except Exception: except Exception:
@ -95,6 +100,7 @@ class gsquery:
else: else:
self.exit_success(str(self.response)) self.exit_success(str(self.response))
def parse_args(): def parse_args():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description='Allows querying of various game servers.', description='Allows querying of various game servers.',
@ -142,10 +148,12 @@ def parse_args():
) )
return parser.parse_args() return parser.parse_args()
def main(): def main():
arguments = parse_args() arguments = parse_args()
server = gsquery(arguments) server = gsquery(arguments)
server.responding() server.responding()
if __name__ == '__main__': if __name__ == '__main__':
main() main()

Loading…
Cancel
Save