mirror of
https://github.com/RaspAP/raspap-webgui.git
synced 2024-11-25 09:00:25 +00:00
Update wg logging facility
This commit is contained in:
parent
5fe58be79e
commit
0af3e7a7c6
3 changed files with 24 additions and 9 deletions
|
@ -13,6 +13,7 @@ function DisplayWireGuardConfig()
|
||||||
$optRules = $_POST['wgRules'];
|
$optRules = $_POST['wgRules'];
|
||||||
$optConf = $_POST['wgCnfOpt'];
|
$optConf = $_POST['wgCnfOpt'];
|
||||||
$optSrvEnable = $_POST['wgSrvEnable'];
|
$optSrvEnable = $_POST['wgSrvEnable'];
|
||||||
|
$optLogEnable = $_POST['wgLogEnable'];
|
||||||
if (isset($_POST['savewgsettings']) && $optConf == 'manual' && $optSrvEnable == 1 ) {
|
if (isset($_POST['savewgsettings']) && $optConf == 'manual' && $optSrvEnable == 1 ) {
|
||||||
SaveWireGuardConfig($status);
|
SaveWireGuardConfig($status);
|
||||||
} elseif (isset($_POST['savewgsettings']) && $optConf == 'upload' && is_uploaded_file($_FILES["wgFile"]["tmp_name"])) {
|
} elseif (isset($_POST['savewgsettings']) && $optConf == 'upload' && is_uploaded_file($_FILES["wgFile"]["tmp_name"])) {
|
||||||
|
@ -30,6 +31,7 @@ function DisplayWireGuardConfig()
|
||||||
$status->addMessage($line, 'info');
|
$status->addMessage($line, 'info');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CheckWireGuardLog( $optLogEnable, $status );
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch server config
|
// fetch server config
|
||||||
|
@ -69,7 +71,7 @@ function DisplayWireGuardConfig()
|
||||||
"serviceStatus",
|
"serviceStatus",
|
||||||
"public_ip",
|
"public_ip",
|
||||||
"optRules",
|
"optRules",
|
||||||
"wg_log",
|
"optLogEnable",
|
||||||
"peer_id",
|
"peer_id",
|
||||||
"wg_srvpubkey",
|
"wg_srvpubkey",
|
||||||
"wg_srvport",
|
"wg_srvport",
|
||||||
|
@ -218,8 +220,11 @@ function SaveWireGuardConfig($status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save settings
|
// Save settings
|
||||||
if ($good_input) {
|
if ($good_input) {
|
||||||
|
var_dump($_POST);
|
||||||
|
|
||||||
// server (wg0.conf)
|
// server (wg0.conf)
|
||||||
if ($_POST['wg_senabled'] == 1) {
|
if ($_POST['wg_senabled'] == 1) {
|
||||||
// fetch server private key from filesytem
|
// fetch server private key from filesytem
|
||||||
|
@ -278,10 +283,6 @@ function SaveWireGuardConfig($status)
|
||||||
system('sudo rm '. RASPI_WIREGUARD_PATH.'client.conf', $return);
|
system('sudo rm '. RASPI_WIREGUARD_PATH.'client.conf', $return);
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle log option
|
|
||||||
if ($_POST['wg_log'] == "1") {
|
|
||||||
exec("sudo /bin/systemctl status wg-quick@wg0 | sudo tee /tmp/wireguard.log > /dev/null");
|
|
||||||
}
|
|
||||||
foreach ($return as $line) {
|
foreach ($return as $line) {
|
||||||
$status->addMessage($line, 'info');
|
$status->addMessage($line, 'info');
|
||||||
}
|
}
|
||||||
|
@ -293,3 +294,17 @@ function SaveWireGuardConfig($status)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return object $status
|
||||||
|
*/
|
||||||
|
function CheckWireGuardLog( $opt, $status )
|
||||||
|
{
|
||||||
|
// handle log option
|
||||||
|
if ( $opt == "1") {
|
||||||
|
exec("sudo journalctl --identifier wg-quick > /tmp/wireguard.log");
|
||||||
|
$status->addMessage('WireGuard debug log updated', 'success');
|
||||||
|
}
|
||||||
|
return $status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ www-data ALL=(ALL) NOPASSWD:/usr/local/sbin/onoff_huawei_hilink.sh *
|
||||||
www-data ALL=(ALL) NOPASSWD:/bin/sed -i * /etc/wvdial.conf
|
www-data ALL=(ALL) NOPASSWD:/bin/sed -i * /etc/wvdial.conf
|
||||||
www-data ALL=(ALL) NOPASSWD:/bin/sed -i * /etc/udev/rules.d/80-raspap-net-devices.rules
|
www-data ALL=(ALL) NOPASSWD:/bin/sed -i * /etc/udev/rules.d/80-raspap-net-devices.rules
|
||||||
www-data ALL=(ALL) NOPASSWD:/usr/bin/tee -a /etc/udev/rules.d/80-raspap-net-devices.rules
|
www-data ALL=(ALL) NOPASSWD:/usr/bin/tee -a /etc/udev/rules.d/80-raspap-net-devices.rules
|
||||||
www-data ALL=(ALL) NOPASSWD:/usr/bin/tee /tmp/wireguard.log
|
www-data ALL=(ALL) NOPASSWD:/usr/bin/journalctl --identifier wg-quick
|
||||||
www-data ALL=(ALL) NOPASSWD:/bin/systemctl * wg-quick@wg0
|
www-data ALL=(ALL) NOPASSWD:/bin/systemctl * wg-quick@wg0
|
||||||
www-data ALL=(ALL) NOPASSWD:/usr/bin/wg
|
www-data ALL=(ALL) NOPASSWD:/usr/bin/wg
|
||||||
www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wireguard/*.conf
|
www-data ALL=(ALL) NOPASSWD:/bin/cat /etc/wireguard/*.conf
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<h4 class="mt-3"><?php echo _("Logging"); ?></h4>
|
<h4 class="mt-3"><?php echo _("Logging"); ?></h4>
|
||||||
<div class="custom-control custom-switch">
|
<div class="custom-control custom-switch">
|
||||||
<input class="custom-control-input" id="wg_log" type="checkbox" name="wg_log" value="1" <?php echo $wg_log ? ' checked="checked"' : "" ?> aria-describedby="wg_log">
|
<input class="custom-control-input" id="wgLogEnable" type="checkbox" name="wgLogEnable" value="1" <?php echo $optLogEnable ? ' checked="checked"' : "" ?> aria-describedby="wgLogEnable">
|
||||||
<label class="custom-control-label" for="wg_log"><?php echo _("Display WireGuard status") ?></label>
|
<label class="custom-control-label" for="wgLogEnable"><?php echo _("Display WireGuard debug log") ?></label>
|
||||||
</div>
|
</div>
|
||||||
<p><small><?php echo _("Enable this option to display an updated WireGuard status.") ?></small></p>
|
<p><small><?php echo _("Enable this option to display an updated WireGuard debug log.") ?></small></p>
|
||||||
<?php
|
<?php
|
||||||
exec('sudo chmod o+r /tmp/wireguard.log');
|
exec('sudo chmod o+r /tmp/wireguard.log');
|
||||||
$log = file_get_contents('/tmp/wireguard.log');
|
$log = file_get_contents('/tmp/wireguard.log');
|
||||||
|
|
Loading…
Reference in a new issue