summaryrefslogtreecommitdiff
path: root/core.py
diff options
context:
space:
mode:
authorRaúl Benencia <rbenencia@linti.unlp.edu.ar>2012-08-02 18:06:23 -0300
committerRaúl Benencia <rbenencia@linti.unlp.edu.ar>2012-08-02 18:06:23 -0300
commit4d30bf280dbdb68ad72e01e911bf039b48ccb869 (patch)
treee885129fdfecb1327fb50e13ac24d3cca208cbb5 /core.py
parent10e9272d170f5c634e8ca8f7415fb4ad1454bfe6 (diff)
Completed XML parsing
Diffstat (limited to 'core.py')
-rw-r--r--core.py20
1 files changed, 13 insertions, 7 deletions
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)
nihil fit ex nihilo