Skip to content

Commit

Permalink
net: style sweep
Browse files Browse the repository at this point in the history
  • Loading branch information
fichtner committed Mar 13, 2020
1 parent b4cb311 commit b749701
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
18 changes: 9 additions & 9 deletions net/firewall/src/etc/inc/plugins.inc.d/pfplugin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
/**
* @param $fw
*/
function pfplugin_firewall($fw)
{
$mdlFilter = new OPNsense\Firewall\Filter();
foreach ($mdlFilter->rules->rule->sortedBy(["sequence"]) as $key => $rule) {
$content = $rule->serialize();
$content["#ref"] = "ui/firewall/filter#" . (string)$rule->getAttributes()['uuid'];
$fw->registerFilterRule($rule->getPriority(), $content);
}
}
function pfplugin_firewall($fw)
{
$mdlFilter = new OPNsense\Firewall\Filter();
foreach ($mdlFilter->rules->rule->sortedBy(["sequence"]) as $key => $rule) {
$content = $rule->serialize();
$content["#ref"] = "ui/firewall/filter#" . (string)$rule->getAttributes()['uuid'];
$fw->registerFilterRule($rule->getPriority(), $content);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
*/
namespace OPNsense\Firewall;


class FilterController extends \OPNsense\Base\IndexController
{
public function indexAction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,12 @@ public function getPriority()
if (strpos($interface, ",") !== false) {
// floating (multiple interfaces involved)
return 1000;
} elseif (!empty($configObj->interfaces) &&
} elseif (
!empty($configObj->interfaces) &&
!empty($configObj->interfaces->$interface) &&
!empty($configObj->interfaces->$interface->type) &&
$configObj->interfaces->$interface->type == 'group') {
$configObj->interfaces->$interface->type == 'group'
) {
// group type
return 2000;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ public function performValidation($validateFullModel = false)
foreach ($this->rules->rule->iterateItems() as $rule) {
// validate changed rules
$rule_changed = false;
foreach($rule->iterateItems() as $field) {
foreach ($rule->iterateItems() as $field) {
$rule_changed = $rule_changed ? $rule_changed : $field->isFieldChanged();
}
if ($validateFullModel || $rule_changed) {
// port / protocol validation
if (!empty((string)$rule->source_port) && !in_array( $rule->protocol, ['TCP', 'UDP'])) {
if (!empty((string)$rule->source_port) && !in_array($rule->protocol, ['TCP', 'UDP'])) {
$messages->appendMessage(new Message(
gettext("Source ports are only valid for tcp or udp type rules."),
$rule->source_port->__reference
));
}
if (!empty((string)$rule->destination_port) && !in_array( $rule->protocol, ['TCP', 'UDP'])) {
if (!empty((string)$rule->destination_port) && !in_array($rule->protocol, ['TCP', 'UDP'])) {
$messages->appendMessage(new Message(
gettext("Destination ports are only valid for tcp or udp type rules."),
$rule->destination_port->__reference
Expand Down Expand Up @@ -100,7 +100,7 @@ public function rollback($revision)
$sourcedom = dom_import_simplexml($sourcexml->OPNsense->Firewall->FilterRule);
$targetxml = Config::getInstance()->object();
$targetdom = dom_import_simplexml($targetxml->OPNsense->Firewall->FilterRule);
$node = $targetdom->ownerDocument->importNode($sourcedom, TRUE);
$node = $targetdom->ownerDocument->importNode($sourcedom, true);
$targetdom->parentNode->replaceChild($node, $targetdom);
Config::getInstance()->save();
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<v6destination type="NetworkField">
<default>2001:db8:1:ffff::1</default>
<Required>Y</Required>
</v6destination>
</v6destination>
<v6prefix type="NetworkField">
<default>2001:db8:1:ffff::/96</default>
<Required>Y</Required>
Expand Down

0 comments on commit b749701

Please sign in to comment.