From 9ed1bd79f2a52ebedfe747db32969036add175c3 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 12 Jun 2017 12:29:11 +0200 Subject: [PATCH] getInterfaceGateways() should only return first found entry per ipprotocol --- .../mvc/app/library/OPNsense/Firewall/Plugin.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/opnsense/mvc/app/library/OPNsense/Firewall/Plugin.php b/src/opnsense/mvc/app/library/OPNsense/Firewall/Plugin.php index 447d6cb0e..ba265ac51 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Firewall/Plugin.php +++ b/src/opnsense/mvc/app/library/OPNsense/Firewall/Plugin.php @@ -78,6 +78,7 @@ class Plugin if (Util::isIpAddress($gw['gateway']) && !empty($gw['interface'])) { $this->gatewayMapping[$key] = array("logic" => "route-to ( {$gw['interface']} {$gw['gateway']} )", "interface" => $gw['interface'], + "gateway" => $gw['gateway'], "type" => "gateway"); } } @@ -120,9 +121,18 @@ class Plugin public function getInterfaceGateways($intf) { $result = array(); + $protos_found = array(); foreach ($this->gatewayMapping as $key => $gw) { if ($gw['type'] == 'gateway' && $gw['interface'] == $intf) { - $result[] = $key; + if (strstr($gw['gateway'], ':')) { + $proto = 'v6'; + } else { + $proto = 'v4'; + } + if (!in_array($proto, $protos_found)) { + $result[] = $key; + $protos_found[] = $proto; + } } } return $result;