diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-02-14 15:17:07 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2011-02-14 15:17:07 +0100 |
commit | 1ecd9254b361d4e026e7a25f1b47382d1015e63c (patch) | |
tree | 183e5215126435b5b9bc986d86e616bafccb1645 /module/remote | |
parent | some parts of cli working again (diff) | |
download | pyload-1ecd9254b361d4e026e7a25f1b47382d1015e63c.tar.xz |
default thrift backend
Diffstat (limited to 'module/remote')
-rw-r--r-- | module/remote/RemoteManager.py | 18 | ||||
-rw-r--r-- | module/remote/ThriftBackend.py | 4 | ||||
-rw-r--r-- | module/remote/XMLRPCBackend.py | 4 | ||||
-rw-r--r-- | module/remote/thriftbackend/ThriftClient.py | 2 |
4 files changed, 18 insertions, 10 deletions
diff --git a/module/remote/RemoteManager.py b/module/remote/RemoteManager.py index e0e5cdccf..e57424eed 100644 --- a/module/remote/RemoteManager.py +++ b/module/remote/RemoteManager.py @@ -26,7 +26,6 @@ class BackendBase(Thread): self.core = manager.core def run(self): - self.core.log.info(_("Starting %s") % self.__class__.__name__) try: self.serve() except: @@ -34,7 +33,7 @@ class BackendBase(Thread): if self.core.debug: print_exc() - def setup(self): + def setup(self, host, port): pass def checkDeps(self): @@ -47,21 +46,28 @@ class BackendBase(Thread): return self.manager.checkAuth(user, password, remoteip) class RemoteManager(): - available = ("XMLRPCBackend", "ThriftBackend") - #available = ("ThriftBackend", ) + available = ["ThriftBackend"] def __init__(self, core): self.core = core self.backends = [] def startBackends(self): + + host = self.core.config["remote"]["listenaddr"] + port = self.core.config["remote"]["port"] + + if self.core.config["remote"]["xmlrpc"]: + self.available.append("XMLRPCBackend") + for b in self.available: klass = getattr(__import__("module.remote.%s" % b, globals(), locals(), [b] , -1), b) backend = klass(self) if not backend.checkDeps(): continue try: - backend.setup() + backend.setup(host, port) + self.core.log.info(_("Starting %(name)s: %(addr)s:%(port)s") % {"name": b, "addr": host, "port": port}) except: self.core.log.error(_("Failed loading backend %s") % b) if self.core.debug: @@ -70,6 +76,8 @@ class RemoteManager(): backend.start() self.backends.append(backend) + port += 1 + def checkAuth(self, user, password, remoteip=None): if self.core.config["remote"]["nolocalauth"] and remoteip == "127.0.0.1": return True diff --git a/module/remote/ThriftBackend.py b/module/remote/ThriftBackend.py index 208fb8c72..ac7d1f857 100644 --- a/module/remote/ThriftBackend.py +++ b/module/remote/ThriftBackend.py @@ -28,7 +28,7 @@ from thriftbackend.Transport import TransportFactory from thrift.server import TServer class ThriftBackend(BackendBase): - def setup(self): + def setup(self, host, port): handler = Handler(self) processor = Processor(handler) @@ -41,7 +41,7 @@ class ThriftBackend(BackendBase): key = self.core.config['ssl']['key'] cert = self.core.config['ssl']['cert'] - transport = ServerSocket(int(self.core.config['remote']['port'])+1, self.core.config["remote"]["listenaddr"], key, cert) + transport = ServerSocket(port, host, key, cert) tfactory = TransportFactory() pfactory = ProtocolFactory() diff --git a/module/remote/XMLRPCBackend.py b/module/remote/XMLRPCBackend.py index 08803df23..50b37f17b 100644 --- a/module/remote/XMLRPCBackend.py +++ b/module/remote/XMLRPCBackend.py @@ -21,8 +21,8 @@ import module.lib.SecureXMLRPCServer as Server from module.remote.RemoteManager import BackendBase class XMLRPCBackend(BackendBase): - def setup(self): - server_addr = (self.core.config['remote']['listenaddr'], int(self.core.config['remote']['port'])) + def setup(self, host, port): + server_addr = (host, port) if self.core.config['ssl']['activated']: if exists(self.core.config['ssl']['cert']) and exists(self.core.config['ssl']['key']): self.core.log.info(_("Using SSL XMLRPCBackend")) diff --git a/module/remote/thriftbackend/ThriftClient.py b/module/remote/thriftbackend/ThriftClient.py index c6a48df2b..c5beec96e 100644 --- a/module/remote/thriftbackend/ThriftClient.py +++ b/module/remote/thriftbackend/ThriftClient.py @@ -30,7 +30,7 @@ class NoSSL(Exception): pass class ThriftClient: - def __init__(self, host="localhost", port=7228, user="", password=""): + def __init__(self, host="localhost", port=7227, user="", password=""): self.createConnection(host, port) try: |