Fix an issue when a server is offline
This commit is contained in:
parent
3bf01ec623
commit
c3228c67db
|
@ -1,6 +1,6 @@
|
||||||
maubot: 0.1.0
|
maubot: 0.1.0
|
||||||
id: sh.wallace.matrix.shameotron
|
id: sh.wallace.matrix.shameotron
|
||||||
version: 0.0.6
|
version: 0.0.7
|
||||||
license: MIT
|
license: MIT
|
||||||
modules:
|
modules:
|
||||||
- shameotron
|
- shameotron
|
||||||
|
|
|
@ -125,8 +125,12 @@ class ShameOTron(Plugin):
|
||||||
try:
|
try:
|
||||||
addr = list(data['ConnectionReports'].keys())[0]
|
addr = list(data['ConnectionReports'].keys())[0]
|
||||||
ssl_expiry = await self.get_ssl_expiry(addr)
|
ssl_expiry = await self.get_ssl_expiry(addr)
|
||||||
except ssl.SSLCertVerificationError:
|
except (
|
||||||
|
ssl.SSLCertVerificationError,
|
||||||
|
IndexError
|
||||||
|
):
|
||||||
ssl_expiry = None
|
ssl_expiry = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not version:
|
if not version:
|
||||||
version = data['Version']['version']
|
version = data['Version']['version']
|
||||||
|
@ -174,8 +178,11 @@ class ShameOTron(Plugin):
|
||||||
|
|
||||||
warning = ''
|
warning = ''
|
||||||
now = int(datetime.now().timestamp())
|
now = int(datetime.now().timestamp())
|
||||||
expiry = int(data['ssl_expiry'].timestamp()) if data['ssl_expiry'] else now
|
if data['ssl_expiry']:
|
||||||
warning = '(cert expiry warning!)' if now > (expiry - (30 * 86400)) else ''
|
expiry = int(data['ssl_expiry'].timestamp())
|
||||||
|
self.log.debug("%s: %s, %s", host, now, expiry)
|
||||||
|
if now > (expiry - (30 * 86400)):
|
||||||
|
warning = '(cert expiry warning!)'
|
||||||
|
|
||||||
versions.append(
|
versions.append(
|
||||||
(host, f"{data['version']} {warning}")
|
(host, f"{data['version']} {warning}")
|
||||||
|
|
Loading…
Reference in a new issue