mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-19 19:15:22 +00:00
Firewall/alias, prefer mvc aliases in isAlias(), at the moment we need to keep scanning both (legacy,mvc) to make sure the migration can actually run. for https://github.com/opnsense/core/issues/1858
This commit is contained in:
parent
409b8aac38
commit
3c0746d90b
@ -29,6 +29,7 @@
|
||||
namespace OPNsense\Firewall;
|
||||
|
||||
use \OPNsense\Core\Config;
|
||||
use \OPNsense\Firewall\Alias;
|
||||
|
||||
/**
|
||||
* Class Util, common static firewall support functions
|
||||
@ -72,15 +73,27 @@ class Util
|
||||
* check if name exists in alias config section
|
||||
* @param string $name name
|
||||
* @return boolean
|
||||
* @throws \OPNsense\Base\ModelException
|
||||
*/
|
||||
public static function isAlias($name)
|
||||
{
|
||||
if (!empty($name) && !empty(Config::getInstance()->object()->aliases)) {
|
||||
foreach (Config::getInstance()->object()->aliases->children() as $node) {
|
||||
if ($node->name == $name) {
|
||||
if (!empty($name) ){
|
||||
$aliasMdl = new Alias();
|
||||
// MVC defined aliases
|
||||
foreach ($aliasMdl->aliases->alias->__items as $alias) {
|
||||
if ((string)$alias->name == $name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// legacy style aliases
|
||||
$cnf = Config::getInstance()->object();
|
||||
if (!empty($cnf->aliases)) {
|
||||
foreach ($cnf->aliases->children() as $node) {
|
||||
if ($node->name == $name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user