From de00497b4098fece043a1550a94e112829bcbceb Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Wed, 20 Jun 2012 10:59:38 +1200 Subject: [PATCH] Re-enable SSL service. --- libpathod/pathod.py | 9 ++++++++- libpathod/test.py | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/libpathod/pathod.py b/libpathod/pathod.py index 9fabc026e..8a29b9cb3 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -5,6 +5,12 @@ import version, app, rparse class PathodHandler(tcp.BaseHandler): def handle(self): + if self.server.ssloptions: + self.convert_to_ssl( + self.server.ssloptions["certfile"], + self.server.ssloptions["keyfile"], + ) + line = self.rfile.readline() if line == "\r\n" or line == "\n": # Possible leftover from previous message line = self.rfile.readline() @@ -42,8 +48,9 @@ class PathodHandler(tcp.BaseHandler): class Pathod(tcp.TCPServer): - def __init__(self, addr, prefix="/p/"): + def __init__(self, addr, ssloptions=None, prefix="/p/"): tcp.TCPServer.__init__(self, addr) + self.ssloptions = ssloptions self.prefix = prefix self.app = app.app self.app.config["pathod"] = self diff --git a/libpathod/test.py b/libpathod/test.py index f33e922fa..5fba17d53 100644 --- a/libpathod/test.py +++ b/libpathod/test.py @@ -36,7 +36,7 @@ class PaThread(threading.Thread): ) else: ssloptions = self.ssl - self.server = pathod.Pathod((IFACE, 0)) + self.server = pathod.Pathod((IFACE, 0), ssloptions=ssloptions) #self.server, self.port = pathod.make_server(self.app, 0, IFACE, ssloptions) self.q.put(self.server.port) self.server.serve_forever()