From 7665d2bc7f76700bef5ee3170f2dc5186a1e1395 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Thu, 18 Jul 2019 08:54:45 +0200 Subject: [PATCH] filter, rule overview. guess ipproto when not set, closes https://github.com/opnsense/core/issues/3581 --- src/www/firewall_rules.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/www/firewall_rules.php b/src/www/firewall_rules.php index 18ff79c17..63a96ef40 100644 --- a/src/www/firewall_rules.php +++ b/src/www/firewall_rules.php @@ -51,7 +51,21 @@ function firewall_rule_item_proto($filterent) break; } } else { - $record_ipprotocol = "IPv4 "; + // when ipprotocol is not set, pf would normally figure out the ip proto itself. + // reconstruct ipproto depending on source/destination address. + if (!empty($filterent['from']) && is_ipaddr(explode("/", $filterent['from'])[0])) { + $record_ipprotocol = strpos($filterent['from'], ":") === false ? "IPv4 " : "IPv6 "; + } elseif (!empty($filterent['to']) && is_ipaddr(explode("/", $filterent['to'])[0])) { + $record_ipprotocol = strpos($filterent['to'], ":") === false ? "IPv4 " : "IPv6 "; + } elseif (isset($filterent['source']['address']) + && is_ipaddr(explode("/", $filterent['source']['address'])[0])) { + $record_ipprotocol = strpos($filterent['source']['address'], ":") === false ? "IPv4 " : "IPv6 "; + } elseif (isset($filterent['destination']['address']) + && is_ipaddr(explode("/", $filterent['destination']['address'])[0])) { + $record_ipprotocol = strpos($filterent['destination']['address'], ":") === false ? "IPv4 " : "IPv6 "; + } else { + $record_ipprotocol = "IPv4+6 "; + } } $icmptypes = array( "" => gettext("any"),