class Challenger(threading.Thread): """ Based on my quick and dirty server 'keep-alive' heartbeat class """ def __init__(self, baseSite, target, params, autostart=True): # Flag of Death self.stopFlag = False; self.pauseFlag = False; self._silent = False; self.server = NetworkInterface(); self.server.baseSite = baseSite; self.server.target = target; self.server.params = params; self.server.makeNulls = True; # Clear the timer time.clock(); threading.Thread.__init__(self, None, None, "Challenger Thread"); self.daemon = True; if autostart: self.start(); def run(self): """ Start sending beats to the server every 10 seconds """ while(not self.stopFlag): sleeptime = time.clock(); if(self.pauseFlag): op = self.server.params['type']; self.server.params['type'] = 'ali'; self.server.request(); self.server.params['type'] = op; else: response = self.server.request(); if(response not in [None, '', False] and response != '$NoBattle' and 0 < len(response) <= 25): if(response == '$Ingame'): continue; else: os.system('start python Popup.py ' + response.strip()); time.sleep(math.fabs(3 - (time.clock() - sleeptime))); def stop(self, join=True): if(join and self.stopFlag): self.join(1); self.stopFlag = True;
# Package the new data conn1.params = {"u":u, "python":1, "type":"", "SID":SID}; # 1. Split the key in half # 2. Place chunks at both the front and the end (double salt) # 3. SHA-1 the whole thing again eKeyPiece1 = KEY[0:20]; eKeyPiece2 = KEY[20:40]; p = str(hashlib.sha1(eKeyPiece1 + hashlib.sha1(hashlib.md5(p).hexdigest()).hexdigest() + eKeyPiece2).hexdigest()); u = str(hashlib.sha1(eKeyPiece1 + u + eKeyPiece2).hexdigest()); conn1.params["u"] = u; conn1.params["p"] = p; conn1.params["type"] = "lin"; # Authenticate the user's information response = conn1.request(); # Alert the user of the result, and display the proper options accordingly if response != False: if response == "Approved": Display.playerMsg("Login Successful."); # Grab the user's player data and store it as a dictionary conn1.params = {"u":u, "p":p, "python":1, "type":"pul", "SID":SID}; conn1.makeNulls = True; response = conn1.request(); if response != False: userdict = json_decode(response); userpowers = userdict['powers'];