Browse Source

Apply zbchristian/fix-wireguard conf

pull/1113/head
billz 1 year ago
parent
commit
4b6db8bb1b
  1. 6
      includes/wireguard.php

6
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]';

Loading…
Cancel
Save