summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-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)bin3510 -> 3510 bytes
-rw-r--r--examples/networks.xml (renamed from networks.xml)0
-rw-r--r--pywhoisd.conf4
-rwxr-xr-xpywhoisd.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
diff --git a/whoiscore.py b/core.py
index 6053508..5ff69bc 100644
--- a/whoiscore.py
+++ b/core.py
@@ -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/whoisdata.py b/data.py
index 200d3ba..200d3ba 100644
--- a/whoisdata.py
+++ b/data.py
diff --git a/pywhoisd.dia b/doc/pywhoisd.dia
index d108724..d108724 100644
--- a/pywhoisd.dia
+++ b/doc/pywhoisd.dia
Binary files differ
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
diff --git a/main.py b/pywhoisd.py
index 9205304..7832cae 100755
--- a/main.py
+++ b/pywhoisd.py
@@ -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):
nihil fit ex nihilo