From cc1c8d594ad9512ce483708405bb1e22e014e33e Mon Sep 17 00:00:00 2001 From: billz Date: Tue, 23 Feb 2021 23:21:02 +0000 Subject: [PATCH] Update w/ fallback default values --- includes/wireguard.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/includes/wireguard.php b/includes/wireguard.php index 84956b89..a7404495 100644 --- a/includes/wireguard.php +++ b/includes/wireguard.php @@ -50,6 +50,7 @@ function DisplayWireGuardConfig() $config[] = '[Interface]'; $config[] = 'Address = '.$_POST['wg_ipaddress']; $config[] = 'ListenPort = '.$_POST['wg_port']; + $config[] = ''; $config[] = 'PrivateKey = '.$_POST['wg_privkey']; $config[] = 'PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE'; @@ -102,8 +103,8 @@ function DisplayWireGuardConfig() // fetch wg config exec('sudo cat '. RASPI_WIREGUARD_CONFIG, $return); $conf = ParseConfig($return); - $wg_port = $conf['ListenPort']; - $wg_ipaddress = $conf['Address']; + $wg_port = ($conf['ListenPort'] == '') ? getDefaultNetValue('wireguard','interface','listenport') : $conf['ListenPort']; + $wg_ipaddress = ($conf['Address'] == '') ? getDefaultNetValue('wireguard','interface','address') : $conf['Address']; $wg_pubkey = $conf['PublicKey']; $wg_privkey = $conf['PrivateKey']; $wg_endpoint = $conf['Endpoint'];