mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
fixed so it handles multiple packets from the masters
This commit is contained in:
parent
e27e2d8b2a
commit
42553448f7
|
@ -62,17 +62,23 @@ def get_servers(address):
|
|||
sock.settimeout(1.5)
|
||||
sock.sendto("\x20\x00\x00\x00\x00\x00\xff\xff\xff\xffreqt", (address, master_port))
|
||||
|
||||
while 1:
|
||||
data, addr = sock.recvfrom(1024)
|
||||
sock.close()
|
||||
|
||||
data = data[14:]
|
||||
num_servers = len(data) / 6
|
||||
num_players = 0
|
||||
|
||||
for n in range(0, num_servers):
|
||||
ip = ".".join(map(str, map(ord, data[n*6:n*6+4])))
|
||||
port = ord(data[n*6+5]) * 256 + ord(data[n*6+4])
|
||||
servers += [[ip, port]]
|
||||
|
||||
# and we are done
|
||||
if num_servers < 128:
|
||||
break
|
||||
|
||||
sock.close()
|
||||
|
||||
return servers
|
||||
except:
|
||||
return None
|
||||
|
|
Loading…
Reference in a new issue