From cff5969e4a20159b21e835fcee068f15889f318e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 13 Apr 2015 16:09:03 +0200 Subject: Rename ClickAndLoad to ClickNLoad --- pyload/plugin/addon/ClickAndLoad.py | 87 ------------------------------------- pyload/plugin/addon/ClickNLoad.py | 87 +++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 87 deletions(-) delete mode 100644 pyload/plugin/addon/ClickAndLoad.py create mode 100644 pyload/plugin/addon/ClickNLoad.py (limited to 'pyload/plugin') diff --git a/pyload/plugin/addon/ClickAndLoad.py b/pyload/plugin/addon/ClickAndLoad.py deleted file mode 100644 index 1e420fa8e..000000000 --- a/pyload/plugin/addon/ClickAndLoad.py +++ /dev/null @@ -1,87 +0,0 @@ -# -*- coding: utf-8 -*- - -import socket -import time - -from threading import Lock - -from pyload.plugin.Addon import Addon, threaded - - -def forward(source, destination): - try: - bufsize = 1024 - bufdata = source.recv(bufsize) - while bufdata: - destination.sendall(bufdata) - bufdata = source.recv(bufsize) - finally: - destination.shutdown(socket.SHUT_WR) - # destination.close() - - -#@TODO: IPv6 support -class ClickAndLoad(Addon): - __name = "ClickAndLoad" - __type = "addon" - __version = "0.41" - - __config = [("activated", "bool", "Activated" , True), - ("port" , "int" , "Port" , 9666), - ("extern" , "bool", "Listen on the public network interface", True)] - - __description = """Click'n'Load addon plugin""" - __license = "GPLv3" - __authors = [("RaNaN" , "RaNaN@pyload.de" ), - ("Walter Purcaro", "vuolter@gmail.com")] - - - def activate(self): - if not self.core.config['webui']['activated']: - return - - ip = "" if self.getConfig('extern') else "127.0.0.1" - webport = self.core.config['webui']['port'] - cnlport = self.getConfig('port') - - self.proxy(ip, webport, cnlport) - - - @threaded - def proxy(self, ip, webport, cnlport): - time.sleep(10) #@TODO: Remove in 0.4.10 (implement addon delay on startup) - - self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) - - self._server(ip, webport, cnlport) - - lock = Lock() - lock.acquire() - lock.acquire() - - - @threaded - def _server(self, ip, webport, cnlport): - try: - dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - dock_socket.bind((ip, cnlport)) - dock_socket.listen(5) - - while True: - client_socket, client_addr = dock_socket.accept() - self.logDebug("Connection from %s:%s" % client_addr) - - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server_socket.connect(("127.0.0.1", webport)) - - self.manager.startThread(forward, client_socket, server_socket) - self.manager.startThread(forward, server_socket, client_socket) - - except socket.timeout: - self.logDebug("Connection timed out, retrying...") - return self._server(ip, webport, cnlport) - - except socket.error, e: - self.logError(e) - time.sleep(240) - return self._server(ip, webport, cnlport) diff --git a/pyload/plugin/addon/ClickNLoad.py b/pyload/plugin/addon/ClickNLoad.py new file mode 100644 index 000000000..b6448598a --- /dev/null +++ b/pyload/plugin/addon/ClickNLoad.py @@ -0,0 +1,87 @@ +# -*- coding: utf-8 -*- + +import socket +import time + +from threading import Lock + +from pyload.plugin.Addon import Addon, threaded + + +def forward(source, destination): + try: + bufsize = 1024 + bufdata = source.recv(bufsize) + while bufdata: + destination.sendall(bufdata) + bufdata = source.recv(bufsize) + finally: + destination.shutdown(socket.SHUT_WR) + # destination.close() + + +#@TODO: IPv6 support +class ClickNLoad(Addon): + __name = "ClickNLoad" + __type = "addon" + __version = "0.41" + + __config = [("activated", "bool", "Activated" , True), + ("port" , "int" , "Port" , 9666), + ("extern" , "bool", "Listen on the public network interface", True)] + + __description = """Click'n'Load addon plugin""" + __license = "GPLv3" + __authors = [("RaNaN" , "RaNaN@pyload.de" ), + ("Walter Purcaro", "vuolter@gmail.com")] + + + def activate(self): + if not self.core.config['webui']['activated']: + return + + ip = "" if self.getConfig('extern') else "127.0.0.1" + webport = self.core.config['webui']['port'] + cnlport = self.getConfig('port') + + self.proxy(ip, webport, cnlport) + + + @threaded + def proxy(self, ip, webport, cnlport): + time.sleep(10) #@TODO: Remove in 0.4.10 (implement addon delay on startup) + + self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) + + self._server(ip, webport, cnlport) + + lock = Lock() + lock.acquire() + lock.acquire() + + + @threaded + def _server(self, ip, webport, cnlport): + try: + dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + dock_socket.bind((ip, cnlport)) + dock_socket.listen(5) + + while True: + client_socket, client_addr = dock_socket.accept() + self.logDebug("Connection from %s:%s" % client_addr) + + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server_socket.connect(("127.0.0.1", webport)) + + self.manager.startThread(forward, client_socket, server_socket) + self.manager.startThread(forward, server_socket, client_socket) + + except socket.timeout: + self.logDebug("Connection timed out, retrying...") + return self._server(ip, webport, cnlport) + + except socket.error, e: + self.logError(e) + time.sleep(240) + return self._server(ip, webport, cnlport) -- cgit v1.2.3