|
|
@ -103,23 +103,31 @@ class PyMaster: |
|
|
|
if( gamedir != None ): |
|
|
|
if( gamedir != None ): |
|
|
|
if( gamedir != i.gamedir): |
|
|
|
if( gamedir != i.gamedir): |
|
|
|
continue |
|
|
|
continue |
|
|
|
|
|
|
|
|
|
|
|
# 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 |
|
|
|
|
|
|
|
|
|
|
|
self.sock.sendto(packet, addr) |
|
|
|
self.sock.sendto(packet, addr) |
|
|
|
|
|
|
|
|
|
|
|
def removeServerFromList(self, data, addr): |
|
|
|
def removeServerFromList(self, data, addr): |
|
|
|
logPrint("Remove Server: from {0}:{1}".format(addr[0], addr[1])) |
|
|
|
|
|
|
|
for i in self.serverList: |
|
|
|
for i in self.serverList: |
|
|
|
if (i.addr == addr): |
|
|
|
if (i.addr == addr): |
|
|
|
|
|
|
|
logPrint("Remove Server: from {0}:{1}".format(addr[0], addr[1])) |
|
|
|
self.serverList.remove(i) |
|
|
|
self.serverList.remove(i) |
|
|
|
|
|
|
|
|
|
|
|
def sendChallengeToServer(self, data, addr): |
|
|
|
def sendChallengeToServer(self, data, addr): |
|
|
|
logPrint("Challenge Request: from {0}:{1}".format(addr[0], addr[1])) |
|
|
|
logPrint("Challenge Request: from {0}:{1}".format(addr[0], addr[1])) |
|
|
|
# At first, remove old server- data from list |
|
|
|
# At first, remove old server- data from list |
|
|
|
self.removeServerFromList(None, addr) |
|
|
|
#self.removeServerFromList(None, addr) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
count = 0 |
|
|
|
|
|
|
|
for i in self.serverList: |
|
|
|
|
|
|
|
if ( i.addr[0] == addr[0] ): |
|
|
|
|
|
|
|
if( i.addr[1] == addr[1] ): |
|
|
|
|
|
|
|
self.serverList.remove(i) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
count += 1 |
|
|
|
|
|
|
|
if( count > 7 ): |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
# Generate a 32 bit challenge number |
|
|
|
# Generate a 32 bit challenge number |
|
|
|
challenge = random.randint(0, 2**32-1) |
|
|
|
challenge = random.randint(0, 2**32-1) |
|
|
@ -150,7 +158,7 @@ class PyMaster: |
|
|
|
|
|
|
|
|
|
|
|
packet = b'Server\t\t\tGame\tMap\t\tPlayers\tVersion\tChallenge\tCheck\n' |
|
|
|
packet = b'Server\t\t\tGame\tMap\t\tPlayers\tVersion\tChallenge\tCheck\n' |
|
|
|
for i in self.serverList: |
|
|
|
for i in self.serverList: |
|
|
|
line = '{0}:{1}\t{2}\t{3}\t\t{4}/{5}\t{6}\t{7}\t{8}n'.format(i.addr[0], i.addr[1], |
|
|
|
line = '{0}:{1}\t{2}\t{3}\t{4}/{5}\t{6}\t{7}\t{8}\n'.format(i.addr[0], i.addr[1], |
|
|
|
i.gamedir, i.gamemap, i.players, |
|
|
|
i.gamedir, i.gamemap, i.players, |
|
|
|
i.maxplayers, i.version, i.challenge, i.check) |
|
|
|
i.maxplayers, i.version, i.challenge, i.check) |
|
|
|
packet += line.encode('latin_1') |
|
|
|
packet += line.encode('latin_1') |
|
|
|