getInterfaceGateways() should only return first found entry per ipprotocol

This commit is contained in:
Ad Schellevis 2017-06-12 12:29:11 +02:00 committed by Franco Fichtner
parent 013f3c7e8f
commit 9ed1bd79f2

View File

@ -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;