diff options
author | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-12-15 06:13:20 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@users.noreply.github.com> | 2015-12-27 22:29:11 +0100 |
commit | e0fe4f0d7a845e195f99c6f44df5ebed16e97081 (patch) | |
tree | 52bb100d0c65f54f4fe8963b531bb758da6021c3 | |
parent | [SkipRev] Fixup (1) (diff) | |
download | pyload-e0fe4f0d7a845e195f99c6f44df5ebed16e97081.tar.xz |
[ClickNLoad] Update
-rw-r--r-- | module/plugins/hooks/ClickNLoad.py | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/module/plugins/hooks/ClickNLoad.py b/module/plugins/hooks/ClickNLoad.py index 79bf66c09..0e039a6dc 100644 --- a/module/plugins/hooks/ClickNLoad.py +++ b/module/plugins/hooks/ClickNLoad.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import socket -import threading import time try: @@ -9,18 +8,8 @@ try: except ImportError: pass -from module.plugins.internal.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) +from module.plugins.internal.Addon import Addon +from module.plugins.internal.misc import forward, lock, threaded #@TODO: IPv6 support @@ -46,8 +35,8 @@ class ClickNLoad(Addon): if not self.pyload.config.get("webinterface", "activated"): return - cnlip = "" if self.get_config('extern') else "127.0.0.1" - cnlport = self.get_config('port') + cnlip = "" if self.config.get('extern') else "127.0.0.1" + cnlport = self.config.get('port') webip = "127.0.0.1" if any(_ip == self.pyload.config.get("webinterface", "host") for _ip in ("0.0.0.0", "")) \ else self.pyload.config.get("webinterface", "host") webport = self.pyload.config.get("webinterface", "port") @@ -55,8 +44,9 @@ class ClickNLoad(Addon): self.pyload.scheduler.addJob(5, self.proxy, [cnlip, cnlport, webip, webport], threaded=False) + @lock @threaded - def forward(self, source, destination, queue=False): + def forward(self, source, destination, queue=False) if queue: old_ids = set(pack.id for pack in self.pyload.api.getCollector()) @@ -71,13 +61,8 @@ class ClickNLoad(Addon): @threaded def proxy(self, cnlip, cnlport, webip, webport): self.log_info(_("Proxy listening on %s:%s") % (cnlip or "0.0.0.0", cnlport)) - self._server(cnlip, cnlport, webip, webport) - lock = threading.Lock() - lock.acquire() - lock.acquire() - @threaded def _server(self, cnlip, cnlport, webip, webport): @@ -108,7 +93,7 @@ class ClickNLoad(Addon): server_socket.connect((webip, webport)) - self.forward(client_socket, server_socket, self.get_config('dest') is "queue") + self.forward(client_socket, server_socket, self.config.get('dest') is "queue") self.forward(server_socket, client_socket) except socket.timeout: |