mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 09:34:39 +00:00
interfaces: separate the use cases of get_configured_carp_interface_list()
Pages only call these to get lists but get_interface_ip*() functions want a specific one. Handroll these cases and simplify the other end. PR: https://github.com/opnsense/core/pull/5185
This commit is contained in:
parent
d963858af6
commit
65178b937c
@ -3972,7 +3972,13 @@ function ip_in_interface_alias_subnet($interface, $ipalias)
|
||||
function get_interface_ip($interface = 'wan', $ifconfig_details = null)
|
||||
{
|
||||
if (strstr($interface, '_vip')) {
|
||||
return get_configured_carp_interface_list($interface);
|
||||
foreach (config_read_array('virtualip', 'vip') as $vip) {
|
||||
if ($vip['mode'] == 'carp') {
|
||||
if ($interface == "{$vip['interface']}_vip{$vip['vhid']}" && is_ipaddrv4($vip['subnet'])) {
|
||||
return $vip['subnet'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list ($ip) = interfaces_primary_address($interface, $ifconfig_details);
|
||||
@ -3983,7 +3989,13 @@ function get_interface_ip($interface = 'wan', $ifconfig_details = null)
|
||||
function get_interface_ipv6($interface = 'wan', $ifconfig_details = null)
|
||||
{
|
||||
if (strstr($interface, '_vip')) {
|
||||
return get_configured_carp_interface_list($interface, 'inet6');
|
||||
foreach (config_read_array('virtualip', 'vip') as $vip) {
|
||||
if ($vip['mode'] == 'carp') {
|
||||
if ($interface == "{$vip['interface']}_vip{$vip['vhid']}" && is_ipaddrv6($vip['subnet'])) {
|
||||
return $vip['subnet'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
list ($ipv6) = interfaces_primary_address6($interface, $ifconfig_details);
|
||||
|
||||
@ -753,35 +753,22 @@ function is_inrange($test, $start, $end)
|
||||
return is_ipaddrv6($test) ? is_inrange_v6($test, $start, $end) : is_inrange_v4($test, $start, $end);
|
||||
}
|
||||
|
||||
/* XXX: return the configured carp interface list */
|
||||
function get_configured_carp_interface_list($carpinterface = '', $family = 'inet')
|
||||
function get_configured_carp_interface_list()
|
||||
{
|
||||
$iflist = array();
|
||||
$carp_list = [];
|
||||
|
||||
foreach (config_read_array('virtualip', 'vip') as $vip) {
|
||||
switch ($vip['mode']) {
|
||||
case 'carp':
|
||||
if (!empty($carpinterface)) {
|
||||
if ($carpinterface == "{$vip['interface']}_vip{$vip['vhid']}") {
|
||||
if ($family == 'inet' && is_ipaddrv4($vip['subnet'])) {
|
||||
return $vip['subnet'];
|
||||
} elseif ($family == 'inet6' && is_ipaddrv6($vip['subnet'])) {
|
||||
return $vip['subnet'];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$iflist["{$vip['interface']}_vip{$vip['vhid']}"] = $vip['subnet'];
|
||||
}
|
||||
break;
|
||||
if ($vip['mode'] == 'carp') {
|
||||
$carp_list["{$vip['interface']}_vip{$vip['vhid']}"] = $vip['subnet'];
|
||||
}
|
||||
}
|
||||
|
||||
return $iflist;
|
||||
return $carp_list;
|
||||
}
|
||||
|
||||
function get_configured_ip_aliases_list()
|
||||
{
|
||||
$alias_list = array();
|
||||
$alias_list = [];
|
||||
|
||||
foreach (config_read_array('virtualip', 'vip') as $vip) {
|
||||
if ($vip['mode'] == 'ipalias') {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user