Browse Source

add key encoding fix by @a1batross #1542

add-key-protocol-support
ghost 11 months ago
parent
commit
0af57a1e86
  1. 11
      pymaster.py

11
pymaster.py

@ -126,8 +126,8 @@ class PyMaster: @@ -126,8 +126,8 @@ class PyMaster:
clver = v
elif k == 'protocol':
protocol = int(v)
elif k == 'key': # defined but not implemented yet
key = v
elif k == 'key':
key = int(v, 16)
# somebody is playing :)
elif k == 'thisismypcid' or k == 'heydevelopersifyoureadthis':
self.fakeInfoForOldVersions(gamedir, addr)
@ -142,6 +142,10 @@ class PyMaster: @@ -142,6 +142,10 @@ class PyMaster:
return
packet = MasterProtocol.queryPacketHeader
if key != None:
packet += b'\x7F' + pack('<I', key) + b'\x00'
for i in self.serverList:
if time() > i.die:
self.serverList.remove(i)
@ -161,9 +165,6 @@ class PyMaster: @@ -161,9 +165,6 @@ class PyMaster:
data = ('\xff\xff\xff\xffc %s:%d' % (addr[0], addr[1])).encode('latin_1')
self.sock.sendto(data, i.addr)
if key:
packet += b"\x7f" + key.encode('latin_1')
# Use pregenerated address string
packet += i.queryAddr
packet += b'\0\0\0\0\0\0' # Fill last IP:Port with \0

Loading…
Cancel
Save