From b7497011938f926433082e2ab5b1e7521813b728 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Fri, 13 Mar 2020 08:27:10 +0100 Subject: [PATCH] net: style sweep --- .../src/etc/inc/plugins.inc.d/pfplugin.inc | 18 +++++++++--------- .../OPNsense/Firewall/FilterController.php | 1 - .../Firewall/FieldTypes/FilterRuleField.php | 6 ++++-- .../app/models/OPNsense/Firewall/Filter.php | 8 ++++---- .../mvc/app/models/OPNsense/Tayga/General.xml | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/net/firewall/src/etc/inc/plugins.inc.d/pfplugin.inc b/net/firewall/src/etc/inc/plugins.inc.d/pfplugin.inc index a9c1948066..8f68a6b131 100644 --- a/net/firewall/src/etc/inc/plugins.inc.d/pfplugin.inc +++ b/net/firewall/src/etc/inc/plugins.inc.d/pfplugin.inc @@ -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); + } +} diff --git a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/FilterController.php b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/FilterController.php index 789f32a499..a3b711e8f5 100644 --- a/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/FilterController.php +++ b/net/firewall/src/opnsense/mvc/app/controllers/OPNsense/Firewall/FilterController.php @@ -27,7 +27,6 @@ */ namespace OPNsense\Firewall; - class FilterController extends \OPNsense\Base\IndexController { public function indexAction() diff --git a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/FilterRuleField.php b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/FilterRuleField.php index 06afc60f63..e49d452d6e 100644 --- a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/FilterRuleField.php +++ b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/FieldTypes/FilterRuleField.php @@ -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 { diff --git a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.php b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.php index ccaa644ed8..90cf019d95 100644 --- a/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.php +++ b/net/firewall/src/opnsense/mvc/app/models/OPNsense/Firewall/Filter.php @@ -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 @@ -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; diff --git a/net/tayga/src/opnsense/mvc/app/models/OPNsense/Tayga/General.xml b/net/tayga/src/opnsense/mvc/app/models/OPNsense/Tayga/General.xml index 63fdb0c3dd..8ce7919d6d 100644 --- a/net/tayga/src/opnsense/mvc/app/models/OPNsense/Tayga/General.xml +++ b/net/tayga/src/opnsense/mvc/app/models/OPNsense/Tayga/General.xml @@ -21,7 +21,7 @@ 2001:db8:1:ffff::1 Y - + 2001:db8:1:ffff::/96 Y