From ee634c4b50f8032290bc35e26655234b80006667 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 15 Mar 2021 10:11:36 +0000 Subject: [PATCH 1/5] Initial commit: ajax fetch wg client.conf --- ajax/networking/get_wgcfg.php | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 ajax/networking/get_wgcfg.php diff --git a/ajax/networking/get_wgcfg.php b/ajax/networking/get_wgcfg.php new file mode 100644 index 00000000..6a9d771d --- /dev/null +++ b/ajax/networking/get_wgcfg.php @@ -0,0 +1,9 @@ + Date: Mon, 15 Mar 2021 10:12:18 +0000 Subject: [PATCH 2/5] Add handler for wg client.conf download --- app/js/custom.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/js/custom.js b/app/js/custom.js index b2214c9c..72f363de 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -361,6 +361,26 @@ $('.wg-keygen').click(function(){ }) }) +// Handler for wireguard client.conf download +$('.wg-client-dl').click(function(){ + var req = new XMLHttpRequest(); + var url = 'ajax/networking/get_wgcfg.php'; + req.open('get', url, true); + req.responseType = 'blob'; + req.setRequestHeader('Content-type', 'text/plain; charset=UTF-8'); + console.log(req); + req.onreadystatechange = function (event) { + if(req.readyState == 4 && req.status == 200) { + var blob = req.response; + var link=document.createElement('a'); + link.href=window.URL.createObjectURL(blob); + link.download = 'client.conf'; + link.click(); + } + } + req.send(); +}) + // Event listener for Bootstrap's form validation window.addEventListener('load', function() { // Fetch all the forms we want to apply custom Bootstrap validation styles to From a89140435b570449ddec99c181a076773ec2aab4 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 15 Mar 2021 10:30:36 +0000 Subject: [PATCH 3/5] Update peer template w/ download button --- templates/wg/peers.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/templates/wg/peers.php b/templates/wg/peers.php index 319cc0f9..d4347575 100644 --- a/templates/wg/peers.php +++ b/templates/wg/peers.php @@ -36,7 +36,7 @@
-
+
@@ -65,10 +65,14 @@
-
+
RaspAP Wifi QR code -
+
+ + client.conf file to your device."); ?> +
+
From 319f917071ffb05fe2dd0f8d785fafc2ff6a942c Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 15 Mar 2021 10:31:17 +0000 Subject: [PATCH 4/5] Update w/ wg download msgs --- locale/en_US/LC_MESSAGES/messages.po | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/locale/en_US/LC_MESSAGES/messages.po b/locale/en_US/LC_MESSAGES/messages.po index dcd00a5c..74627378 100644 --- a/locale/en_US/LC_MESSAGES/messages.po +++ b/locale/en_US/LC_MESSAGES/messages.po @@ -909,6 +909,12 @@ msgstr "Enable this option to display an updated WireGuard status." msgid "Scan this QR code with your client to connect to this tunnel" msgstr "Scan this QR code with your client to connect to this tunnel" +msgid "or download the client.conf file to your device." +msgstr "or download the client.conf file to your device." + +msgid "Download" +msgstr "Download" + msgid "Start WireGuard" msgstr "Start WireGuard" From c7c8eacb0ceea8a64894897b5d3c58a93e511fc7 Mon Sep 17 00:00:00 2001 From: billz Date: Mon, 15 Mar 2021 10:38:14 +0000 Subject: [PATCH 5/5] Minor: remove debug output --- app/js/custom.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app/js/custom.js b/app/js/custom.js index 72f363de..d5047558 100644 --- a/app/js/custom.js +++ b/app/js/custom.js @@ -368,7 +368,6 @@ $('.wg-client-dl').click(function(){ req.open('get', url, true); req.responseType = 'blob'; req.setRequestHeader('Content-type', 'text/plain; charset=UTF-8'); - console.log(req); req.onreadystatechange = function (event) { if(req.readyState == 4 && req.status == 200) { var blob = req.response;