Routing, gateways. add getAddress() method to return a gateways address. for https://github.com/opnsense/core/issues/2279

This commit is contained in:
Ad Schellevis 2019-04-12 14:53:03 +02:00
parent 21f3607085
commit a6340f8032

View File

@ -310,4 +310,23 @@ class Gateways
return false;
}
/**
* @param string $name gateway name
* @return string|null gateway address
*/
public function getAddress($name)
{
foreach ($this->getGateways() as $gateway) {
if ($gateway['name'] == $name && !empty($gateway['gateway'])){
$result = $gateway['gateway'];
if (strtolower(substr($gateway['gateway'], 0, 5)) == "fe80:") {
// link local, suffix interface
$result .= "%{$gw['if']}";
}
return $result;
}
}
return null;
}
}