Browse Source

server_entry: save time when we sent challenge

master
a1batross 2 years ago
parent
commit
3cbb519ccb
  1. 15
      server_entry.py

15
server_entry.py

@ -18,7 +18,7 @@ class ServerEntry:
region = 255 region = 255
product = '' product = ''
nat = 0 nat = 0
def setInfoString(self, data): def setInfoString(self, data):
infostring = data.replace('\n', '').replace('\r', '').replace('\0', '') infostring = data.replace('\n', '').replace('\r', '').replace('\0', '')
split = infostring.split('\\') split = infostring.split('\\')
@ -60,24 +60,25 @@ class ServerEntry:
except IndexError: except IndexError:
pass pass
self.check = self.challenge == self.challenge2 self.check = self.challenge == self.challenge2
return self.check
def __init__(self, addr, challenge): def __init__(self, addr, challenge):
# Address # Address
self.addr = addr self.addr = addr
# Shortcuts for generating query # Shortcuts for generating query
self.queryAddr = b'' self.queryAddr = b''
for i in addr[0].split('.'): for i in addr[0].split('.'):
self.queryAddr += pack('!B', int(i)) self.queryAddr += pack('!B', int(i))
self.queryAddr += pack('!H', int(addr[1])) self.queryAddr += pack('!H', int(addr[1]))
# Random number that server must return # Random number that server must return
self.challenge = challenge self.challenge = challenge
self.sentChallengeAt = time()
# This server is not checked # This server is not checked
# So it will not get into queries # So it will not get into queries
self.check = False self.check = False
# Remove server after this time. # Remove server after this time.
# This maybe not instant # This maybe not instant
self.die = time() + 600.0 self.die = self.sentChallengeAt + 600

Loading…
Cancel
Save