From 1b1b97d87499926e3100c53e500ac94fe796003c Mon Sep 17 00:00:00 2001 From: Eduardo Silva Date: Thu, 15 Feb 2024 12:48:40 -0300 Subject: [PATCH] better placeholder for status page --- templates/wireguard/wireguard_status.html | 25 ++++++++++++++++++++++- wireguard/views.py | 10 ++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/templates/wireguard/wireguard_status.html b/templates/wireguard/wireguard_status.html index d141e4a..c16f912 100644 --- a/templates/wireguard/wireguard_status.html +++ b/templates/wireguard/wireguard_status.html @@ -1,5 +1,28 @@ {% extends "base.html" %} {% block content %} -this page is just a placeholder for the moment + +
+
+
+
+

WireGuard Status

+
+
+
+
+
{{command_output}}
+ +
+
+ +
+
+ +
+
+

+ This is just a placeholder for the WireGuard status page. It will be updated with more information in the near future. +

+ {% endblock %} diff --git a/wireguard/views.py b/wireguard/views.py index fadec58..79964b9 100644 --- a/wireguard/views.py +++ b/wireguard/views.py @@ -75,7 +75,15 @@ def view_welcome(request): @login_required def view_wireguard_status(request): page_title = 'WireGuard Status' - context = {'page_title': page_title} + bash_command = ['bash', '-c', 'wg show'] + try: + command_output = subprocess.check_output(bash_command, stderr=subprocess.STDOUT).decode('utf-8') + command_success = True + except subprocess.CalledProcessError as e: + command_output = e.output.decode('utf-8') + command_success = False + + context = {'page_title': page_title, 'command_output': command_output, 'command_success': command_success} return render(request, 'wireguard/wireguard_status.html', context)