summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-31 21:06:18 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-05-31 21:06:18 +0200
commit3755da2af7e3f79171d505dd81e0c0b63b4adb9f (patch)
treeb2267b76fe897c3c27ce6ed2a019de08c1394647 /module
parentxupi.in works again (diff)
downloadpyload-3755da2af7e3f79171d505dd81e0c0b63b4adb9f.tar.xz
gui socket finally works
Diffstat (limited to 'module')
-rw-r--r--module/remote/ClientHandler.py7
-rw-r--r--module/remote/ClientSocket.py36
-rw-r--r--module/remote/SocketServer.py3
3 files changed, 29 insertions, 17 deletions
diff --git a/module/remote/ClientHandler.py b/module/remote/ClientHandler.py
index 0037a874e..6f60d5176 100644
--- a/module/remote/ClientHandler.py
+++ b/module/remote/ClientHandler.py
@@ -12,11 +12,12 @@ from Crypto.Cipher import Blowfish
from RequestHandler import RequestHandler
class ClientHandler(RequestHandler):
- def __init__(self, client):
+ def __init__(self, client, pw):
self.client = client
- key = hashlib.sha256("pwhere")
+ key = hashlib.sha256(pw)
self.bf = Blowfish.new(key.hexdigest(), Blowfish.MODE_ECB)
def proceed(self, data):
obj = self.decrypt(data)
- return self.encrypt(obj) \ No newline at end of file
+ #evaluate object
+ return self.encrypt(obj)
diff --git a/module/remote/ClientSocket.py b/module/remote/ClientSocket.py
index 30eaf20e0..9c52681c7 100644
--- a/module/remote/ClientSocket.py
+++ b/module/remote/ClientSocket.py
@@ -8,31 +8,41 @@ socket for connecting to the core's server
"""
import asynchat
import socket
+import asyncore
+import threading
+import time
from ClientHandler import ClientHandler
+class SocketThread(threading.Thread):
+ def __init__(self, adress, port, pw, client):
+ threading.Thread.__init__(self)
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ sock.connect((adress, port))
+ self.socket = ClientSocket(sock, pw, client)
+ self.start()
+ def run(self):
+ asyncore.loop()
+ print "loop closed"
+
+
class ClientSocket(asynchat.async_chat):
- def __init__(self, client):
- asynchat.async_chat.__init__(self)
- self.client = client
+ def __init__(self, sock, pw, client):
+ asynchat.async_chat.__init__(self, conn=sock)
self.data = ""
- self.handler = ClientHandler(None)
+ self.handler = ClientHandler(client, pw)
self.set_terminator("\n")
- self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
-
- def handle_connect(self):
- print "connected"
+ #self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
def handle_close(self):
print "Disconnected from", self.getpeername()
self.close()
def collect_incoming_data(self, data):
- print "data arrived"
self.data += data
def found_terminator(self):
- obj = self.handler.proceed(data)
- self.push(obj)
- print "pushed"
- data = ""
+ obj = self.handler.proceed(self.data)
+ #self.push(obj+"\n")
+ print "data arrived"
+ self.data = ""
diff --git a/module/remote/SocketServer.py b/module/remote/SocketServer.py
index 817e956aa..e1b41dd1d 100644
--- a/module/remote/SocketServer.py
+++ b/module/remote/SocketServer.py
@@ -35,6 +35,7 @@ class MainServerSocket(asyncore.dispatcher):
def handle_accept(self):
newSocket, address = self.accept()
print "Connected from", address
+ print newSocket
SecondaryServerSocket(newSocket, self.pycore)
def handle_close(self):
print "going to close"
@@ -54,7 +55,7 @@ class SecondaryServerSocket(asynchat.async_chat):
def found_terminator(self):
rep = self.handler.proceed(self.data)
self.sendall(rep+"\n")
- print "push"
+ print "data arrived"
self.data = ""
#having fun with the data
def handle_close(self):