Skip to content

Commit

Permalink
Routing, gateways. add getAddress() method to return a gateways addre…
Browse files Browse the repository at this point in the history
…ss. for #2279
  • Loading branch information
AdSchellevis committed Apr 12, 2019
1 parent 21f3607 commit a6340f8
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/opnsense/mvc/app/library/OPNsense/Routing/Gateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,4 +310,23 @@ public function hasGateways($ipproto)
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;
}

}

0 comments on commit a6340f8

Please sign in to comment.