Header for whoisd, commented some lines with %
This commit is contained in:
parent
6878cfebde
commit
98735fe4a9
15
bin/whoisd
15
bin/whoisd
|
@ -20,8 +20,15 @@ log = logging.getLogger("whoisd")
|
||||||
__VERSION__ = '0.1'
|
__VERSION__ = '0.1'
|
||||||
|
|
||||||
class WhoisHandler(socketserver.BaseRequestHandler):
|
class WhoisHandler(socketserver.BaseRequestHandler):
|
||||||
|
header = "% This is the DARKNET database query service.\n" \
|
||||||
|
"% The objects should be in something like RPLS format.\n" \
|
||||||
|
"%\n" \
|
||||||
|
"% The DARKNET database is subject to terms and conditions.\n" \
|
||||||
|
"% Mostly these are \"be nice\" and \"don't knowingly break things\".\n" \
|
||||||
|
"\n"
|
||||||
|
|
||||||
def handle(self):
|
def handle(self):
|
||||||
self.request.sendall(b"Welcome!\n\n")
|
self.request.sendall(self.header.encode())
|
||||||
line = self.request.recv(1024)
|
line = self.request.recv(1024)
|
||||||
line = line.split(b"\n", 2)[0].strip()
|
line = line.split(b"\n", 2)[0].strip()
|
||||||
print("Request object is %s" % line)
|
print("Request object is %s" % line)
|
||||||
|
@ -30,16 +37,16 @@ class WhoisHandler(socketserver.BaseRequestHandler):
|
||||||
|
|
||||||
objs = findInDatabase(line.decode())
|
objs = findInDatabase(line.decode())
|
||||||
if len(objs) > 0:
|
if len(objs) > 0:
|
||||||
self.request.sendall(("%d result%s\n" % (len(objs), "" if len(objs)==1 else "s")).encode())
|
self.request.sendall(("%% %d result%s\n" % (len(objs), "" if len(objs)==1 else "s")).encode())
|
||||||
for obj in objs:
|
for obj in objs:
|
||||||
self.sendObject(obj)
|
self.sendObject(obj)
|
||||||
else:
|
else:
|
||||||
self.request.sendall(b"NOT FOUND\n\n")
|
self.request.sendall(b"%% NOT FOUND\n\n")
|
||||||
|
|
||||||
def sendObject(self, obj):
|
def sendObject(self, obj):
|
||||||
result = [
|
result = [
|
||||||
"",
|
"",
|
||||||
"Object %s (%s)" % (obj, obj.getClassName()),
|
"%% Object %s (%s)" % (obj, obj.getClassName()),
|
||||||
""
|
""
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue