diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-30 17:09:04 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2009-05-30 17:09:04 +0200 |
commit | 6d2c1e1c9b4dc38d56bc3c5da220675c3d61951d (patch) | |
tree | 2a3997206773aa6f5afb8401d3c6d0772feb0b92 /module/remote | |
parent | tango icons for gui (diff) | |
download | pyload-6d2c1e1c9b4dc38d56bc3c5da220675c3d61951d.tar.xz |
client socket
Diffstat (limited to 'module/remote')
-rw-r--r-- | module/remote/ClientSocket.py | 30 | ||||
-rw-r--r-- | module/remote/RequestHandler.py | 4 | ||||
-rw-r--r-- | module/remote/SocketServer.py | 1 |
3 files changed, 33 insertions, 2 deletions
diff --git a/module/remote/ClientSocket.py b/module/remote/ClientSocket.py new file mode 100644 index 000000000..74f66f0be --- /dev/null +++ b/module/remote/ClientSocket.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# -'- coding: utf-8 -*. +""" +authored by: RaNaN + +socket for connecting to the core's server + +""" +import asynchat +import socket +from RequestHandler import RequestHandler + +class ClientSocket(asynchat.async_chat): + def __init__(self, client): + asynchat.async_chat.__init__(self) + self.client = client + self.data = "" + self.handler = RequestHandler(None) + self.set_terminator("\n") + self.create_socket(socket.AF_INET, socket.SOCK_STREAM) + + def handle_connect(self): + print "connected" + + def collect_incoming_data(self, data): + self.data += data + + def found_terminator(self): + pass + #process diff --git a/module/remote/RequestHandler.py b/module/remote/RequestHandler.py index 1405fd3eb..212f65b1c 100644 --- a/module/remote/RequestHandler.py +++ b/module/remote/RequestHandler.py @@ -21,7 +21,7 @@ from RequestObject import RequestObject class RequestHandler: def __init__(self, core): self.core = core - key = SHA.new(core.config['remotepassword']) + key = SHA.new("pwhere") #core.config['remotepassword'] key = MD5.new(key.hexdigest()) self.aes = AES.new(key.hexdigest(), AES.MODE_ECB) @@ -32,7 +32,7 @@ class RequestHandler: func = getattr(self.core, obj.function) obj.response = func(*obj.args) else: - obj.response = "antwort" + obj.response = "error happend" return self.encrypt(obj) diff --git a/module/remote/SocketServer.py b/module/remote/SocketServer.py index 9000c1c71..5bd6ba3d0 100644 --- a/module/remote/SocketServer.py +++ b/module/remote/SocketServer.py @@ -52,6 +52,7 @@ class SecondaryServerSocket(asynchat.async_chat): def collect_incoming_data(self, data): self.data += data def found_terminator(self): + print "data arrived" rep = self.handler.proceed(self.data) self.push(rep) self.data = "" |