1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00

Update wg-keygen for server + peer

This commit is contained in:
billz 2021-02-24 10:32:07 +00:00
parent 796ed558f7
commit b7ed2960c1
3 changed files with 10 additions and 11 deletions

View File

@ -350,16 +350,15 @@ function clearBlocklistStatus() {
} }
// Handler for the wireguard generate key button // Handler for the wireguard generate key button
function generateWgKey() { $('.wg-keygen').click(function(){
var entity = $('#wg-srvpubkey').attr('name'); var entity = $(this).parent('div').prev('input[type="text"]');
console.log(entity); var updated = entity.attr('name')+"-pubkey-status";
$.post('ajax/networking/get_wgkey.php',{'entity':entity },function(data){ $.post('ajax/networking/get_wgkey.php',{'entity':entity.attr('name') },function(data){
var jsonData = JSON.parse(data); var jsonData = JSON.parse(data);
console.log(jsonData); entity.val(jsonData);
$('#wg-srvpubkey').val(jsonData); $('#' + updated).removeClass('check-hidden').addClass('check-updated').delay(500).animate({ opacity: 1 }, 700);
$('#wg-server-pubkey-status').removeClass('check-hidden').addClass('check-updated').delay(500).animate({ opacity: 1 }, 700);
}) })
} })
// Static Array method // Static Array method
Array.range = (start, end) => Array.from({length: (end - start)}, (v, k) => k + start); Array.range = (start, end) => Array.from({length: (end - start)}, (v, k) => k + start);

View File

@ -27,7 +27,7 @@
<div class="input-group col-md-12 mb-3"> <div class="input-group col-md-12 mb-3">
<input type="text" class="form-control" name="wg-server" id="wg-srvpubkey" value="<?php echo htmlspecialchars($wg_srvpubkey, ENT_QUOTES); ?>" /> <input type="text" class="form-control" name="wg-server" id="wg-srvpubkey" value="<?php echo htmlspecialchars($wg_srvpubkey, ENT_QUOTES); ?>" />
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-sm btn-outline-secondary rounded-right" type="button" onclick="generateWgKey()"><?php echo _("Generate key"); ?></button> <button class="btn btn-sm btn-outline-secondary rounded-right wg-keygen" type="button"><?php echo _("Generate key"); ?></button>
<span id="wg-server-pubkey-status" class="input-group-addon check-hidden ml-2 mt-1"><i class="fas fa-check"></i></span> <span id="wg-server-pubkey-status" class="input-group-addon check-hidden ml-2 mt-1"><i class="fas fa-check"></i></span>
</div> </div>
</div> </div>

View File

@ -41,8 +41,8 @@
<div class="input-group col-md-12 mb-3"> <div class="input-group col-md-12 mb-3">
<input type="text" class="form-control" name="wg-peer" id="wg-peerpubkey" value="<?php echo htmlspecialchars($wg_peerpubkey, ENT_QUOTES); ?>" /> <input type="text" class="form-control" name="wg-peer" id="wg-peerpubkey" value="<?php echo htmlspecialchars($wg_peerpubkey, ENT_QUOTES); ?>" />
<div class="input-group-append"> <div class="input-group-append">
<button class="btn btn-sm btn-outline-secondary rounded-right" type="button" onclick="generateWgKey()"><?php echo _("Generate key"); ?></button> <button class="btn btn-sm btn-outline-secondary rounded-right wg-keygen" type="button"><?php echo _("Generate key"); ?></button>
<span id="cbxblocklist-status" class="input-group-addon check-hidden ml-2 mt-1"><i class="fas fa-check"></i></span> <span id="wg-peer-pubkey-status" class="input-group-addon check-hidden ml-2 mt-1"><i class="fas fa-check"></i></span>
</div> </div>
</div> </div>
</div> </div>