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
|
||||
id: sh.wallace.matrix.shameotron
|
||||
version: 0.0.6
|
||||
version: 0.0.7
|
||||
license: MIT
|
||||
modules:
|
||||
- shameotron
|
||||
|
|
|
@ -125,8 +125,12 @@ class ShameOTron(Plugin):
|
|||
try:
|
||||
addr = list(data['ConnectionReports'].keys())[0]
|
||||
ssl_expiry = await self.get_ssl_expiry(addr)
|
||||
except ssl.SSLCertVerificationError:
|
||||
except (
|
||||
ssl.SSLCertVerificationError,
|
||||
IndexError
|
||||
):
|
||||
ssl_expiry = None
|
||||
|
||||
try:
|
||||
if not version:
|
||||
version = data['Version']['version']
|
||||
|
@ -174,8 +178,11 @@ class ShameOTron(Plugin):
|
|||
|
||||
warning = ''
|
||||
now = int(datetime.now().timestamp())
|
||||
expiry = int(data['ssl_expiry'].timestamp()) if data['ssl_expiry'] else now
|
||||
warning = '(cert expiry warning!)' if now > (expiry - (30 * 86400)) else ''
|
||||
if data['ssl_expiry']:
|
||||
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(
|
||||
(host, f"{data['version']} {warning}")
|
||||
|
|
Loading…
Reference in a new issue