Commit 316ce1e0 authored by Ad Schellevis's avatar Ad Schellevis

firewall / plugin, add getInterfaceGateways() and additional metadata to fetch...

firewall / plugin, add getInterfaceGateways() and additional metadata to fetch all related gateways. Needed for some of the current internal rules.
parent 3226dce2
......@@ -73,7 +73,9 @@ class Plugin
if (is_array($gateways)) {
foreach ($gateways as $key => $gw) {
if (Util::isIpAddress($gw['gateway']) && !empty($gw['interface'])) {
$this->gatewayMapping[$key] = array("logic" => "route-to ( {$gw['interface']} {$gw['gateway']} )");
$this->gatewayMapping[$key] = array("logic" => "route-to ( {$gw['interface']} {$gw['gateway']} )",
"interface" => $gw['interface'],
"type" => "gateway");
}
}
}
......@@ -101,12 +103,28 @@ class Plugin
if (!empty(Config::getInstance()->object()->system->lb_use_sticky)) {
$routetologic .= " sticky-address ";
}
$this->gatewayMapping[$key] = array("logic" => $routetologic);
$this->gatewayMapping[$key] = array("logic" => $routetologic,
"type" => "group");
}
}
}
}
/**
* fetch gateway (names) for provided interface, would return both ipv4/ipv6
* @param string $intf interface (e.g. em0, igb0,...)
*/
public function getInterfaceGateways($intf)
{
$result = array();
foreach ($this->gatewayMapping as $key => $gw) {
if ($gw['type'] == 'gateway' && $gw['interface'] == $intf) {
$result[] = $key;
}
}
return $result;
}
/**
* @return array
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment