Fix ParseConfig() handling of name-only options, thx @meandthemachine

This commit is contained in:
billz 2024-12-16 18:19:15 -08:00
parent f811d21dc7
commit b7a6d334e3

View File

@ -54,7 +54,7 @@ function cidr2mask($cidr)
{
$ipParts = explode('/', $cidr);
$ip = $ipParts[0];
$prefixLength = $ipParts[1];
$prefixLength = $ipParts[1] ?? null;
$ipLong = ip2long($ip);
$netmaskLong = bindec(str_pad(str_repeat('1', $prefixLength), 32, '0'));
@ -458,6 +458,9 @@ function ParseConfig($arrConfig, $wg = false)
if (strpos($line, "=") !== false) {
list($option, $value) = array_map("trim", explode("=", $line, 2));
} else {
$option = $line;
$value = "";
}
if (empty($config[$option])) {
$config[$option] = $value ?: true;