diff --git a/src/etc/inc/config.inc b/src/etc/inc/config.inc index cf9b948a4..35f833be8 100644 --- a/src/etc/inc/config.inc +++ b/src/etc/inc/config.inc @@ -63,23 +63,11 @@ function load_config_from_file($filename) ******/ function parse_config() { - global $aliastable; - $cnf = OPNsense\Core\Config::getInstance(); // return config data as array, use old "listags" construction to mark certain elements as array (even if they're not recurring) $config = $cnf->toArray(listtags()); - $aliastable = array(); - - foreach ((new \OPNsense\Firewall\Alias())->aliasIterator() as $alias) { - if (strncmp($alias['type'], 'url', 3) !== 0) { - $aliastable[$alias['name']] = implode(" ", explode("\n", $alias['content'])); - } else { - $aliastable[$alias['name']] = ""; - } - } - return $config; } diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 45f763121..bee33f601 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -543,7 +543,7 @@ function system_routing_configure($verbose = false, $interface = '') function system_staticroutes_configure($interface = '') { - $static_routes = get_staticroutes(false, true); + $static_routes = get_staticroutes(false); if (count($static_routes)) { $ifdetails = legacy_interfaces_details(); $gateways_arr = (new \OPNsense\Routing\Gateways($ifdetails))->gatewaysIndexedByName(false, true); diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index f79b322ac..fc61dd5df 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -1027,8 +1027,7 @@ function mwexecf_bg($format, $args = array(), $mute = false) /* check if an alias exists */ function is_alias($name) { - global $aliastable; - return array_key_exists($name, $aliastable); + return \OPNsense\Firewall\Util::isAlias($name); } function subnet_size($subnet) @@ -1241,36 +1240,14 @@ function is_URL($url) return false; } -function get_staticroutes($returnsubnetsonly = false, $returnhostnames = false) +function get_staticroutes($returnsubnetsonly=false) { global $aliastable; - $allstaticroutes = array(); - $allsubnets = array(); - - /* Loop through routes and expand aliases as we find them. */ + $allstaticroutes = []; + $allsubnets = []; foreach (config_read_array('staticroutes', 'route') as $route) { - if (is_alias($route['network'])) { - if (!isset($aliastable[$route['network']])) { - continue; - } - $subnets = preg_split('/\s+/', $aliastable[$route['network']]); - foreach ($subnets as $net) { - if (!is_subnet($net)) { - if (is_ipaddrv4($net)) { - $net .= "/32"; - } elseif (is_ipaddrv6($net)) { - $net .= "/128"; - } elseif ($returnhostnames === false || !is_fqdn($net)) { - continue; - } - } - $temproute = $route; - $temproute['network'] = $net; - $allstaticroutes[] = $temproute; - $allsubnets[] = $net; - } - } elseif (is_subnet($route['network'])) { + if (is_subnet($route['network'])) { $allstaticroutes[] = $route; $allsubnets[] = $route['network']; }