mirror of
https://github.com/de2tla2f/pymaster.git
synced 2024-11-27 05:11:29 +00:00
Compare commits
No commits in common. "76079d0fdb0e2c1fee8584ba157f8686fa3cd3f2" and "4ad8a8a59c68b9503b870acbf7f04ab78593d12f" have entirely different histories.
76079d0fdb
...
4ad8a8a59c
|
@ -100,20 +100,16 @@ class PyMaster:
|
|||
|
||||
for i in self.serverList:
|
||||
if time() > i.die:
|
||||
logging.debug("Server removed by timeout")
|
||||
self.serverList.remove(i)
|
||||
continue
|
||||
|
||||
if not i.check:
|
||||
logging.debug("Invalid request")
|
||||
continue
|
||||
|
||||
if nat != i.nat:
|
||||
logging.debug("NAT {0} mismatch {1}".format(i.nat, nat))
|
||||
continue
|
||||
|
||||
if gamedir is not None and gamedir != i.gamedir:
|
||||
logging.debug("Game dir {0} mismatch node settings: {1}".format(i.gamedir, gamedir))
|
||||
continue
|
||||
|
||||
if nat:
|
||||
|
@ -176,13 +172,11 @@ class PyMaster:
|
|||
else:
|
||||
count += 1
|
||||
if count > MAX_SERVERS_FOR_IP:
|
||||
logging.debug("Reached MAX_SERVERS_FOR_IP: {0}".format(MAX_SERVERS_FOR_IP))
|
||||
return
|
||||
|
||||
challenge = random.randint(0, 2**32 - 1)
|
||||
|
||||
# Add server to list
|
||||
logging.debug("Added new server {0}:{1} with challenge {2}".format(addr[0], addr[1], challenge))
|
||||
self.serverList.append(ServerEntry(addr, challenge))
|
||||
|
||||
# And send him a challenge
|
||||
|
@ -199,7 +193,6 @@ class PyMaster:
|
|||
# Find a server with same address
|
||||
for serverEntry in self.serverList:
|
||||
if serverEntry.addr == addr:
|
||||
logging.debug("Skipped same server address: {0}:{1}".format(addr[0], addr[1]))
|
||||
break
|
||||
|
||||
serverEntry.setInfoString(serverInfo)
|
||||
|
|
|
@ -5,7 +5,7 @@ import ipaddress
|
|||
|
||||
class ServerEntry:
|
||||
challenge2 = 0
|
||||
gamedir = 'valve'
|
||||
gamedir = ''
|
||||
protocol = 0
|
||||
players = 0
|
||||
maxplayers = 0
|
||||
|
@ -20,48 +20,45 @@ class ServerEntry:
|
|||
region = 255
|
||||
product = ''
|
||||
nat = 0
|
||||
key = None
|
||||
|
||||
def setInfoString(self, data):
|
||||
infostring = data.replace('\n', '').replace('\r', '').replace('\0', '')
|
||||
split = infostring.split('\\')
|
||||
for i in range(0, len(split), 2):
|
||||
try:
|
||||
value = split[i + 1]
|
||||
key = split[i + 1]
|
||||
if( split[i] == 'challenge' ):
|
||||
self.challenge2 = int(value)
|
||||
self.challenge2 = int(key)
|
||||
elif( split[i] == 'gamedir' ):
|
||||
self.gamedir = value.lower() # keep gamedir lowercase
|
||||
self.gamedir = key.lower() # keep gamedir lowercase
|
||||
elif( split[i] == 'protocol' ):
|
||||
self.protocol = int(value)
|
||||
self.protocol = int(key)
|
||||
elif( split[i] == 'players' ):
|
||||
self.players = int(value)
|
||||
self.players = int(key)
|
||||
elif( split[i] == 'max' ):
|
||||
self.maxplayers = int(value.split('.')[0])
|
||||
self.maxplayers = int(key.split('.')[0])
|
||||
elif( split[i] == 'bots' ):
|
||||
self.bots = int(value)
|
||||
self.bots = int(key)
|
||||
elif( split[i] == 'map' ):
|
||||
self.gamemap = value
|
||||
self.gamemap = key
|
||||
elif( split[i] == 'version' ):
|
||||
self.version = value
|
||||
self.version = key
|
||||
elif( split[i] == 'type' ):
|
||||
self.servtype = value
|
||||
self.servtype = key
|
||||
elif( split[i] == 'password' ):
|
||||
self.password = value
|
||||
self.password = key
|
||||
elif( split[i] == 'os' ):
|
||||
self.os = value
|
||||
self.os = key
|
||||
elif( split[i] == 'secure' ):
|
||||
self.secure = value
|
||||
self.secure = key
|
||||
elif( split[i] == 'lan' ):
|
||||
self.lan = value
|
||||
self.lan = key
|
||||
elif( split[i] == 'region' ):
|
||||
self.region = value
|
||||
self.region = key
|
||||
elif( split[i] == 'product' ):
|
||||
self.product = value
|
||||
self.product = key
|
||||
elif( split[i] == 'nat' ):
|
||||
self.nat = int(value)
|
||||
elif split[i] == 'key':
|
||||
self.key = int(value, 16)
|
||||
self.nat = int(key)
|
||||
except IndexError:
|
||||
pass
|
||||
self.check = self.challenge == self.challenge2
|
||||
|
|
Loading…
Reference in a new issue