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

Apply zbchristian/fix-wireguard conf

This commit is contained in:
billz 2022-01-25 08:36:14 +00:00
parent 7435dfd0ff
commit 4b6db8bb1b

View File

@ -18,6 +18,8 @@ function DisplayWireGuardConfig()
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"])) {
SaveWireGuardUpload($status, $_FILES['wgFile'], $optRules); SaveWireGuardUpload($status, $_FILES['wgFile'], $optRules);
} elseif (isset($_POST['savewgsettings']) && isset($_POST['wg_penabled']) ) {
SaveWireGuardConfig($status);
} elseif (isset($_POST['startwg'])) { } elseif (isset($_POST['startwg'])) {
$status->addMessage('Attempting to start WireGuard', 'info'); $status->addMessage('Attempting to start WireGuard', 'info');
exec('sudo /bin/systemctl start wg-quick@wg0', $return); exec('sudo /bin/systemctl start wg-quick@wg0', $return);
@ -166,7 +168,7 @@ function SaveWireGuardConfig($status)
$good_input = true; $good_input = true;
$peer_id = 1; $peer_id = 1;
// Validate server input // Validate server input
if ($_POST['wg_senabled'] == 1) { if ($_POST['wgSrvEnable'] == 1) {
if (isset($_POST['wg_srvport'])) { if (isset($_POST['wg_srvport'])) {
if (strlen($_POST['wg_srvport']) > 5 || !is_numeric($_POST['wg_srvport'])) { if (strlen($_POST['wg_srvport']) > 5 || !is_numeric($_POST['wg_srvport'])) {
$status->addMessage('Invalid value for server local port', 'danger'); $status->addMessage('Invalid value for server local port', 'danger');
@ -224,7 +226,7 @@ function SaveWireGuardConfig($status)
// Save settings // Save settings
if ($good_input) { if ($good_input) {
// server (wg0.conf) // server (wg0.conf)
if ($_POST['wg_senabled'] == 1) { if ($_POST['wgSrvEnable'] == 1) {
// fetch server private key from filesytem // fetch server private key from filesytem
$wg_srvprivkey = exec('sudo cat '. RASPI_WIREGUARD_PATH .'wg-server-private.key', $return); $wg_srvprivkey = exec('sudo cat '. RASPI_WIREGUARD_PATH .'wg-server-private.key', $return);
$config[] = '[Interface]'; $config[] = '[Interface]';