mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-19 19:15:22 +00:00
Routing, gateways. add getAddress() method to return a gateways address. for https://github.com/opnsense/core/issues/2279
This commit is contained in:
parent
21f3607085
commit
a6340f8032
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user