Add support for punycode, some bug fixing
This commit is contained in:
parent
4ac190ef23
commit
c958d290d2
|
@ -1,4 +1,4 @@
|
||||||
import datetime, os, setuptools, socketserver, ssltools, sys, syslog, threading
|
import datetime, encodings, os, setuptools, socketserver, ssltools, sys, syslog, threading
|
||||||
|
|
||||||
SYSLOG = 0
|
SYSLOG = 0
|
||||||
STDOUT = 1
|
STDOUT = 1
|
||||||
|
@ -8,7 +8,12 @@ SILENT = 9 # Quiet mode
|
||||||
SSL = 0
|
SSL = 0
|
||||||
PORT = 1
|
PORT = 1
|
||||||
|
|
||||||
exec("logging = %s or STDOUT" % setuptools.getSetting("Log", "sink"))
|
logging = STDOUT
|
||||||
|
|
||||||
|
try:
|
||||||
|
exec("logging = " + setuptools.getSetting("Log", "sink"))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def logger(message, prio=syslog.LOG_INFO, sink=logging):
|
def logger(message, prio=syslog.LOG_INFO, sink=logging):
|
||||||
if sink in (STDOUT, STDDEB):
|
if sink in (STDOUT, STDDEB):
|
||||||
|
@ -56,11 +61,13 @@ class TCPHandler(socketserver.StreamRequestHandler):
|
||||||
return "UA: Not currently implemented."
|
return "UA: Not currently implemented."
|
||||||
elif command in ("ssl", "tls"):
|
elif command in ("ssl", "tls"):
|
||||||
try:
|
try:
|
||||||
if listIncluded(str(content[1]), SSL):
|
host = encodings.idna.ToASCII(str(content[1]))
|
||||||
try:
|
try:
|
||||||
expiry = ssltools.getRemoteExpiry(str(content[1]), int(content[2]))
|
port = int(content[2])
|
||||||
except:
|
except IndexError:
|
||||||
expiry = ssltools.getRemoteExpiry(str(content[1]), 443)
|
port = 443
|
||||||
|
if listIncluded(host, SSL):
|
||||||
|
expiry = ssltools.getRemoteExpiry(host, port)
|
||||||
if expiry > datetime.datetime.now():
|
if expiry > datetime.datetime.now():
|
||||||
dm = "%s certificate is valid until: %s" % (content[1], expiry)
|
dm = "%s certificate is valid until: %s" % (content[1], expiry)
|
||||||
try:
|
try:
|
||||||
|
@ -71,13 +78,11 @@ class TCPHandler(socketserver.StreamRequestHandler):
|
||||||
return "AL: %s" % dm
|
return "AL: %s" % dm
|
||||||
return "OK: %s" % dm
|
return "OK: %s" % dm
|
||||||
else:
|
else:
|
||||||
return "AL: %s certificate has expired! Please renew ASAP! - %s" % (content[1], expiry)
|
return "AL: %s certificate has expired on: %s" % (content[1], expiry)
|
||||||
else:
|
else:
|
||||||
return "NM: %s is not being monitored!" % content[1]
|
return "NM: %s is not being monitored!" % content[1]
|
||||||
except TypeError:
|
|
||||||
raise
|
|
||||||
except:
|
except:
|
||||||
return "ER: Could not verify SSL certificate on %s:%i. Is the server down?" % (content[1], 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":
|
||||||
return "UA: Not currently implemented."
|
return "UA: Not currently implemented."
|
||||||
elif command in ("req", "request"):
|
elif command in ("req", "request"):
|
||||||
|
@ -86,9 +91,9 @@ class TCPHandler(socketserver.StreamRequestHandler):
|
||||||
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:
|
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:
|
except IndexError 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)
|
||||||
|
|
||||||
def handle(self):
|
def handle(self):
|
||||||
|
|
Loading…
Reference in a new issue