mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
firewall: add priority method similar to the legacy priority choices and allow dynamic type interfaces
for https://github.com/opnsense/plugins/issues/1720
This commit is contained in:
committed by
Ad Schellevis
parent
2ef75761fd
commit
4d5aea8e63
+28
@@ -30,6 +30,7 @@
|
||||
|
||||
namespace OPNsense\Firewall\FieldTypes;
|
||||
|
||||
use OPNsense\Core\Config;
|
||||
use OPNsense\Base\FieldTypes\ArrayField;
|
||||
use OPNsense\Base\FieldTypes\ContainerField;
|
||||
|
||||
@@ -80,8 +81,35 @@ class FilterRuleContainerField extends ContainerField
|
||||
//
|
||||
$result['descr'] = (string)$this->description;
|
||||
$result['type'] = (string)$this->action;
|
||||
if (strpos((string)$this->interface, ",") !== false) {
|
||||
$result['floating'] = true;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* rule priority is threaded equally to the legacy rules, first "floating" then groups and single interface
|
||||
* rules are handled last
|
||||
* @return int priority in the ruleset, sequence should determine sort order.
|
||||
*/
|
||||
public function getPriority()
|
||||
{
|
||||
$configObj = Config::getInstance()->object();
|
||||
$interface = (string)$this->interface;
|
||||
if (strpos($interface, ",") !== false) {
|
||||
// floating (multiple interfaces involved)
|
||||
return 1000;
|
||||
} elseif (!empty($configObj->interfaces) &&
|
||||
!empty($configObj->interfaces->$interface) &&
|
||||
!empty($configObj->interfaces->$interface->type) &&
|
||||
$configObj->interfaces->$interface->type == 'group') {
|
||||
// group type
|
||||
return 2000;
|
||||
} else {
|
||||
// default
|
||||
return 3000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<Required>Y</Required>
|
||||
<multiple>Y</multiple>
|
||||
<default>lan</default>
|
||||
<AllowDynamic>Y</AllowDynamic>
|
||||
</interface>
|
||||
<direction type="OptionField">
|
||||
<Required>Y</Required>
|
||||
|
||||
Reference in New Issue
Block a user