diff options
author | Raúl Benencia <rbenencia@linti.unlp.edu.ar> | 2012-08-01 18:05:04 -0300 |
---|---|---|
committer | Raúl Benencia <rbenencia@linti.unlp.edu.ar> | 2012-08-01 18:05:04 -0300 |
commit | 01aa58c5d7947e37bc3f0a927c2ed809873122a3 (patch) | |
tree | 31eb413ef072c5bc56da31b5820bb2be960d3726 | |
parent | 9eaa4fb13a8f761e4be0abec042501d600b4de10 (diff) |
New scheme. Starting port to python 3. It's now or never!
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | core.py (renamed from whoiscore.py) | 13 | ||||
-rw-r--r-- | data.py (renamed from whoisdata.py) | 0 | ||||
-rw-r--r-- | doc/pywhoisd.dia (renamed from pywhoisd.dia) | bin | 3510 -> 3510 bytes | |||
-rw-r--r-- | examples/networks.xml (renamed from networks.xml) | 0 | ||||
-rw-r--r-- | pywhoisd.conf | 4 | ||||
-rwxr-xr-x | pywhoisd.py (renamed from main.py) | 14 |
7 files changed, 18 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72723e5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*pyc @@ -1,4 +1,5 @@ from ipcalc import IP, Network +import socketserver class WhoisDaemon(): def __init__(data): @@ -29,10 +30,10 @@ class WhoisDaemon(): result['error'] = "Red no encontrada" return result - def search_domain: + def search_domain(self): pass -class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): +class ThreadedTCPRequestHandler(socketserver.BaseRequestHandler): def handle(self): data = self.request.recv(100) @@ -40,17 +41,17 @@ class ThreadedTCPRequestHandler(SocketServer.BaseRequestHandler): response = self.get_header() + "\n" + self.get_answer(data) + "\n" + self.get_footer() self.request.sendall(response) -class WhoisServer(TCPServer): +class WhoisServer(socketserver.TCPServer): def __init__(self, config): host = config.get('Servers', 'classic_host') port = config.get('Servers', 'classic_port') - TCPServer.__init__(self, (host, port), ThreadedTCPRequestHandler): + TCPServer.__init__(self, (host, port), ThreadedTCPRequestHandler) def start(self): - + pass -class WhoisWebServer(TCPServer): +class WhoisWebServer(socketserver.TCPServer): def __init__(self, config): self.host = config.get('Servers', 'web_host') self.port = config.get('Servers', 'web_host') diff --git a/pywhoisd.dia b/doc/pywhoisd.dia Binary files differindex d108724..d108724 100644 --- a/pywhoisd.dia +++ b/doc/pywhoisd.dia diff --git a/networks.xml b/examples/networks.xml index 641071d..641071d 100644 --- a/networks.xml +++ b/examples/networks.xml diff --git a/pywhoisd.conf b/pywhoisd.conf index 346ddc4..b7d0662 100644 --- a/pywhoisd.conf +++ b/pywhoisd.conf @@ -5,8 +5,8 @@ classic = yes # Only makes sense when classic server is enabled -web_host = localhost -web_port = 4343 +classic_host = localhost +classic_port = 4343 # Run a web whois server? web = yes @@ -1,10 +1,12 @@ -#!/usr/bin/python -import ConfigParser +#!/usr/bin/python3 +import configparser import whoiscore class PyWhoisD(): + """Main class. It reads the configuration options and starts the server""" + def __init__(self): - self.config = ConfigParser.RawConfigParser() + self.config = configparser.ConfigParser() self.config.read('pywhoisd.conf') self.data = None @@ -12,7 +14,7 @@ class PyWhoisD(): # What kind of storage are we using? def config_data(self): - mode = self.config.get('Storage', 'mode') + mode = self.config['Storage']['mode'] if mode == 'xml': self.data = WhoisData.WhoisDataXML(self.config) @@ -27,10 +29,10 @@ class PyWhoisD(): # Returns true if web server is enabled def classicserver(self): - self.config.get('Servers', 'classic') == 'yes': + self.config.get('Servers', 'classic') == 'yes' def config_servers(self): - if self.classicserver() + if self.classicserver(): self.classic_server = whoiscore.WhoisServer(self.config, self.daemon) if self.webserver(self): |