Include SKS in server
This commit is contained in:
parent
f09cb30772
commit
feac1be289
|
@ -1,4 +1,15 @@
|
||||||
import datetime, encodings.idna, os, porttools, servertools.dbconn, setuptools, socket, socketserver, ssltools, sys, syslog, threading
|
import datetime
|
||||||
|
import encodings.idna
|
||||||
|
import os
|
||||||
|
import porttools
|
||||||
|
import setuptools
|
||||||
|
import skstools
|
||||||
|
import socket
|
||||||
|
import socketserver
|
||||||
|
import ssltools
|
||||||
|
import sys
|
||||||
|
import syslog
|
||||||
|
import threading
|
||||||
|
|
||||||
SYSLOG = 0
|
SYSLOG = 0
|
||||||
STDOUT = 1
|
STDOUT = 1
|
||||||
|
@ -7,6 +18,7 @@ SILENT = 9 # Quiet mode
|
||||||
|
|
||||||
SSL = 0
|
SSL = 0
|
||||||
PORT = 1
|
PORT = 1
|
||||||
|
SKS = 2
|
||||||
|
|
||||||
logging = STDOUT
|
logging = STDOUT
|
||||||
|
|
||||||
|
@ -35,7 +47,7 @@ def logger(message, prio=syslog.LOG_INFO, sink=logging):
|
||||||
|
|
||||||
def listIncluded(host, section):
|
def listIncluded(host, section):
|
||||||
if not setuptools.getListSetting("Server", "ignorelist"):
|
if not setuptools.getListSetting("Server", "ignorelist"):
|
||||||
for i in setuptools.getListSetting("SSL" if section == SSL else "Ports", "hosts"):
|
for i in setuptools.getListSetting("SSL" if section == SSL else "Ports" if section == PORT else "SKS", "hosts"):
|
||||||
if encodings.idna.ToASCII(i[0].lower()).decode("UTF-8") == encodings.idna.ToASCII(host.lower()).decode("UTF-8"):
|
if encodings.idna.ToASCII(i[0].lower()).decode("UTF-8") == encodings.idna.ToASCII(host.lower()).decode("UTF-8"):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -60,10 +72,13 @@ class TCPHandler(socketserver.StreamRequestHandler):
|
||||||
return "HI: Kumi Status v0.8.15 (KSP) at %s" % setuptools.getSetting("Server", "host") or socket.gethostname()
|
return "HI: Kumi Status v0.8.15 (KSP) at %s" % setuptools.getSetting("Server", "host") or socket.gethostname()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
elif command in ("heartbeat", "hb", "ping"):
|
elif command in ("heartbeat", "hb", "ping"):
|
||||||
return "OK: Still here? Wow."
|
return "OK: Still here? Wow."
|
||||||
|
|
||||||
elif command in ("stat", "status"):
|
elif command in ("stat", "status"):
|
||||||
return "UA: Not currently implemented."
|
return "UA: Not currently implemented."
|
||||||
|
|
||||||
elif command in ("ssl", "tls"):
|
elif command in ("ssl", "tls"):
|
||||||
try:
|
try:
|
||||||
host = encodings.idna.ToASCII(str(content[1])).decode("UTF-8")
|
host = encodings.idna.ToASCII(str(content[1])).decode("UTF-8")
|
||||||
|
@ -89,6 +104,7 @@ class TCPHandler(socketserver.StreamRequestHandler):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
return "ER: Could not verify SSL certificate on %s:%i. Is the server down?" % (content[1], int(content[2]))
|
return "ER: Could not verify SSL certificate on %s:%i. Is the server down?" % (content[1], int(content[2]))
|
||||||
|
|
||||||
elif command == "port":
|
elif command == "port":
|
||||||
host = encodings.idna.ToASCII(str(content[1])).decode("UTF-8")
|
host = encodings.idna.ToASCII(str(content[1])).decode("UTF-8")
|
||||||
port = int(content[2])
|
port = int(content[2])
|
||||||
|
@ -99,12 +115,26 @@ class TCPHandler(socketserver.StreamRequestHandler):
|
||||||
return "ER: Port %i is not open on %s." % (port, content[1])
|
return "ER: Port %i is not open on %s." % (port, content[1])
|
||||||
else:
|
else:
|
||||||
return "NM: %s is not being monitored!" % content[1]
|
return "NM: %s is not being monitored!" % content[1]
|
||||||
|
|
||||||
|
elif command in ("sks", "keyserver"):
|
||||||
|
host = encodings.idna.ToASCII(str(content[1])).decode("UTF-8")
|
||||||
|
if listIncluded(host, SKS):
|
||||||
|
if skstools.getStatus(host):
|
||||||
|
return "OK: SKS is running on %s and included in the pools." % content[1]
|
||||||
|
else:
|
||||||
|
return "ER: The SKS keyserver at %s is not included in the pools." % content[1]
|
||||||
|
else:
|
||||||
|
return "NM: %s is not being monitored!" % content[1]
|
||||||
|
|
||||||
elif command in ("req", "request"):
|
elif command in ("req", "request"):
|
||||||
return "NI: Requesting monitoring is not yet implemented."
|
return "NI: Requesting monitoring is not yet implemented."
|
||||||
|
|
||||||
elif command == "help":
|
elif command == "help":
|
||||||
return "UA: Not currently implemented."
|
return "UA: Not currently implemented."
|
||||||
|
|
||||||
else:
|
else:
|
||||||
return "IM: Unknown command %s." % command
|
return "IM: Unknown command %s." % command
|
||||||
|
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
return "IM: Invalid values passed to %s. Try HELP %s." % (command, command)
|
return "IM: Invalid values passed to %s. Try HELP %s." % (command, command)
|
||||||
except IndexError as e:
|
except IndexError as e:
|
||||||
|
|
Loading…
Reference in a new issue