diff --git a/src/opnsense/mvc/app/library/OPNsense/Firewall/FilterRule.php b/src/opnsense/mvc/app/library/OPNsense/Firewall/FilterRule.php index 958064ab2..ac2299d72 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Firewall/FilterRule.php +++ b/src/opnsense/mvc/app/library/OPNsense/Firewall/FilterRule.php @@ -293,4 +293,77 @@ class FilterRule extends Rule } return $ruleTxt; } + + /** + * Legacy and MVC use different fields, which at some point need to be merged. + * parseFilterRules already does this for the rule output, but gui parts are left with a mix of things + */ + private function uiConvertNet($network) + { + $suffix = str_ends_with($network, 'ip') ? gettext("address") : gettext("net"); + $ifname = rtrim($network, 'ip'); + if (!empty($this->interfaceMapping[$ifname])) { + $if = $this->interfaceMapping[$ifname]; + return (!empty($if['descr']) ? $if['descr'] : $ifname) . " " . $suffix; + } elseif ($ifname == '(self)') { + return gettext("This Firewall"); + } + return $network; + } + public function getUIFromAddress() + { + if (!empty($this->rule['from'])) { + return $this->rule['from']; + } elseif (isset($this->rule['source']['address'])) { + return $this->rule['source']['address']; + } elseif (isset($this->rule['source']['any'])) { + return '*'; + } elseif (isset($this->rule['source']['network'])) { + return $this->uiConvertNet($this->rule['source']['network']); + } + return '*'; + } + public function isUIFromNot() + { + return isset($this->rule['source']) && isset($this->rule['source']['not']); + } + public function getUIFromPort() + { + if (!empty($this->rule['from_port'])) { + return $this->rule['from_port']; + } elseif (isset($this->rule['source']['port'])) { + return $this->rule['source']['port']; + } + return '*'; + } + public function getUIToAddress() + { + if (!empty($this->rule['to'])) { + return $this->rule['to']; + } elseif (isset($this->rule['destination']['address'])) { + return $this->rule['destination']['address']; + } elseif (isset($this->rule['destination']['any'])) { + return '*'; + } elseif (isset($this->rule['destination']['network'])) { + return $this->uiConvertNet($this->rule['destination']['network']); + } + return '*'; + } + public function isUIToNot() + { + return isset($this->rule['destination']) && isset($this->rule['destination']['not']); + } + public function getUIToPort() + { + if (!empty($this->rule['to_port'])) { + return $this->rule['to_port']; + } elseif (isset($this->rule['destination']['port'])) { + return $this->rule['destination']['port']; + } + return '*'; + } + public function getUIGateway() + { + return !empty($this->rule['gateway']) ? $this->rule['gateway'] : "*"; + } } diff --git a/src/www/firewall_rules.php b/src/www/firewall_rules.php index a9e1e34b9..6b6802527 100644 --- a/src/www/firewall_rules.php +++ b/src/www/firewall_rules.php @@ -208,6 +208,20 @@ function firewall_rule_item_log($filterent) return "fa fa-info-circle fa-fw text-muted"; } } + +function filter_rule_item_alias_tooltip($alias_name) +{ + $alias_descr = htmlspecialchars(get_alias_description($alias_name)); + $alias_name = htmlspecialchars($alias_name); + $result = ""; + $result .= $alias_name . " "; + $result .= ""; + $result .= ""; + $result .= ""; + $result .= ""; + return $result; +} /*********************************************************************************************************** * ***********************************************************************************************************/ @@ -738,7 +752,10 @@ $( document ).ready(function() { ]; foreach ($fw->iterateFilterRules() as $rule): $is_selected = false; - if ($rule->getInterface() == $selected_if) { + if (empty($ifgroups) && $rule->ruleOrigin() == 'group'){ + // group view, skip group section (groups can't be nested) + $is_selected = false; + } elseif ($rule->getInterface() == $selected_if) { // interface view and this interface is selected $is_selected = true; } elseif ($selected_if == "FloatingRules" && $rule->ruleOrigin() == 'floating') { @@ -790,19 +807,21 @@ $( document ).ready(function() { - + isUIFromNot() ? '!' : '';?> + getUIFromAddress()) ? filter_rule_item_alias_tooltip($rule->getUIFromAddress()) : htmlspecialchars($rule->getUIFromAddress());?> - + getUIFromPort()) ? filter_rule_item_alias_tooltip($rule->getUIFromPort()) : htmlspecialchars(pprint_port($rule->getUIFromPort()));?> - + isUIToNot() ? '!' : '';?> + getUIToAddress()) ? filter_rule_item_alias_tooltip($rule->getUIToAddress()) : htmlspecialchars($rule->getUIToAddress());?> - + getUIToPort()) ? filter_rule_item_alias_tooltip($rule->getUIToPort()) : htmlspecialchars(pprint_port($rule->getUIToPort()));?> - + getUIGateway();?> * @@ -865,13 +884,7 @@ $( document ).ready(function() { - -   - - " data-toggle="tooltip"> - - + @@ -879,13 +892,7 @@ $( document ).ready(function() { - -   - - " data-toggle="tooltip"> - - + @@ -893,13 +900,7 @@ $( document ).ready(function() { - - - - " data-toggle="tooltip"> - - + @@ -907,13 +908,7 @@ $( document ).ready(function() { - -   - - " data-toggle="tooltip"> - - +