From d442ce97a7ba66d90527cfbee313dc5640975def Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 25 Dec 2014 16:07:09 +0100 Subject: [ClickAndLoad] Revert initPeriodical --- module/plugins/hooks/ClickAndLoad.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 27d99c71c..04aac2f10 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -52,7 +52,7 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.23" + __version__ = "0.24" __config__ = [("activated", "bool", "Activated", True), ("extern", "bool", "Allow external link adding", False)] @@ -63,11 +63,6 @@ class ClickAndLoad(Hook): ("mkaay", "mkaay@mkaay.de")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass - - def coreReady(self): self.port = int(self.config['webinterface']['port']) if self.config['webinterface']['activated']: -- cgit v1.2.3 From 354ecbc78898efb4a31a7272e5ea1f5e00a53327 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 4 Jan 2015 19:52:02 +0100 Subject: [ClickAndLoad] Updated --- module/plugins/hooks/ClickAndLoad.py | 104 ++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 50 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 04aac2f10..8ef31ec1e 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -1,41 +1,10 @@ # -*- coding: utf-8 -*- import socket -import thread - -from module.plugins.Hook import Hook - - -def proxy(self, *settings): - thread.start_new_thread(server, (self,) + settings) - lock = thread.allocate_lock() - lock.acquire() - lock.acquire() - - -def server(self, *settings): - try: - dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - dock_socket.bind((settings[0], settings[2])) - dock_socket.listen(5) - while True: - client_socket = dock_socket.accept()[0] - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server_socket.connect(("127.0.0.1", settings[1])) - thread.start_new_thread(forward, (client_socket, server_socket)) - thread.start_new_thread(forward, (server_socket, client_socket)) - except socket.error, e: - if hasattr(e, "errno"): - errno = e.errno - else: - errno = e.args[0] - if errno == 98: - self.logWarning(_("Click'N'Load: Port 9666 already in use")) - return - thread.start_new_thread(server, (self,) + settings) - except: - thread.start_new_thread(server, (self,) + settings) +from threading import Thread, Lock + +from module.plugins.Hook import Hook, threaded def forward(source, destination): @@ -45,33 +14,68 @@ def forward(source, destination): if string: destination.sendall(string) else: - #source.shutdown(socket.SHUT_RD) destination.shutdown(socket.SHUT_WR) class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.24" + __version__ = "0.25" - __config__ = [("activated", "bool", "Activated", True), - ("extern", "bool", "Allow external link adding", False)] + __config__ = [("activated", "bool", "Activated" , True ), + ("port" , "int" , "Port" , 9666 ), + ("extern" , "bool", "Listen for requests coming from WAN (internet)", False)] __description__ = """Click'N'Load hook plugin""" __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.de"), - ("mkaay", "mkaay@mkaay.de")] + ("Walter Purcaro", "vuolter@gmail.com")] def coreReady(self): - self.port = int(self.config['webinterface']['port']) - if self.config['webinterface']['activated']: - try: - if self.getConfig("extern"): - ip = "0.0.0.0" - else: - ip = "127.0.0.1" - - thread.start_new_thread(proxy, (self, ip, self.port, 9666)) - except: - self.logError(_("ClickAndLoad port already in use")) + if not self.config['webinterface']['activated']: + return + + ip = "0.0.0.0" if self.getConfig("extern") else "127.0.0.1" + webport = int(self.config['webinterface']['port']) + cnlport = self.getConfig('port') + + self.proxy(ip, webport, cnlport) + + + @threaded + def proxy(self, ip, webport, cnlport): + hookManager.startThread(self.server, ip, webport, cnlport) + lock = Lock() + lock.acquire() + lock.acquire() + + + 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: + server_socket = dock_socket.accept()[0] + client_socket = socket.create_connection(("127.0.0.1", webport)) + + hookManager.startThread(forward, server_socket, client_socket) + hookManager.startThread(forward, client_socket, server_socket) + + except socket.error, e: + if hasattr(e, "errno"): + errno = e.errno + else: + errno = e.args[0] + + if errno == 98: + self.logWarning(_("Port %s already in use") % cnlport) + else: + self.logError(e) + self.server(ip, webport, cnlport) + + except Exception, e: + self.logError(e) + self.server(ip, webport, cnlport) -- cgit v1.2.3 From 7e5e88778c2dd4fac088cffbd2fba4384dde8582 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 13 Jan 2015 01:45:31 +0100 Subject: [ClickAndLoad] Fix error "Port already in use" --- module/plugins/hooks/ClickAndLoad.py | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 8ef31ec1e..222310c25 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -3,6 +3,7 @@ import socket from threading import Thread, Lock +from time import sleep from module.plugins.Hook import Hook, threaded @@ -20,7 +21,7 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.25" + __version__ = "0.26" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -54,6 +55,8 @@ class ClickAndLoad(Hook): def server(self, ip, webport, cnlport): try: dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + dock_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) dock_socket.bind((ip, cnlport)) dock_socket.listen(5) @@ -65,17 +68,8 @@ class ClickAndLoad(Hook): hookManager.startThread(forward, client_socket, server_socket) except socket.error, e: - if hasattr(e, "errno"): - errno = e.errno - else: - errno = e.args[0] - - if errno == 98: - self.logWarning(_("Port %s already in use") % cnlport) - else: - self.logError(e) - self.server(ip, webport, cnlport) - - except Exception, e: self.logError(e) self.server(ip, webport, cnlport) + + finally: + dock_socket.close() -- cgit v1.2.3 From feef23fadfdfbf64b38ea0be817e36321160be1f Mon Sep 17 00:00:00 2001 From: Nippey Date: Thu, 22 Jan 2015 16:47:29 +0100 Subject: socket.create_connection is unavailable in Python25 socket.create_connection doesn't exist in Python 2.5. But it can be modeled with above function taken from: https://hg.python.org/cpython/file/2.6/Lib/socket.py#l534 So, it is how 2.6 does it :) --- module/plugins/hooks/ClickAndLoad.py | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 222310c25..370c40053 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -17,11 +17,40 @@ def forward(source, destination): else: destination.shutdown(socket.SHUT_WR) - +_GLOBAL_DEFAULT_TIMEOUT = object() +def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT): + """Connect to *address* and return the socket object. + + Convenience function. Connect to *address* (a 2-tuple ``(host, + port)``) and return the socket object. Passing the optional + *timeout* parameter will set the timeout on the socket instance + before attempting to connect. If no *timeout* is supplied, the + global default timeout setting returned by :func:`getdefaulttimeout` + is used. + """ + + msg = "getaddrinfo returns an empty list" + host, port = address + for res in getaddrinfo(host, port, 0, socket.SOCK_STREAM): + af, socktype, proto, canonname, sa = res + sock = None + try: + sock = socket(af, socktype, proto) + if timeout is not _GLOBAL_DEFAULT_TIMEOUT: + sock.settimeout(timeout) + sock.connect(sa) + return sock + + except error, msg: + if sock is not None: + sock.close() + + raise error, msg + class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.26" + __version__ = "0.27" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -62,7 +91,7 @@ class ClickAndLoad(Hook): while True: server_socket = dock_socket.accept()[0] - client_socket = socket.create_connection(("127.0.0.1", webport)) + client_socket = create_connection(("127.0.0.1", webport)) hookManager.startThread(forward, server_socket, client_socket) hookManager.startThread(forward, client_socket, server_socket) -- cgit v1.2.3 From ce27cfd75023d3408cbdd74cf797a5aea7428de7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 23 Jan 2015 00:52:58 +0100 Subject: [ClickAndLoad] Improve create_connection --- module/plugins/hooks/ClickAndLoad.py | 78 +++++++++++++++++++++--------------- 1 file changed, 46 insertions(+), 32 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 370c40053..682639750 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -17,40 +17,55 @@ def forward(source, destination): else: destination.shutdown(socket.SHUT_WR) -_GLOBAL_DEFAULT_TIMEOUT = object() -def create_connection(address, timeout=_GLOBAL_DEFAULT_TIMEOUT): - """Connect to *address* and return the socket object. - - Convenience function. Connect to *address* (a 2-tuple ``(host, - port)``) and return the socket object. Passing the optional - *timeout* parameter will set the timeout on the socket instance - before attempting to connect. If no *timeout* is supplied, the - global default timeout setting returned by :func:`getdefaulttimeout` - is used. - """ - - msg = "getaddrinfo returns an empty list" - host, port = address - for res in getaddrinfo(host, port, 0, socket.SOCK_STREAM): - af, socktype, proto, canonname, sa = res - sock = None - try: - sock = socket(af, socktype, proto) - if timeout is not _GLOBAL_DEFAULT_TIMEOUT: - sock.settimeout(timeout) - sock.connect(sa) - return sock - - except error, msg: - if sock is not None: - sock.close() - - raise error, msg - + +#: socket.create_connection wrapper for python 2.5 +def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, + source_address=None): + try: + return socket.create_connection(address, timeout, source_address) + + except SyntaxError: + """Connect to *address* and return the socket object. + + Convenience function. Connect to *address* (a 2-tuple ``(host, + port)``) and return the socket object. Passing the optional + *timeout* parameter will set the timeout on the socket instance + before attempting to connect. If no *timeout* is supplied, the + global default timeout setting returned by :func:`getdefaulttimeout` + is used. If *source_address* is set it must be a tuple of (host, port) + for the socket to bind as a source address before making the connection. + An host of \'\' or port 0 tells the OS to use the default. + """ + + host, port = address + err = None + for res in getaddrinfo(host, port, 0, SOCK_STREAM): + af, socktype, proto, canonname, sa = res + sock = None + try: + sock = socket(af, socktype, proto) + if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT: + sock.settimeout(timeout) + if source_address: + sock.bind(source_address) + sock.connect(sa) + return sock + + except error as _: + err = _ + if sock is not None: + sock.close() + + if err is not None: + raise err + else: + raise error("getaddrinfo returns an empty list") + + class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.27" + __version__ = "0.28" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -98,7 +113,6 @@ class ClickAndLoad(Hook): except socket.error, e: self.logError(e) - self.server(ip, webport, cnlport) finally: dock_socket.close() -- cgit v1.2.3 From d95f42fd8aef58a1aa892a8540a7ec360540d90a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 25 Jan 2015 16:54:40 +0100 Subject: [ClickAndLoad] Fix bad except --- module/plugins/hooks/ClickAndLoad.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 682639750..c8e5e0e98 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -51,7 +51,7 @@ def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, sock.connect(sa) return sock - except error as _: + except socket.error, _: err = _ if sock is not None: sock.close() @@ -59,13 +59,13 @@ def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, if err is not None: raise err else: - raise error("getaddrinfo returns an empty list") + raise socket.error("getaddrinfo returns an empty list") class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.28" + __version__ = "0.29" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), -- cgit v1.2.3 From b9ca6e20d44b6bbe95c7becc566b351b3f39c1e6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 26 Jan 2015 00:20:26 +0100 Subject: [ClickAndLoad] Fix create_connection in python 2.5 --- module/plugins/hooks/ClickAndLoad.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index c8e5e0e98..80201fe23 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -19,10 +19,11 @@ def forward(source, destination): #: socket.create_connection wrapper for python 2.5 -def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, - source_address=None): +def create_connection(address, timeout=object(), source_address=None): try: - return socket.create_connection(address, timeout, source_address) + return socket.create_connection(address, + socket._GLOBAL_DEFAULT_TIMEOUT if type(timeout) == object else timeout, + source_address) except SyntaxError: """Connect to *address* and return the socket object. @@ -44,7 +45,7 @@ def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, sock = None try: sock = socket(af, socktype, proto) - if timeout is not socket._GLOBAL_DEFAULT_TIMEOUT: + if type(timeout) != object: sock.settimeout(timeout) if source_address: sock.bind(source_address) @@ -65,7 +66,7 @@ def create_connection(address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.29" + __version__ = "0.30" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), -- cgit v1.2.3 From 49397d8e52e7c68a4ce3c1eb74792e23d79f3ebb Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 27 Jan 2015 17:46:19 +0100 Subject: [ClickAndLoad] Use self.manager instead hookManager --- module/plugins/hooks/ClickAndLoad.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 80201fe23..94a240d4c 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -66,7 +66,7 @@ def create_connection(address, timeout=object(), source_address=None): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.30" + __version__ = "0.31" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -91,7 +91,7 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): - hookManager.startThread(self.server, ip, webport, cnlport) + self.manager.startThread(self.server, ip, webport, cnlport) lock = Lock() lock.acquire() lock.acquire() @@ -109,8 +109,8 @@ class ClickAndLoad(Hook): server_socket = dock_socket.accept()[0] client_socket = create_connection(("127.0.0.1", webport)) - hookManager.startThread(forward, server_socket, client_socket) - hookManager.startThread(forward, client_socket, server_socket) + self.manager.startThread(forward, server_socket, client_socket) + self.manager.startThread(forward, client_socket, server_socket) except socket.error, e: self.logError(e) -- cgit v1.2.3 From 2fa8ca10879e163e5f20c9d7b8645e376e9941f3 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 1 Feb 2015 23:32:34 +0100 Subject: [ClickAndLoad] Improve --- module/plugins/hooks/ClickAndLoad.py | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 94a240d4c..7ece12781 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -20,24 +20,13 @@ def forward(source, destination): #: socket.create_connection wrapper for python 2.5 def create_connection(address, timeout=object(), source_address=None): - try: - return socket.create_connection(address, - socket._GLOBAL_DEFAULT_TIMEOUT if type(timeout) == object else timeout, - source_address) - - except SyntaxError: - """Connect to *address* and return the socket object. - - Convenience function. Connect to *address* (a 2-tuple ``(host, - port)``) and return the socket object. Passing the optional - *timeout* parameter will set the timeout on the socket instance - before attempting to connect. If no *timeout* is supplied, the - global default timeout setting returned by :func:`getdefaulttimeout` - is used. If *source_address* is set it must be a tuple of (host, port) - for the socket to bind as a source address before making the connection. - An host of \'\' or port 0 tells the OS to use the default. - """ + if hasattr(socket, 'create_connection'): + if type(timeout) == object: + timeout = socket._GLOBAL_DEFAULT_TIMEOUT + return socket.create_connection(address, timeout, source_address) + + else: host, port = address err = None for res in getaddrinfo(host, port, 0, SOCK_STREAM): @@ -66,7 +55,7 @@ def create_connection(address, timeout=object(), source_address=None): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.31" + __version__ = "0.32" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -114,6 +103,7 @@ class ClickAndLoad(Hook): except socket.error, e: self.logError(e) + self.server(ip, webport, cnlport) finally: dock_socket.close() -- cgit v1.2.3 From f6295ec0a2e6a819977afa66bbed3da15017c700 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 3 Feb 2015 02:37:17 +0100 Subject: [ClickAndLoad] Fix https://github.com/pyload/pyload/issues/1135 --- module/plugins/hooks/ClickAndLoad.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 7ece12781..0bcd6ddef 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -9,13 +9,14 @@ from module.plugins.Hook import Hook, threaded def forward(source, destination): - string = ' ' - while string: - string = source.recv(1024) - if string: - destination.sendall(string) - else: - destination.shutdown(socket.SHUT_WR) + try: + size = 1024 + data = source.recv(size) + while data: + destination.sendall(data) + data = source.recv(size) + finally: + destination.shutdown(socket.SHUT_WR) #: socket.create_connection wrapper for python 2.5 @@ -55,7 +56,7 @@ def create_connection(address, timeout=object(), source_address=None): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.32" + __version__ = "0.33" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -89,21 +90,21 @@ class ClickAndLoad(Hook): def server(self, ip, webport, cnlport): try: dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - dock_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) dock_socket.bind((ip, cnlport)) dock_socket.listen(5) while True: - server_socket = dock_socket.accept()[0] - client_socket = create_connection(("127.0.0.1", webport)) + client_socket = dock_socket.accept()[0] + server_socket = create_connection(("127.0.0.1", webport)) - self.manager.startThread(forward, server_socket, client_socket) self.manager.startThread(forward, client_socket, server_socket) + self.manager.startThread(forward, server_socket, client_socket) except socket.error, e: - self.logError(e) + self.logDebug(e) self.server(ip, webport, cnlport) finally: + client_socket.close() + server_socket.close() dock_socket.close() -- cgit v1.2.3 From fd7e1994a94c58aa0ba69808223f5f6a9b99f718 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 12 Feb 2015 00:02:41 +0100 Subject: [ClickAndLoad] Fix https://github.com/pyload/pyload/issues/1158 --- module/plugins/hooks/ClickAndLoad.py | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 0bcd6ddef..40e6ded65 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -10,16 +10,16 @@ from module.plugins.Hook import Hook, threaded def forward(source, destination): try: - size = 1024 - data = source.recv(size) + bufsize = 1024 + data = source.recv(bufsize) while data: destination.sendall(data) - data = source.recv(size) + data = source.recv(bufsize) finally: destination.shutdown(socket.SHUT_WR) -#: socket.create_connection wrapper for python 2.5 +#: create_connection wrapper for python 2.5 socket module def create_connection(address, timeout=object(), source_address=None): if hasattr(socket, 'create_connection'): if type(timeout) == object: @@ -56,7 +56,7 @@ def create_connection(address, timeout=object(), source_address=None): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.33" + __version__ = "0.34" __config__ = [("activated", "bool", "Activated" , True ), ("port" , "int" , "Port" , 9666 ), @@ -72,7 +72,7 @@ class ClickAndLoad(Hook): if not self.config['webinterface']['activated']: return - ip = "0.0.0.0" if self.getConfig("extern") else "127.0.0.1" + ip = socket.gethostbyname(socket.gethostname()) if self.getConfig("extern") else "127.0.0.1" webport = int(self.config['webinterface']['port']) cnlport = self.getConfig('port') @@ -89,22 +89,23 @@ class ClickAndLoad(Hook): 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) + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + server_socket.bind((ip, cnlport)) + server_socket.listen(5) while True: - client_socket = dock_socket.accept()[0] - server_socket = create_connection(("127.0.0.1", webport)) + client_socket = server_socket.accept()[0] + dock_socket = create_connection(("127.0.0.1", webport)) - self.manager.startThread(forward, client_socket, server_socket) - self.manager.startThread(forward, server_socket, client_socket) + self.manager.startThread(forward, client_socket, dock_socket) + self.manager.startThread(forward, dock_socket, client_socket) + client_socket.close() + dock_socket.close() except socket.error, e: self.logDebug(e) self.server(ip, webport, cnlport) finally: - client_socket.close() server_socket.close() - dock_socket.close() -- cgit v1.2.3 From 65a02207360423ea83314eb3ea3178095c1bbd2e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 12 Feb 2015 00:29:23 +0100 Subject: [ClickAndLoad] Small code cosmetics --- module/plugins/hooks/ClickAndLoad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 40e6ded65..d0f340aae 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -3,7 +3,6 @@ import socket from threading import Thread, Lock -from time import sleep from module.plugins.Hook import Hook, threaded @@ -100,6 +99,7 @@ class ClickAndLoad(Hook): self.manager.startThread(forward, client_socket, dock_socket) self.manager.startThread(forward, dock_socket, client_socket) + client_socket.close() dock_socket.close() -- cgit v1.2.3 From 8ef57f185a386883da33c83ccdd96a12d51f03b8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 15 Feb 2015 01:51:37 +0100 Subject: [ClickAndLoad] Fixup --- module/plugins/hooks/ClickAndLoad.py | 49 +++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 18 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index d0f340aae..8b53872e4 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -2,7 +2,7 @@ import socket -from threading import Thread, Lock +from threading import Lock from module.plugins.Hook import Hook, threaded @@ -10,10 +10,10 @@ from module.plugins.Hook import Hook, threaded def forward(source, destination): try: bufsize = 1024 - data = source.recv(bufsize) - while data: - destination.sendall(data) - data = source.recv(bufsize) + bufdata = source.recv(bufsize) + while bufdata: + destination.sendall(bufdata) + bufdata = source.recv(bufsize) finally: destination.shutdown(socket.SHUT_WR) @@ -55,11 +55,11 @@ def create_connection(address, timeout=object(), source_address=None): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.34" + __version__ = "0.35" - __config__ = [("activated", "bool", "Activated" , True ), - ("port" , "int" , "Port" , 9666 ), - ("extern" , "bool", "Listen for requests coming from WAN (internet)", False)] + __config__ = [("activated", "bool", "Activated" , True), + ("port" , "int" , "Port" , 9666), + ("extern" , "bool", "Listen on the public network interface", True)] __description__ = """Click'N'Load hook plugin""" __license__ = "GPLv3" @@ -67,6 +67,11 @@ class ClickAndLoad(Hook): ("Walter Purcaro", "vuolter@gmail.com")] + #@TODO: Remove in 0.4.10 + def initPeriodical(self): + pass + + def coreReady(self): if not self.config['webinterface']['activated']: return @@ -80,13 +85,13 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): - self.manager.startThread(self.server, ip, webport, cnlport) + self.manager.startThread(self._server, ip, webport, cnlport) lock = Lock() lock.acquire() lock.acquire() - def server(self, ip, webport, cnlport): + def _server(self, ip, webport, cnlport, thread): try: server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) @@ -97,15 +102,23 @@ class ClickAndLoad(Hook): client_socket = server_socket.accept()[0] dock_socket = create_connection(("127.0.0.1", webport)) - self.manager.startThread(forward, client_socket, dock_socket) self.manager.startThread(forward, dock_socket, client_socket) - - client_socket.close() - dock_socket.close() + self.manager.startThread(forward, client_socket, dock_socket) except socket.error, e: self.logDebug(e) - self.server(ip, webport, cnlport) + self._server(ip, webport, cnlport, thread) - finally: - server_socket.close() + except Exception, e: + self.logError(e) + + try: + client_socket.close() + dock_socket.close() + except Exception: + pass + + try: + server_socket.close() + except Exception: + pass -- cgit v1.2.3 From e98807ebce1220afdac21e7dfabe04f7ee2acdcf Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Feb 2015 22:09:19 +0100 Subject: [ClickAndLoad] Fix https://github.com/pyload/pyload/issues/1186 --- module/plugins/hooks/ClickAndLoad.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 8b53872e4..a0eacd10f 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -21,7 +21,7 @@ def forward(source, destination): #: create_connection wrapper for python 2.5 socket module def create_connection(address, timeout=object(), source_address=None): if hasattr(socket, 'create_connection'): - if type(timeout) == object: + if type(timeout) is object: timeout = socket._GLOBAL_DEFAULT_TIMEOUT return socket.create_connection(address, timeout, source_address) @@ -29,11 +29,11 @@ def create_connection(address, timeout=object(), source_address=None): else: host, port = address err = None - for res in getaddrinfo(host, port, 0, SOCK_STREAM): + for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): af, socktype, proto, canonname, sa = res sock = None try: - sock = socket(af, socktype, proto) + sock = socket.socket(af, socktype, proto) if type(timeout) != object: sock.settimeout(timeout) if source_address: @@ -41,21 +41,18 @@ def create_connection(address, timeout=object(), source_address=None): sock.connect(sa) return sock - except socket.error, _: - err = _ + except socket.error, e: + err = e if sock is not None: sock.close() - - if err is not None: - raise err else: - raise socket.error("getaddrinfo returns an empty list") + raise socket.error(err or "getaddrinfo returns an empty list") class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.35" + __version__ = "0.36" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -76,7 +73,7 @@ class ClickAndLoad(Hook): if not self.config['webinterface']['activated']: return - ip = socket.gethostbyname(socket.gethostname()) if self.getConfig("extern") else "127.0.0.1" + ip = "0.0.0.0" if self.getConfig("extern") else "127.0.0.1" webport = int(self.config['webinterface']['port']) cnlport = self.getConfig('port') @@ -85,6 +82,7 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): + self.logInfo(_("Proxy listening on %s:%s") % (ip, cnlport)) self.manager.startThread(self._server, ip, webport, cnlport) lock = Lock() lock.acquire() -- cgit v1.2.3 From 547e5991a861c68d3b87d59eda3aeb8b41116cbd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 20 Feb 2015 16:20:42 +0100 Subject: [ClickAndLoad] Improve --- module/plugins/hooks/ClickAndLoad.py | 81 ++++++++++++------------------------ 1 file changed, 27 insertions(+), 54 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index a0eacd10f..0d95a801d 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import socket +import time from threading import Lock @@ -18,41 +19,11 @@ def forward(source, destination): destination.shutdown(socket.SHUT_WR) -#: create_connection wrapper for python 2.5 socket module -def create_connection(address, timeout=object(), source_address=None): - if hasattr(socket, 'create_connection'): - if type(timeout) is object: - timeout = socket._GLOBAL_DEFAULT_TIMEOUT - - return socket.create_connection(address, timeout, source_address) - - else: - host, port = address - err = None - for res in socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM): - af, socktype, proto, canonname, sa = res - sock = None - try: - sock = socket.socket(af, socktype, proto) - if type(timeout) != object: - sock.settimeout(timeout) - if source_address: - sock.bind(source_address) - sock.connect(sa) - return sock - - except socket.error, e: - err = e - if sock is not None: - sock.close() - else: - raise socket.error(err or "getaddrinfo returns an empty list") - - +#@TODO: IPv6 support class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.36" + __version__ = "0.37" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -73,7 +44,7 @@ class ClickAndLoad(Hook): if not self.config['webinterface']['activated']: return - ip = "0.0.0.0" if self.getConfig("extern") else "127.0.0.1" + ip = "" if self.getConfig("extern") else "127.0.0.1" webport = int(self.config['webinterface']['port']) cnlport = self.getConfig('port') @@ -91,32 +62,34 @@ class ClickAndLoad(Hook): def _server(self, ip, webport, cnlport, thread): try: - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - server_socket.bind((ip, cnlport)) - server_socket.listen(5) + try: + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - while True: - client_socket = server_socket.accept()[0] - dock_socket = create_connection(("127.0.0.1", webport)) + server_socket.bind((ip, cnlport)) + server_socket.listen(5) - self.manager.startThread(forward, dock_socket, client_socket) - self.manager.startThread(forward, client_socket, dock_socket) + while True: + client_socket = server_socket.accept()[0] + dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - except socket.error, e: - self.logDebug(e) - self._server(ip, webport, cnlport, thread) + dock_socket.connect(("127.0.0.1", webport)) - except Exception, e: - self.logError(e) + self.manager.startThread(forward, dock_socket, client_socket) + self.manager.startThread(forward, client_socket, dock_socket) - try: + except socket.timeout: + self.logDebug("Connection timed out, retrying...") + return self._server(ip, webport, cnlport, thread) + + finally: + server_socket.close() client_socket.close() dock_socket.close() - except Exception: - pass - try: - server_socket.close() - except Exception: - pass + except socket.error, e: + self.logError(e) + time.sleep(120) + self._server(ip, webport, cnlport, thread) + + except Exception, e: + self.logError(e) -- cgit v1.2.3 From d371d98a4a6a803efce3f1cfc779ee2b887cd4e7 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 20 Feb 2015 16:21:36 +0100 Subject: [ClickAndLoad] Improve (2) --- module/plugins/hooks/ClickAndLoad.py | 3 --- 1 file changed, 3 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 0d95a801d..6691bb1fe 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -90,6 +90,3 @@ class ClickAndLoad(Hook): self.logError(e) time.sleep(120) self._server(ip, webport, cnlport, thread) - - except Exception, e: - self.logError(e) -- cgit v1.2.3 From 93eb54614d512396a5505cb9bdea4e201920b434 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 1 Mar 2015 00:33:21 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/ClickAndLoad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 6691bb1fe..5b21aec96 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -53,7 +53,7 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): - self.logInfo(_("Proxy listening on %s:%s") % (ip, cnlport)) + self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) self.manager.startThread(self._server, ip, webport, cnlport) lock = Lock() lock.acquire() -- cgit v1.2.3 From 5ea0fe898b435a5654e0a14172025779c82182d6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 2 Mar 2015 00:39:51 +0100 Subject: [ClickAndLoad] Revert and improve --- module/plugins/hooks/ClickAndLoad.py | 50 +++++++++++++++++------------------- 1 file changed, 24 insertions(+), 26 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 5b21aec96..1a7dec6ac 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -16,6 +16,7 @@ def forward(source, destination): destination.sendall(bufdata) bufdata = source.recv(bufsize) finally: + source.shutdown(socket.SHUT_RD) destination.shutdown(socket.SHUT_WR) @@ -23,13 +24,13 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.37" + __version__ = "0.38" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), ("extern" , "bool", "Listen on the public network interface", True)] - __description__ = """Click'N'Load hook plugin""" + __description__ = """Click'n'Load hook plugin""" __license__ = "GPLv3" __authors__ = [("RaNaN", "RaNaN@pyload.de"), ("Walter Purcaro", "vuolter@gmail.com")] @@ -45,7 +46,7 @@ class ClickAndLoad(Hook): return ip = "" if self.getConfig("extern") else "127.0.0.1" - webport = int(self.config['webinterface']['port']) + webport = self.config['webinterface']['port'] cnlport = self.getConfig('port') self.proxy(ip, webport, cnlport) @@ -54,39 +55,36 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) - self.manager.startThread(self._server, ip, webport, cnlport) + + self._server(ip, webport, cnlport) + lock = Lock() lock.acquire() lock.acquire() - def _server(self, ip, webport, cnlport, thread): + @threaded + def _server(self, ip, webport, cnlport): try: - try: - server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + dock_socket.bind((ip, cnlport)) + dock_socket.listen(1) - server_socket.bind((ip, cnlport)) - server_socket.listen(5) + while True: + client_socket, client_addr = dock_socket.accept() + self.logDebug("Connection from: %s" % client_addr) - while True: - client_socket = server_socket.accept()[0] - dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - - dock_socket.connect(("127.0.0.1", webport)) - - self.manager.startThread(forward, dock_socket, client_socket) - self.manager.startThread(forward, client_socket, dock_socket) + server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + server_socket.connect(("127.0.0.1", webport)) - except socket.timeout: - self.logDebug("Connection timed out, retrying...") - return self._server(ip, webport, cnlport, thread) + self.manager.startThread(forward, client_socket, server_socket) + self.manager.startThread(forward, server_socket, client_socket) - finally: - server_socket.close() - client_socket.close() - dock_socket.close() + except socket.timeout: + self.logDebug("Connection timed out, retrying...") + return self._server(ip, webport, cnlport) except socket.error, e: self.logError(e) - time.sleep(120) - self._server(ip, webport, cnlport, thread) + time.sleep(240) + return self._server(ip, webport, cnlport) -- cgit v1.2.3 From 8d85fb7c11dfa83052d09402dbae21dde44392aa Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 4 Mar 2015 03:12:58 +0100 Subject: [ClickAndLoad] Fix https://github.com/pyload/pyload/issues/1220 --- module/plugins/hooks/ClickAndLoad.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 1a7dec6ac..f3396be77 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -16,15 +16,15 @@ def forward(source, destination): destination.sendall(bufdata) bufdata = source.recv(bufsize) finally: - source.shutdown(socket.SHUT_RD) destination.shutdown(socket.SHUT_WR) + destination.close() #@TODO: IPv6 support class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.38" + __version__ = "0.39" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -68,11 +68,11 @@ class ClickAndLoad(Hook): try: dock_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) dock_socket.bind((ip, cnlport)) - dock_socket.listen(1) + dock_socket.listen(5) while True: client_socket, client_addr = dock_socket.accept() - self.logDebug("Connection from: %s" % client_addr) + 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)) -- cgit v1.2.3 From 9854d2f81577dc3c5c7c97cefd61404f739f4a24 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 5 Mar 2015 23:15:19 +0100 Subject: [ClickAndLoad] Fixup --- module/plugins/hooks/ClickAndLoad.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index f3396be77..938269795 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -17,14 +17,14 @@ def forward(source, destination): bufdata = source.recv(bufsize) finally: destination.shutdown(socket.SHUT_WR) - destination.close() + # destination.close() #@TODO: IPv6 support class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.39" + __version__ = "0.40" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), -- cgit v1.2.3 From 6f7002bcc3520c47fafe5122b0e0cbada313887d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 8 Mar 2015 23:39:59 +0100 Subject: Whitespace cosmetics --- module/plugins/hooks/ClickAndLoad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 938269795..2f5938101 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -32,7 +32,7 @@ class ClickAndLoad(Hook): __description__ = """Click'n'Load hook plugin""" __license__ = "GPLv3" - __authors__ = [("RaNaN", "RaNaN@pyload.de"), + __authors__ = [("RaNaN" , "RaNaN@pyload.de" ), ("Walter Purcaro", "vuolter@gmail.com")] -- cgit v1.2.3 From 7beb65e991bc6d1913c3b5bb2ef69e659d5b8342 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 10 Mar 2015 01:55:52 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/ClickAndLoad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 2f5938101..731c8bd7e 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -45,7 +45,7 @@ class ClickAndLoad(Hook): if not self.config['webinterface']['activated']: return - ip = "" if self.getConfig("extern") else "127.0.0.1" + ip = "" if self.getConfig('extern') else "127.0.0.1" webport = self.config['webinterface']['port'] cnlport = self.getConfig('port') -- cgit v1.2.3 From 2bc144adb6bc2759b635e09687b27bf96074827f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 13:39:07 +0100 Subject: Spare code cosmetics --- module/plugins/hooks/ClickAndLoad.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 731c8bd7e..812f969f9 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -41,6 +41,10 @@ class ClickAndLoad(Hook): pass + def setup(self): + self.info = {} #@TODO: Remove in 0.4.10 + + def coreReady(self): if not self.config['webinterface']['activated']: return -- cgit v1.2.3 From 990c1d9dd74b11b7110b2c66afb48704b5d5901f Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 18 Mar 2015 16:13:45 +0100 Subject: [ClickAndLoad] Fix freeze after a pyLoad restart --- module/plugins/hooks/ClickAndLoad.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 812f969f9..257f58584 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -24,7 +24,7 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.40" + __version__ = "0.41" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -58,6 +58,8 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): + time.sleep(10) #@TODO: Implement addon delay on start in 0.4.10 + self.logInfo(_("Proxy listening on %s:%s") % (ip or "0.0.0.0", cnlport)) self._server(ip, webport, cnlport) -- cgit v1.2.3 From 7d90803262ccbb4fc5296a4dc3ce30fe98f55631 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 25 Mar 2015 23:10:07 +0100 Subject: __config__ cosmetics --- module/plugins/hooks/ClickAndLoad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 257f58584..0564e31ca 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -58,7 +58,7 @@ class ClickAndLoad(Hook): @threaded def proxy(self, ip, webport, cnlport): - time.sleep(10) #@TODO: Implement addon delay on start in 0.4.10 + 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)) -- cgit v1.2.3 From f1ce338ed31e49373cea5453a2fbdb6c686ca510 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Thu, 26 Mar 2015 10:16:04 +0100 Subject: interval code cosmetics --- module/plugins/hooks/ClickAndLoad.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 0564e31ca..2ddd66daa 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -36,9 +36,7 @@ class ClickAndLoad(Hook): ("Walter Purcaro", "vuolter@gmail.com")] - #@TODO: Remove in 0.4.10 - def initPeriodical(self): - pass + interval = 0 #@TODO: Remove in 0.4.10 def setup(self): -- cgit v1.2.3 From c4810d1dbf367c4859a00c18b640fdb86a18ff8f Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Sat, 9 May 2015 22:38:09 +0300 Subject: [ClickAndLoad] fix bug when webinterface uses SSL --- module/plugins/hooks/ClickAndLoad.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 2ddd66daa..1fa89840b 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -3,6 +3,11 @@ import socket import time +try: + import ssl +except ImportError: + pass + from threading import Lock from module.plugins.Hook import Hook, threaded @@ -24,7 +29,7 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.41" + __version__ = "0.42" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), @@ -79,6 +84,21 @@ class ClickAndLoad(Hook): self.logDebug("Connection from %s:%s" % client_addr) server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + + if self.config['webinterface']['https']: + try: + server_socket = ssl.wrap_socket(server_socket) + + except NameError: + self.logError(_("pyLoad's webinterface is configured to use HTTPS, Please install python's ssl lib or + client_socket.close() #: reset the connection. + continue + + except Exception, e: + self.logError(_("SSL error: %s") % e.message) + client_socket.close() #: reset the connection. + continue + server_socket.connect(("127.0.0.1", webport)) self.manager.startThread(forward, client_socket, server_socket) -- cgit v1.2.3 From 1582e816a8cb9a67f420cc9bf69cf2bba6dfbd04 Mon Sep 17 00:00:00 2001 From: GammaC0de Date: Sat, 9 May 2015 23:46:47 +0300 Subject: Update ClickAndLoad.py --- module/plugins/hooks/ClickAndLoad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index 1fa89840b..eb242de1f 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -90,7 +90,7 @@ class ClickAndLoad(Hook): server_socket = ssl.wrap_socket(server_socket) except NameError: - self.logError(_("pyLoad's webinterface is configured to use HTTPS, Please install python's ssl lib or + self.logError(_("pyLoad's webinterface is configured to use HTTPS, Please install python's ssl lib or disable HTTPS")) client_socket.close() #: reset the connection. continue -- cgit v1.2.3 From f22a5c784adcaf3e434fca78fb7eb0141b51c694 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 9 May 2015 22:53:31 +0200 Subject: [ClickAndLoad] Version up --- module/plugins/hooks/ClickAndLoad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hooks/ClickAndLoad.py') diff --git a/module/plugins/hooks/ClickAndLoad.py b/module/plugins/hooks/ClickAndLoad.py index eb242de1f..a7862045e 100644 --- a/module/plugins/hooks/ClickAndLoad.py +++ b/module/plugins/hooks/ClickAndLoad.py @@ -29,7 +29,7 @@ def forward(source, destination): class ClickAndLoad(Hook): __name__ = "ClickAndLoad" __type__ = "hook" - __version__ = "0.42" + __version__ = "0.43" __config__ = [("activated", "bool", "Activated" , True), ("port" , "int" , "Port" , 9666), -- cgit v1.2.3