From 809a4f9d04f34af67ab686ed08c922bd098c6683 Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Fri, 13 Sep 2024 10:44:52 +1000 Subject: [PATCH] feat: Change node border colours for warnings and errors --- server.py | 10 ++++++++++ templates/assets/css/index.css | 8 +++++++- templates/index.html | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 59abcdc..04423dd 100644 --- a/server.py +++ b/server.py @@ -749,28 +749,36 @@ def index(): alerts = [] warnings = [] for node in node_status: + node["class"] = "normal" if not node["plain_dns"]: + node["class"] = "error" alerts.append(f"{node['name']} does not support plain DNS") if not node["doh"]: + node["class"] = "error" alerts.append(f"{node['name']} does not support DoH") if not node["dot"]: + node["class"] = "error" alerts.append(f"{node['name']} does not support DoT") if not node["cert"]["valid"]: + node["class"] = "error" alerts.append(f"{node['name']} has an invalid certificate") if not node["cert_853"]["valid"]: + node["class"] = "error" alerts.append(f"{node['name']} has an invalid certificate on port 853") cert_expiry = datetime.strptime( node["cert"]["expiry_date"], "%b %d %H:%M:%S %Y GMT" ) if cert_expiry < datetime.now(): + node["class"] = "error" alerts.append(f"The {node['name']} node's certificate has expired") continue elif cert_expiry < datetime.now() + relativedelta.relativedelta(days=7): + node["class"] = "warning" warnings.append( f"The {node['name']} node's certificate is expiring {format_relative_time(cert_expiry)}" ) @@ -779,11 +787,13 @@ def index(): node["cert_853"]["expiry_date"], "%b %d %H:%M:%S %Y GMT" ) if cert_853_expiry < datetime.now(): + node["class"] = "error" alerts.append( f"The {node['name']} node's certificate has expired for DNS over TLS (port 853)" ) continue elif cert_853_expiry < datetime.now() + relativedelta.relativedelta(days=7): + node["class"] = "warning" warnings.append( f"The {node['name']} node's certificate is expiring {format_relative_time(cert_853_expiry)} for DNS over TLS (port 853)" ) diff --git a/templates/assets/css/index.css b/templates/assets/css/index.css index 41bd3c3..6203a8e 100644 --- a/templates/assets/css/index.css +++ b/templates/assets/css/index.css @@ -21,4 +21,10 @@ } .node-info > p{ margin: 0; -} \ No newline at end of file +} +.node.warning { + border-color: #FFA500; +} +.node.error { + border-color: #FF0000; +} diff --git a/templates/index.html b/templates/index.html index f97aa32..0a1aadc 100644 --- a/templates/index.html +++ b/templates/index.html @@ -97,7 +97,7 @@
{% for node in nodes %} -
+

{{node.location}}