From 419559a86f4ab6ad59ce50b3e1d7f9d939013584 Mon Sep 17 00:00:00 2001
From: Sunil Mohan Adapa
Date: Fri, 17 Jan 2020 18:52:33 -0800
Subject: [PATCH] wireguard: Show public key even when connection is not active
When wireguard interface is not active 'wg show' does not provide any
information. In such case, get the public key by computing it from private key
by calling 'wg pubkey'.
Signed-off-by: Sunil Mohan Adapa
Reviewed-by: James Valleroy
---
.../modules/wireguard/templates/wireguard.html | 6 +++++-
plinth/modules/wireguard/utils.py | 17 ++++++++++++++++-
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/plinth/modules/wireguard/templates/wireguard.html b/plinth/modules/wireguard/templates/wireguard.html
index c684a6101..8006611c8 100644
--- a/plinth/modules/wireguard/templates/wireguard.html
+++ b/plinth/modules/wireguard/templates/wireguard.html
@@ -62,7 +62,11 @@
{% blocktrans %}
Public key for this {{ box_name }}:
{% endblocktrans %}
- {{ server.public_key }}
+ {% if server.public_key %}
+ {{ server.public_key }}
+ {% else %}
+ {% trans "Not configured yet." %}
+ {% endif %}