diff options
-rw-r--r-- | module/ThreadManager.py | 28 | ||||
-rw-r--r-- | module/plugins/accounts/NetloadIn.py | 2 |
2 files changed, 21 insertions, 9 deletions
diff --git a/module/ThreadManager.py b/module/ThreadManager.py index f46f816e4..eba23f28c 100644 --- a/module/ThreadManager.py +++ b/module/ThreadManager.py @@ -24,6 +24,7 @@ from subprocess import Popen from threading import Event from time import sleep from traceback import print_exc +from random import choice import pycurl import PluginThread @@ -126,7 +127,7 @@ class ThreadManager: while [x.active.plugin.waiting for x in self.threads if x.active].count(True) != 0: sleep(0.25) - ip = re.match(".*Current IP Address: (.*)</body>.*", getURL("http://checkip.dyndns.org/")).group(1) + ip = self.getIP() self.core.hookManager.beforeReconnecting(ip) @@ -144,19 +145,30 @@ class ThreadManager: reconn.wait() sleep(1) - ip = "" - while ip == "": - try: - ip = re.match(".*Current IP Address: (.*)</body>.*", getURL("http://checkip.dyndns.org/")).group(1) #get new ip - except: - ip = "" - sleep(1) + ip = self.getIP() self.core.hookManager.afterReconnecting(ip) self.log.info(_("Reconnected, new IP: %s") % ip) self.reconnecting.clear() + def getIP(self): + """retrieve current ip""" + services = [("http://www.whatismyip.com/automation/n09230945.asp", "(\S+)"), + ("http://checkip.dyndns.org/",".*Current IP Address: (\S+)</body>.*")] + + ip = "" + while not ip: + try: + sv = choice(services) + ip = getURL(sv[0]) + ip = re.match(sv[1], ip).group(1) + except: + ip = "" + sleep(1) + + return ip + #---------------------------------------------------------------------- def checkThreadCount(self): """checks if there are need for increasing or reducing thread count""" diff --git a/module/plugins/accounts/NetloadIn.py b/module/plugins/accounts/NetloadIn.py index 957435b46..4f5b08689 100644 --- a/module/plugins/accounts/NetloadIn.py +++ b/module/plugins/accounts/NetloadIn.py @@ -36,7 +36,7 @@ class NetloadIn(Account): validuntil = time() + int(left.group(1)) * 24 * 60 * 60 + int(left.group(2)) * 60 * 60 return {"validuntil": validuntil, "trafficleft": -1} - def login(self, user, req): + def login(self, user, data,req): page = req.load("http://netload.in/index.php", None, { "txtuser" : user, "txtpass" : data['password'], "txtcheck" : "login", "txtlogin" : ""}, cookies=True) if "password or it might be invalid!" in page: self.wrongPassword() |