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

Code cleanup, update Endpoint default value

This commit is contained in:
billz 2021-03-07 19:06:53 +00:00
parent 7c1ef85bb8
commit 1e7438da23
6 changed files with 18 additions and 12 deletions

View File

@ -368,6 +368,7 @@ window.addEventListener('load', function() {
// Loop over them and prevent submission // Loop over them and prevent submission
var validation = Array.prototype.filter.call(forms, function(form) { var validation = Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) { form.addEventListener('submit', function(event) {
//console.log(event.submitter);
if (form.checkValidity() === false) { if (form.checkValidity() === false) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();

View File

@ -44,7 +44,7 @@
}, },
"peer": { "peer": {
"Address": [ "10.8.1.2/24" ], "Address": [ "10.8.1.2/24" ],
"Endpoint": [ "10.8.2.1" ], "Endpoint": [ "10.8.2.1:51820" ],
"ListenPort": [ "21841" ], "ListenPort": [ "21841" ],
"AllowedIPs": ["10.8.2.0/24"], "AllowedIPs": ["10.8.2.0/24"],
"PersistentKeepalive": [ "15" ] "PersistentKeepalive": [ "15" ]

View File

@ -44,6 +44,9 @@ function DisplayWireGuardConfig()
$wg_pendpoint = ($conf['Endpoint'] == '') ? getDefaultNetValue('wireguard','peer','Endpoint') : $conf['Endpoint']; $wg_pendpoint = ($conf['Endpoint'] == '') ? getDefaultNetValue('wireguard','peer','Endpoint') : $conf['Endpoint'];
$wg_pallowedips = ($conf['AllowedIPs'] == '') ? getDefaultNetValue('wireguard','peer','AllowedIPs') : $conf['AllowedIPs']; $wg_pallowedips = ($conf['AllowedIPs'] == '') ? getDefaultNetValue('wireguard','peer','AllowedIPs') : $conf['AllowedIPs'];
$wg_pkeepalive = ($conf['PersistentKeepalive'] == '') ? getDefaultNetValue('wireguard','peer','PersistentKeepalive') : $conf['PersistentKeepalive']; $wg_pkeepalive = ($conf['PersistentKeepalive'] == '') ? getDefaultNetValue('wireguard','peer','PersistentKeepalive') : $conf['PersistentKeepalive'];
if (sizeof($conf) >0) {
$wg_penabled = true;
}
// fetch service status // fetch service status
exec('pidof wg-crypt-wg0 | wc -l', $wgstatus); exec('pidof wg-crypt-wg0 | wc -l', $wgstatus);
@ -56,12 +59,12 @@ function DisplayWireGuardConfig()
"wg_state", "wg_state",
"serviceStatus", "serviceStatus",
"wg_log", "wg_log",
"endpoint_enable",
"peer_id", "peer_id",
"wg_srvpubkey", "wg_srvpubkey",
"wg_srvport", "wg_srvport",
"wg_srvipaddress", "wg_srvipaddress",
"wg_srvdns", "wg_srvdns",
"wg_penabled",
"wg_pipaddress", "wg_pipaddress",
"wg_plistenport", "wg_plistenport",
"wg_peerpubkey", "wg_peerpubkey",

View File

@ -19,7 +19,7 @@
<label for="code"><?php echo _("Local public key"); ?></label> <label for="code"><?php echo _("Local public key"); ?></label>
</div> </div>
<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); ?>" required /> <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-outline-secondary rounded-right wg-keygen" type="button"><i class="fas fa-magic"></i></button> <button class="btn btn-outline-secondary rounded-right wg-keygen" type="button"><i class="fas fa-magic"></i></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>
@ -30,21 +30,21 @@
<div class="row"> <div class="row">
<div class="form-group col-xs-3 col-sm-3"> <div class="form-group col-xs-3 col-sm-3">
<label for="code"><?php echo _("Local Port"); ?></label> <label for="code"><?php echo _("Local Port"); ?></label>
<input type="text" class="form-control" name="wg_srvport" value="<?php echo htmlspecialchars($wg_srvport, ENT_QUOTES); ?>" required /> <input type="text" class="form-control" name="wg_srvport" value="<?php echo htmlspecialchars($wg_srvport, ENT_QUOTES); ?>" />
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="code"><?php echo _("IP Address"); ?></label> <label for="code"><?php echo _("IP Address"); ?></label>
<input type="text" class="form-control" name="wg_srvipaddress" value="<?php echo htmlspecialchars($wg_srvipaddress, ENT_QUOTES); ?>" required /> <input type="text" class="form-control" name="wg_srvipaddress" value="<?php echo htmlspecialchars($wg_srvipaddress, ENT_QUOTES); ?>" />
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="code"><?php echo _("DNS"); ?></label> <label for="code"><?php echo _("DNS"); ?></label>
<input type="text" class="form-control" name="wg_srvdns" value="<?php echo htmlspecialchars($wg_srvdns, ENT_QUOTES); ?>" required /> <input type="text" class="form-control" name="wg_srvdns" value="<?php echo htmlspecialchars($wg_srvdns, ENT_QUOTES); ?>" />
</div> </div>
</div> </div>

View File

@ -17,7 +17,7 @@
<label for="code"><?php echo _("Peer public key"); ?></label> <label for="code"><?php echo _("Peer public key"); ?></label>
</div> </div>
<div class="input-group col-md-12"> <div class="input-group col-md-12">
<input type="text" class="form-control" name="wg-peer" id="wg-peerpubkey" value="<?php echo htmlspecialchars($wg_peerpubkey, ENT_QUOTES); ?>" required /> <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-outline-secondary rounded-right wg-keygen" type="button"><i class="fas fa-magic"></i></button> <button class="btn btn-outline-secondary rounded-right wg-keygen" type="button"><i class="fas fa-magic"></i></button>
<span id="wg-peer-pubkey-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>
@ -28,28 +28,28 @@
<div class="row"> <div class="row">
<div class="form-group col-xs-3 col-sm-3 mt-3"> <div class="form-group col-xs-3 col-sm-3 mt-3">
<label for="code"><?php echo _("Local Port"); ?></label> <label for="code"><?php echo _("Local Port"); ?></label>
<input type="text" class="form-control" name="wg_plistenport" value="<?php echo htmlspecialchars($wg_plistenport, ENT_QUOTES); ?>" required /> <input type="text" class="form-control" name="wg_plistenport" value="<?php echo htmlspecialchars($wg_plistenport, ENT_QUOTES); ?>" />
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-md-6"> <div class="form-group col-md-6">
<label for="code"><?php echo _("IP Address"); ?></label> <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); ?>" required /> <input type="text" class="form-control" name="wg_pipaddress" value="<?php echo htmlspecialchars($wg_pipaddress, ENT_QUOTES); ?>" />
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="form-group col-xs-3 col-sm-6"> <div class="form-group col-xs-3 col-sm-6">
<label for="code"><?php echo _("Endpoint address"); ?></label> <label for="code"><?php echo _("Endpoint address"); ?></label>
<input type="text" class="form-control" name="wg_pendpoint" value="<?php echo htmlspecialchars($wg_pendpoint, ENT_QUOTES); ?>" required /> <input type="text" class="form-control" name="wg_pendpoint" value="<?php echo htmlspecialchars($wg_pendpoint, ENT_QUOTES); ?>" />
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-xs-3 col-sm-6"> <div class="col-xs-3 col-sm-6">
<label for="code"><?php echo _("Allowed IPs"); ?></label> <label for="code"><?php echo _("Allowed IPs"); ?></label>
<input type="text" class="form-control mb-3" name="wg_pallowedips" value="<?php echo htmlspecialchars($wg_pallowedips, ENT_QUOTES); ?>" required /> <input type="text" class="form-control mb-3" name="wg_pallowedips" value="<?php echo htmlspecialchars($wg_pallowedips, ENT_QUOTES); ?>" />
</div> </div>
</div> </div>
@ -63,8 +63,10 @@
<div class="col-md-6 mt-5"> <div class="col-md-6 mt-5">
<figure class="figure"> <figure class="figure">
<?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%;"> <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 RaspAP."); ?></figcaption> <figcaption class="figure-caption"><?php echo _("Scan this QR code with your client to connect to this RaspAP."); ?></figcaption>
<?php endif; ?>
</figure> </figure>
</div> </div>

View File

@ -27,7 +27,7 @@
</div><!-- /.card-header --> </div><!-- /.card-header -->
<div class="card-body"> <div class="card-body">
<?php $status->showMessages(); ?> <?php $status->showMessages(); ?>
<form class="needs-validation" role="form" action="/wg_conf" enctype="multipart/form-data" method="POST" novalidate> <form role="form" action="/wg_conf" enctype="multipart/form-data" method="POST">
<?php echo CSRFTokenFieldTag() ?> <?php echo CSRFTokenFieldTag() ?>
<!-- Nav tabs --> <!-- Nav tabs -->
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">