mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 03:16:12 +00:00
firewall / plugin, add getInterfaceGateways() and additional metadata to fetch all related gateways. Needed for some of the current internal rules.
This commit is contained in:
parent
3226dce27d
commit
316ce1e05a
@ -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
|
||||
*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user