mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 08:09:41 +00:00
interfaces: interfaces_addresses() because...
... realif can be different for IPv6.
This commit is contained in:
parent
1cf39968ad
commit
c6706805a2
@ -4645,3 +4645,50 @@ function make_ipv6_64_address($prefix, $suffix)
|
||||
|
||||
return implode(':', $prefix_array);
|
||||
}
|
||||
|
||||
function interfaces_addresses($interface)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$realifs = array();
|
||||
$result = array();
|
||||
|
||||
if ($interface == 'lo0') {
|
||||
$realifs[] = 'lo0';
|
||||
} elseif (!isset($config['interfaces'][$interface])) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
foreach (array('all', 'inet6') as $af) {
|
||||
$realif = get_real_interface($interface, $af);
|
||||
if (!empty($realif) && !in_array($realif, $realifs)) {
|
||||
$realifs[] = $realif;
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($realifs)) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$intf_details = legacy_interfaces_details();
|
||||
|
||||
foreach ($realifs as $realif) {
|
||||
foreach (array('ipv4', 'ipv6') as $proto) {
|
||||
if (empty($intf_details[$realif][$proto])) {
|
||||
continue;
|
||||
}
|
||||
foreach ($intf_details[$realif][$proto] as $address) {
|
||||
if (!empty($address['tunnel']) || empty($address['ipaddr'])) {
|
||||
continue;
|
||||
}
|
||||
$scope = '';
|
||||
if (!empty($address['link-local'])) {
|
||||
$scope = "%{$realif}";
|
||||
}
|
||||
$result[] = "{$address['ipaddr']}{$scope}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -123,16 +123,13 @@ function dnsmasq_configure_do($verbose = false)
|
||||
$addresses = array();
|
||||
|
||||
foreach ($interfaces as $interface) {
|
||||
foreach (legacy_getall_interface_addresses(get_real_interface($interface)) as $tmpaddr) {
|
||||
$tmpaddr = explode('/', $tmpaddr)[0];
|
||||
foreach (interfaces_addresses($interface) as $tmpaddr) {
|
||||
/* no support for link-local address with scope specified */
|
||||
$tmpaddr = explode('%', $tmpaddr)[0];
|
||||
if (!empty($tmpaddr)) {
|
||||
if ($interface == 'lo0' && is_ipaddrv4($tmpaddr) && $tmpaddr != '127.0.0.1') {
|
||||
continue;
|
||||
}
|
||||
$addresses[] = $tmpaddr;
|
||||
if ($interface == 'lo0' && is_ipaddrv4($tmpaddr) && $tmpaddr != '127.0.0.1') {
|
||||
continue;
|
||||
}
|
||||
$addresses[] = $tmpaddr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -187,11 +187,9 @@ function openssh_configure_do($verbose = false, $interface = '')
|
||||
$listeners = array();
|
||||
|
||||
foreach ($interfaces as $interface) {
|
||||
foreach (legacy_getall_interface_addresses(get_real_interface($interface)) as $tmpaddr) {
|
||||
$tmpaddr = explode('/', $tmpaddr)[0];
|
||||
/* no support for link-local address with scope specified */
|
||||
$tmpaddr = explode('%', $tmpaddr)[0];
|
||||
if (!empty($tmpaddr)) {
|
||||
foreach (interfaces_addresses($interface) as $tmpaddr) {
|
||||
/* link-local does not seem to be supported */
|
||||
if (strstr($tmpaddr, '%') === false && !is_linklocal($tmpaddr)) {
|
||||
$listeners[] = $tmpaddr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,18 +167,11 @@ EOF;
|
||||
$addresses = array();
|
||||
|
||||
foreach ($active_interfaces as $ubif) {
|
||||
$realif = get_real_interface($ubif);
|
||||
foreach (legacy_getall_interface_addresses($realif) as $tmpaddr) {
|
||||
$tmpaddr = explode('/', $tmpaddr)[0];
|
||||
if (!empty($tmpaddr)) {
|
||||
if ($interface == 'lo0' && is_ipaddrv4($tmpaddr) && $tmpaddr != '127.0.0.1') {
|
||||
continue;
|
||||
}
|
||||
if (is_linklocal($tmpaddr)) {
|
||||
$tmpaddr .= "%{$realif}";
|
||||
}
|
||||
$addresses[] = $tmpaddr;
|
||||
foreach (interfaces_addresses($ubif) as $tmpaddr) {
|
||||
if ($ubif == 'lo0' && is_ipaddrv4($tmpaddr) && $tmpaddr != '127.0.0.1') {
|
||||
continue;
|
||||
}
|
||||
$addresses[] = $tmpaddr;
|
||||
}
|
||||
}
|
||||
|
||||
@ -335,6 +328,7 @@ rrset-cache-size: {$rrsetcachesize}m
|
||||
{$anchor_file}
|
||||
prefetch: {$prefetch}
|
||||
prefetch-key: {$prefetch_key}
|
||||
|
||||
# Interface IP(s) to bind to
|
||||
{$bindints}
|
||||
{$outgoingints}
|
||||
|
||||
@ -59,12 +59,9 @@ function webgui_configure_do($verbose = false, $interface = '')
|
||||
$listeners = count($interfaces) ? array() : array('0.0.0.0', '::');
|
||||
|
||||
foreach ($interfaces as $interface) {
|
||||
foreach (legacy_getall_interface_addresses(get_real_interface($interface)) as $tmpaddr) {
|
||||
$tmpaddr = explode('/', $tmpaddr)[0];
|
||||
/* no support for link-local address with scope specified */
|
||||
$tmpaddr = explode('%', $tmpaddr)[0];
|
||||
foreach (interfaces_addresses($interface) as $tmpaddr) {
|
||||
/* link-local does not seem to be supported */
|
||||
if (!empty($tmpaddr) && !is_linklocal($tmpaddr)) {
|
||||
if (strstr($tmpaddr, '%') === false && !is_linklocal($tmpaddr)) {
|
||||
$listeners[] = $tmpaddr;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user