mirror of
https://github.com/billz/raspap-webgui.git
synced 2023-10-10 13:37:24 +02:00
Merge pull request #15 from RaspAP/feature/wg-download-client
Feature/wg download client
This commit is contained in:
commit
4bdd9e1065
9
ajax/networking/get_wgcfg.php
Normal file
9
ajax/networking/get_wgcfg.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
require '../../includes/csrf.php';
|
||||
require_once '../../includes/config.php';
|
||||
|
||||
// fetch wg client.conf
|
||||
exec('sudo cat '. RASPI_WIREGUARD_PATH.'client.conf', $return);
|
||||
echo implode(PHP_EOL,$return);
|
||||
|
@ -361,6 +361,25 @@ $('.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');
|
||||
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
|
||||
|
@ -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 <code>client.conf</code> file to your device."
|
||||
msgstr "or download the <code>client.conf</code> file to your device."
|
||||
|
||||
msgid "Download"
|
||||
msgstr "Download"
|
||||
|
||||
msgid "Start WireGuard"
|
||||
msgstr "Start WireGuard"
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-xs-3 col-sm-6">
|
||||
<label for="code"><?php echo _("IP Address"); ?></label>
|
||||
<input type="text" class="form-control" name="wg_pipaddress" value="<?php echo htmlspecialchars($wg_pipaddress, ENT_QUOTES); ?>" />
|
||||
</div>
|
||||
@ -65,10 +65,14 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-6 mt-5">
|
||||
<figure class="figure">
|
||||
<figure class="figure w-75 ml-3">
|
||||
<?php if ($wg_penabled == true ) : ?>
|
||||
<img src="app/img/wg-qr-code.php" class="figure-img img-fluid" alt="RaspAP Wifi QR code" style="width:100%;">
|
||||
<figcaption class="figure-caption"><?php echo _("Scan this QR code with your client to connect to this tunnel"); ?></figcaption>
|
||||
<figcaption class="figure-caption">
|
||||
<?php echo _("Scan this QR code with your client to connect to this tunnel"); ?>
|
||||
<?php echo _("or download the <code>client.conf</code> file to your device."); ?>
|
||||
</figcaption>
|
||||
<button class="btn btn-outline-secondary rounded-right wg-client-dl mt-2" type="button"><?php echo _("Download"); ?> <i class="fas fa-download ml-1"></i></button>
|
||||
<?php endif; ?>
|
||||
</figure>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user