mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Fix: Add $wg boolean to ParseConfig()
This commit is contained in:
parent
e86e52f471
commit
0684c46b23
@ -435,18 +435,25 @@ function GetDistString($input, $string, $offset, $separator)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $arrConfig
|
||||
* Parses a configuration file
|
||||
* Options and values are mapped with "=" characters
|
||||
* Optional $wg flag is used for parsing WireGuard .conf files
|
||||
* @param array $arrConfig
|
||||
* @param boolean $wg
|
||||
* @return $config
|
||||
*/
|
||||
function ParseConfig($arrConfig)
|
||||
function ParseConfig($arrConfig, $wg = false)
|
||||
{
|
||||
$config = array();
|
||||
foreach ($arrConfig as $line) {
|
||||
$line = trim($line);
|
||||
if ($line == "" || $line[0] == "#") {
|
||||
$config[$option] = null;
|
||||
continue;
|
||||
if ($wg) {
|
||||
$config[$option] = null;
|
||||
continue;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (strpos($line, "=") !== false) {
|
||||
|
@ -8,6 +8,7 @@ require_once 'config.php';
|
||||
function DisplayWireGuardConfig()
|
||||
{
|
||||
$status = new \RaspAP\Messages\StatusMessage;
|
||||
$parseFlag = true;
|
||||
if (!RASPI_MONITOR_ENABLED) {
|
||||
$optRules = $_POST['wgRules'];
|
||||
$optConf = $_POST['wgCnfOpt'];
|
||||
@ -37,7 +38,7 @@ function DisplayWireGuardConfig()
|
||||
|
||||
// fetch server config
|
||||
exec('sudo cat '. RASPI_WIREGUARD_CONFIG, $return);
|
||||
$conf = ParseConfig($return);
|
||||
$conf = ParseConfig($return, $parseFlag);
|
||||
$wg_srvpubkey = exec('sudo cat '. RASPI_WIREGUARD_PATH .'wg-server-public.key', $return);
|
||||
$wg_srvport = ($conf['ListenPort'] == '') ? getDefaultNetValue('wireguard','server','ListenPort') : $conf['ListenPort'];
|
||||
$wg_srvipaddress = ($conf['Address'] == '') ? getDefaultNetValue('wireguard','server','Address') : $conf['Address'];
|
||||
@ -49,7 +50,7 @@ function DisplayWireGuardConfig()
|
||||
|
||||
// fetch client config
|
||||
exec('sudo cat '. RASPI_WIREGUARD_PATH.'client.conf', $preturn);
|
||||
$conf = ParseConfig($preturn);
|
||||
$conf = ParseConfig($preturn, $parseFlag);
|
||||
$wg_pipaddress = ($conf['Address'] == '') ? getDefaultNetValue('wireguard','peer','Address') : $conf['Address'];
|
||||
$wg_plistenport = ($conf['ListenPort'] == '') ? getDefaultNetValue('wireguard','peer','ListenPort') : $conf['ListenPort'];
|
||||
$wg_pendpoint = ($conf['Endpoint'] == '') ? getDefaultNetValue('wireguard','peer','Endpoint') : $conf['Endpoint'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user