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

Loading…
Cancel
Save