1
0
Fork 0
mirror of https://github.com/de2tla2f/pymaster.git synced 2024-11-30 14:51:28 +00:00

add request key support by @a1batross

This commit is contained in:
ghost 2023-12-26 19:07:15 +02:00
parent d76fb9a8fb
commit e3a2616fd9

View file

@ -67,20 +67,23 @@ class PyMaster:
gamedir = "valve" # halflife, by default gamedir = "valve" # halflife, by default
clver = None clver = None
nat = 0 nat = 0
key = None
for i in range(0, len(split), 2): for i in range(0, len(split), 2):
try: try:
key = split[i + 1] value = split[i + 1]
if split[i] == "gamedir": if split[i] == "gamedir":
gamedir = key.lower() # keep gamedir in lowercase gamedir = value.lower() # keep gamedir in lowercase
elif split[i] == "nat": elif split[i] == "nat":
nat = int(key) nat = int(value)
elif split[i] == "clver": elif split[i] == "clver":
clver = key clver = value
elif split[i] == 'key':
key = int(value, 16)
else: else:
logging.debug( logging.debug(
"Unhandled info string entry: {0}/{1}. Infostring was: {2}".format( "Unhandled info string entry: {0}/{1}. Infostring was: {2}".format(
split[i], key, split split[i], value, split
) )
) )
except IndexError: except IndexError:
@ -91,6 +94,10 @@ class PyMaster:
return return
packet = MasterProtocol.queryPacketHeader packet = MasterProtocol.queryPacketHeader
if key != None: # Required in latest Xash3D version
packet += b'\x7F' + pack('<I', key) + b'\x00'
for i in self.serverList: for i in self.serverList:
if time() > i.die: if time() > i.die:
self.serverList.remove(i) self.serverList.remove(i)