summaryrefslogtreecommitdiffstats
path: root/module/remote/thriftbackend
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2011-02-13 15:06:03 +0100
committerGravatar mkaay <mkaay@mkaay.de> 2011-02-13 15:06:03 +0100
commit908c28bab89525250172a4013667319942846065 (patch)
tree73b85517ae12f8be4bc2071409136f181907795d /module/remote/thriftbackend
parentcleanup (diff)
downloadpyload-908c28bab89525250172a4013667319942846065.tar.xz
fixes + improvements
Diffstat (limited to 'module/remote/thriftbackend')
-rw-r--r--module/remote/thriftbackend/Handler.py7
-rw-r--r--module/remote/thriftbackend/Processor.py4
-rw-r--r--module/remote/thriftbackend/Socket.py2
-rw-r--r--module/remote/thriftbackend/ThriftClient.py4
-rw-r--r--module/remote/thriftbackend/Transport.py15
5 files changed, 24 insertions, 8 deletions
diff --git a/module/remote/thriftbackend/Handler.py b/module/remote/thriftbackend/Handler.py
index 6eb2a8bc6..6e1377938 100644
--- a/module/remote/thriftbackend/Handler.py
+++ b/module/remote/thriftbackend/Handler.py
@@ -4,6 +4,7 @@ from thriftgen.pyload.ttypes import *
from thriftgen.pyload.Pyload import Iface
from module.PyFile import PyFile
+from module.utils import freeSpace
class Handler(Iface):
def __init__(self, backend):
@@ -90,7 +91,7 @@ class Handler(Iface):
return serverStatus
def freeSpace(self):
- return self.core.freeSpace() #bytes
+ return freeSpace(self.core.config["general"]["download_folder"])
def getServerVersion(self):
return self.serverMethods.get_server_version()
@@ -479,13 +480,13 @@ class Handler(Iface):
self.serverMethods.remove_account(plugin, account)
#auth
- def login(self, username, password):
+ def login(self, username, password, remoteip=None):
"""
Parameters:
- username
- password
"""
- return True if self.serverMethods.checkAuth(username, password) else False
+ return self.backend.checkAuth(username, password, remoteip)
def getUserData(self):
return self.serverMethods.checkAuth(username, password)
diff --git a/module/remote/thriftbackend/Processor.py b/module/remote/thriftbackend/Processor.py
index 53c6e404d..8aea42960 100644
--- a/module/remote/thriftbackend/Processor.py
+++ b/module/remote/thriftbackend/Processor.py
@@ -32,7 +32,7 @@ class Processor(Pyload.Processor):
args.read(iprot)
iprot.readMessageEnd()
result = Pyload.login_result()
- self.authenticated[trans] = self._handler.login(args.username, args.password)
+ self.authenticated[trans] = self._handler.login(args.username, args.password, trans.remoteaddr[0])
result.success = self.authenticated[trans]
oprot.writeMessageBegin("login", Pyload.TMessageType.REPLY, seqid)
result.write(oprot)
@@ -40,4 +40,4 @@ class Processor(Pyload.Processor):
oprot.trans.flush()
else:
self._processMap[name](self, seqid, iprot, oprot)
- return True \ No newline at end of file
+ return True
diff --git a/module/remote/thriftbackend/Socket.py b/module/remote/thriftbackend/Socket.py
index d8d3d8db4..33daab4c0 100644
--- a/module/remote/thriftbackend/Socket.py
+++ b/module/remote/thriftbackend/Socket.py
@@ -103,4 +103,4 @@ class ServerSocket(TServerSocket, Socket):
client, addr = self.handle.accept()
result = Socket()
result.setHandle(client)
- return result \ No newline at end of file
+ return result
diff --git a/module/remote/thriftbackend/ThriftClient.py b/module/remote/thriftbackend/ThriftClient.py
index 9fcabc4e7..67474b2bb 100644
--- a/module/remote/thriftbackend/ThriftClient.py
+++ b/module/remote/thriftbackend/ThriftClient.py
@@ -52,7 +52,7 @@ class ThriftClient:
correct = self.client.login(user, password)
finally:
self.socket.setTimeout(None)
-
+
if not correct:
self.transport.close()
raise WrongLogin
@@ -80,4 +80,4 @@ if __name__ == "__main__":
for p in q:
data = client.getPackageData(p.pid)
print data
- print "Package Name: ", data.name \ No newline at end of file
+ print "Package Name: ", data.name
diff --git a/module/remote/thriftbackend/Transport.py b/module/remote/thriftbackend/Transport.py
new file mode 100644
index 000000000..50638f461
--- /dev/null
+++ b/module/remote/thriftbackend/Transport.py
@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+
+from thrift.transport.TTransport import TBufferedTransport
+
+class Transport(TBufferedTransport):
+ DEFAULT_BUFFER = 4096
+
+ def __init__(self, trans, rbuf_size = DEFAULT_BUFFER):
+ TBufferedTransport.__init__(self, trans, rbuf_size)
+ self.remoteaddr = trans.handle.getpeername()
+
+class TransportFactory:
+ def getTransport(self, trans):
+ buffered = Transport(trans)
+ return buffered