mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 00:24:40 +00:00
interfaces: move function to only caller
This commit is contained in:
parent
6759113b9d
commit
07e1223e34
@ -3571,48 +3571,6 @@ function get_real_interface($interface = 'wan', $family = 'all')
|
||||
return $realif;
|
||||
}
|
||||
|
||||
function guess_interface_from_ip($ipaddress)
|
||||
{
|
||||
if (is_ipaddrv4($ipaddress)) {
|
||||
$family = "inet";
|
||||
} elseif (is_ipaddrv6($ipaddress)) {
|
||||
$family = "inet6";
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* create a route table we can search */
|
||||
exec("/usr/bin/netstat -rnWf " . $family, $output, $ret);
|
||||
|
||||
/* search for the route with the largest subnet mask */
|
||||
$largest_mask = 0;
|
||||
$best_if = null;
|
||||
|
||||
foreach ($output as $line) {
|
||||
$fields = preg_split("/\s+/", $line);
|
||||
if (is_subnet($fields[0])) {
|
||||
if (ip_in_subnet($ipaddress, $fields[0])) {
|
||||
list($ip, $mask) = explode('/', $fields[0]);
|
||||
if ($mask > $largest_mask) {
|
||||
$best_if = $fields[5];
|
||||
$largest_mask = $mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($best_if)) {
|
||||
return $best_if;
|
||||
}
|
||||
|
||||
$ret = shell_safe('/sbin/route -n get %s | /usr/bin/awk \'/interface/ { print $2; };\'', $ipaddress);
|
||||
if (empty($ret)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function get_interface_number_track6($wanif, $targetif)
|
||||
{
|
||||
$list = link_interface_to_track6($wanif);
|
||||
|
||||
@ -40,6 +40,48 @@ require_once("XMLRPC_Client.inc");
|
||||
|
||||
exit_on_bootup();
|
||||
|
||||
function guess_interface_from_ip($ipaddress)
|
||||
{
|
||||
if (is_ipaddrv4($ipaddress)) {
|
||||
$family = "inet";
|
||||
} elseif (is_ipaddrv6($ipaddress)) {
|
||||
$family = "inet6";
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* create a route table we can search */
|
||||
exec("/usr/bin/netstat -rnWf " . $family, $output, $ret);
|
||||
|
||||
/* search for the route with the largest subnet mask */
|
||||
$largest_mask = 0;
|
||||
$best_if = null;
|
||||
|
||||
foreach ($output as $line) {
|
||||
$fields = preg_split("/\s+/", $line);
|
||||
if (is_subnet($fields[0])) {
|
||||
if (ip_in_subnet($ipaddress, $fields[0])) {
|
||||
list($ip, $mask) = explode('/', $fields[0]);
|
||||
if ($mask > $largest_mask) {
|
||||
$best_if = $fields[5];
|
||||
$largest_mask = $mask;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($best_if)) {
|
||||
return $best_if;
|
||||
}
|
||||
|
||||
$ret = shell_safe('/sbin/route -n get %s | /usr/bin/awk \'/interface/ { print $2; };\'', $ipaddress);
|
||||
if (empty($ret)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* fetch carp vips from config with modified advskew for the backup host to use
|
||||
* @return array
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user