From 4b6db8bb1bef5e1fb15b02ed139dcd9d2bd8ae6f Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 25 Jan 2022 08:36:14 +0000 Subject: [PATCH] Apply zbchristian/fix-wireguard conf --- includes/wireguard.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/wireguard.php b/includes/wireguard.php index 8718a2dd..dfe04d5c 100644 --- a/includes/wireguard.php +++ b/includes/wireguard.php @@ -18,6 +18,8 @@ function DisplayWireGuardConfig() SaveWireGuardConfig($status); } elseif (isset($_POST['savewgsettings']) && $optConf == 'upload' && is_uploaded_file($_FILES["wgFile"]["tmp_name"])) { SaveWireGuardUpload($status, $_FILES['wgFile'], $optRules); + } elseif (isset($_POST['savewgsettings']) && isset($_POST['wg_penabled']) ) { + SaveWireGuardConfig($status); } elseif (isset($_POST['startwg'])) { $status->addMessage('Attempting to start WireGuard', 'info'); exec('sudo /bin/systemctl start wg-quick@wg0', $return); @@ -166,7 +168,7 @@ function SaveWireGuardConfig($status) $good_input = true; $peer_id = 1; // Validate server input - if ($_POST['wg_senabled'] == 1) { + if ($_POST['wgSrvEnable'] == 1) { if (isset($_POST['wg_srvport'])) { if (strlen($_POST['wg_srvport']) > 5 || !is_numeric($_POST['wg_srvport'])) { $status->addMessage('Invalid value for server local port', 'danger'); @@ -224,7 +226,7 @@ function SaveWireGuardConfig($status) // Save settings if ($good_input) { // server (wg0.conf) - if ($_POST['wg_senabled'] == 1) { + if ($_POST['wgSrvEnable'] == 1) { // fetch server private key from filesytem $wg_srvprivkey = exec('sudo cat '. RASPI_WIREGUARD_PATH .'wg-server-private.key', $return); $config[] = '[Interface]';