summaryrefslogtreecommitdiff
path: root/core.py
diff options
context:
space:
mode:
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