From 4d30bf280dbdb68ad72e01e911bf039b48ccb869 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Benencia?= Date: Thu, 2 Aug 2012 18:06:23 -0300 Subject: Completed XML parsing --- core.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'core.py') diff --git a/core.py b/core.py index 98284e1..a68d1e5 100644 --- a/core.py +++ b/core.py @@ -55,25 +55,31 @@ class Daemon(): def show_help(): pass -class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler): +class WhoisHandler(socketserver.BaseRequestHandler): def handle(self): + daemon = self.server.daemon data = self.request.recv(100) cur_thread = threading.current_thread() - response = self.get_header() + "\n" + self.get_answer(data) + "\n" + self.get_footer() + response = daemon.get_header() + "\n" + daemon.query(data) + "\n" + daemon.get_footer() + self.request.sendall(response) -class ClassicServer(socketserver.TCPServer): - def __init__(self, config): +class ClassicServer(socketserver.ThreadingTCPServer): + def __init__(self, config, daemon): host = config['Servers']['classic_host'] port = config['Servers']['classic_port'] + self.daemon = daemon - TCPServer.__init__(self, (host, port), ThreadedTCPRequestHandler) + ThreadingTCPServer.__init__(self, (host, port), WhoisHandler) def start(self): pass -class WebServer(socketserver.TCPServer): - def __init__(self, config): +class WebServer(socketserver.ThreadingTCPServer): + def __init__(self, config, daemon): self.host = config['Servers']['web_host'] self.port = config['Servers']['web_port'] + self.daemon = daemon + + ThreadingTCPServer.__init__(self, (host, port), WhoisHandler) -- cgit v1.2.3