mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 00:24:40 +00:00
interfaces: shorten list() action where we can
This commit is contained in:
parent
18e87a510b
commit
00a86f74db
@ -4053,7 +4053,7 @@ function get_interfaces_info($include_unlinked = false)
|
||||
}
|
||||
|
||||
if (!empty($ifinfo['ipv4'])) {
|
||||
list ($primary4, $unused, $bits4) = interfaces_primary_address($ifdescr, $all_intf_details);
|
||||
list ($primary4,, $bits4) = interfaces_primary_address($ifdescr, $all_intf_details);
|
||||
if (!empty($primary4)) {
|
||||
$ifinfo['ipaddr'] = $primary4;
|
||||
$ifinfo['subnet'] = $bits4;
|
||||
@ -4072,7 +4072,7 @@ function get_interfaces_info($include_unlinked = false)
|
||||
}
|
||||
|
||||
if (!empty($ifinfo['ipv6'])) {
|
||||
list ($primary6, $unused, $bits6) = interfaces_primary_address6($ifdescr, $all_intf_details);
|
||||
list ($primary6,, $bits6) = interfaces_primary_address6($ifdescr, $all_intf_details);
|
||||
if (!empty($primary6)) {
|
||||
$ifinfo['ipaddrv6'] = $primary6;
|
||||
$ifinfo['subnetv6'] = $bits6;
|
||||
|
||||
@ -309,7 +309,7 @@ function dhcpd_radvd_configure($verbose = false, $blacklist = array())
|
||||
|
||||
$stanzas = [];
|
||||
|
||||
list ($unused, $networkv6) = interfaces_primary_address6($dhcpv6if, $ifconfig_details);
|
||||
list (, $networkv6) = interfaces_primary_address6($dhcpv6if, $ifconfig_details);
|
||||
if (is_subnetv6($networkv6)) {
|
||||
$stanzas[] = $networkv6;
|
||||
}
|
||||
@ -1732,7 +1732,7 @@ function dhcpd_dhcrelay4_configure($verbose = false)
|
||||
|
||||
/* XXX runs multiple times because of server address loop :( */
|
||||
foreach (array_keys($iflist) as $ifname) {
|
||||
list ($unused, $subnet) = interfaces_primary_address($ifname, $ifconfig_details);
|
||||
list (, $subnet) = interfaces_primary_address($ifname, $ifconfig_details);
|
||||
if (!is_subnetv4($subnet)) {
|
||||
continue;
|
||||
}
|
||||
@ -1855,7 +1855,7 @@ function dhcpd_dhcrelay6_configure($verbose = false)
|
||||
|
||||
/* XXX runs multiple times because of server address loop :( */
|
||||
foreach (array_keys($iflist) as $ifname) {
|
||||
list ($unused, $subnet) = interfaces_primary_address6($ifname, $ifconfig_details);
|
||||
list (, $subnet) = interfaces_primary_address6($ifname, $ifconfig_details);
|
||||
if (!is_subnetv6($subnet)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -547,10 +547,10 @@ function ipsec_idinfo_to_cidr(&$idinfo, $addrbits = false, $mode = '')
|
||||
$mode = $idinfo['mode'];
|
||||
}
|
||||
if ($mode == 'tunnel6') {
|
||||
list ($unused, $network) = interfaces_primary_address6($idinfo['type']);
|
||||
list (, $network) = interfaces_primary_address6($idinfo['type']);
|
||||
return $network;
|
||||
} else {
|
||||
list ($unused, $network) = interfaces_primary_address($idinfo['type']);
|
||||
list (, $network) = interfaces_primary_address($idinfo['type']);
|
||||
return $network;
|
||||
}
|
||||
break; /* NOTREACHED */
|
||||
|
||||
@ -601,7 +601,7 @@ function openvpn_reconfigure($mode, $settings, $device_only = false)
|
||||
strcmp($settings['serverbridge_interface'], "none")
|
||||
) {
|
||||
/* XXX emulates older code, but does VIP support make sense here anyway? */
|
||||
list ($biface_ip, $unused, $biface_sn) = interfaces_primary_address(explode('_vip', $settings['serverbridge_interface'])[0]);
|
||||
list ($biface_ip,, $biface_sn) = interfaces_primary_address(explode('_vip', $settings['serverbridge_interface'])[0]);
|
||||
if (
|
||||
is_ipaddrv4($biface_ip) && is_ipaddrv4($settings['serverbridge_dhcp_start']) &&
|
||||
is_ipaddrv4($settings['serverbridge_dhcp_end'])
|
||||
|
||||
@ -482,7 +482,7 @@ function system_default_route($gateway, $family, $interface, $far = false)
|
||||
log_error("ROUTING: creating /tmp/{$realif}_defaultgw using '{$gateway}'");
|
||||
@file_put_contents("/tmp/{$realif}_defaultgw", $gateway);
|
||||
|
||||
list ($unused, $network) = interfaces_primary_address($interface);
|
||||
list (, $network) = interfaces_primary_address($interface);
|
||||
if (!$far && ip_in_subnet($gateway, $network)) {
|
||||
$realif = null;
|
||||
} else {
|
||||
|
||||
@ -91,7 +91,7 @@ foreach ($iflist as $ifname => $ifcfg) {
|
||||
$network = $ifdetails[$realif]['ipv4'][0]['ipaddr'] . "/" . $ifdetails[$realif]['ipv4'][0]['subnetbits'];
|
||||
}
|
||||
|
||||
list ($primary6, $unused, $bits6) = interfaces_primary_address6($ifname, $ifdetails);
|
||||
list ($primary6,, $bits6) = interfaces_primary_address6($ifname, $ifdetails);
|
||||
$network6 = "{$primary6}/{$bits6}";
|
||||
|
||||
$tobanner = "{$ifcfg['descr']} ({$realif})";
|
||||
|
||||
@ -53,11 +53,11 @@ function deleteVIPEntry($id) {
|
||||
}
|
||||
|
||||
if (is_ipaddrv6($a_vip[$id]['subnet'])) {
|
||||
list ($unused, $if_subnet) = interfaces_primary_address6($a_vip[$id]['interface']);
|
||||
list (, $if_subnet) = interfaces_primary_address6($a_vip[$id]['interface']);
|
||||
$subnet = gen_subnetv6($a_vip[$id]['subnet'], $a_vip[$id]['subnet_bits']);
|
||||
$is_ipv6 = true;
|
||||
} else {
|
||||
list ($unused, $if_subnet) = interfaces_primary_address($a_vip[$id]['interface']);
|
||||
list (, $if_subnet) = interfaces_primary_address($a_vip[$id]['interface']);
|
||||
$subnet = gen_subnet($a_vip[$id]['subnet'], $a_vip[$id]['subnet_bits']);
|
||||
$is_ipv6 = false;
|
||||
}
|
||||
|
||||
@ -174,7 +174,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
if ((!empty($pconfig['wins1']) && !is_ipaddrv4($pconfig['wins1'])) || (!empty($pconfig['wins2']) && !is_ipaddrv4($pconfig['wins2']))) {
|
||||
$input_errors[] = gettext("A valid IP address must be specified for the primary/secondary WINS servers.");
|
||||
}
|
||||
list ($unused, $parent_net) = interfaces_primary_address($pconfig['if']);
|
||||
list (, $parent_net) = interfaces_primary_address($pconfig['if']);
|
||||
if (is_subnetv4($parent_net) && $pconfig['gateway'] && $pconfig['gateway'] != "none") {
|
||||
if (!ip_in_subnet($pconfig['gateway'], $parent_net) && !ip_in_interface_alias_subnet($pconfig['if'], $pconfig['gateway'])) {
|
||||
$input_errors[] = sprintf(gettext("The gateway address %s does not lie within the chosen interface's subnet."), $pconfig['gateway']);
|
||||
|
||||
@ -155,7 +155,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
}
|
||||
}
|
||||
|
||||
list ($unused, $parent_net) = interfaces_primary_address($if);
|
||||
list (, $parent_net) = interfaces_primary_address($if);
|
||||
|
||||
if (!empty($pconfig['ipaddr'])) {
|
||||
if (!ip_in_subnet($pconfig['ipaddr'], $parent_net)) {
|
||||
|
||||
@ -70,7 +70,7 @@ $ifcfgip = $config['interfaces'][$if]['ipaddrv6'];
|
||||
$ifcfgsn = $config['interfaces'][$if]['subnetv6'];
|
||||
|
||||
if (isset($config['interfaces'][$if]['dhcpd6track6allowoverride'])) {
|
||||
list ($ifcfgip, $unused, $ifcfgsn) = interfaces_primary_address6($if);
|
||||
list ($ifcfgip,, $ifcfgsn) = interfaces_primary_address6($if);
|
||||
$prefix_array = array();
|
||||
$prefix_array = explode(':', $ifcfgip);
|
||||
$prefix_array[4] = '0';
|
||||
|
||||
@ -238,7 +238,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
break;
|
||||
default:
|
||||
if ($pconfig['mode'] == 'tunnel') {
|
||||
list ($unused, $subnet) = interfaces_primary_address($pconfig['localid_type']);
|
||||
list (, $subnet) = interfaces_primary_address($pconfig['localid_type']);
|
||||
if (!is_subnetv4($subnet)) {
|
||||
$input_errors[] = sprintf(
|
||||
gettext('Invalid local network: %s has no valid IPv4 network.'),
|
||||
@ -246,7 +246,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
);
|
||||
}
|
||||
} elseif ($pconfig['mode'] == 'tunnel6') {
|
||||
list ($unused, $subnet) = interfaces_primary_address6($pconfig['localid_type']);
|
||||
list (, $subnet) = interfaces_primary_address6($pconfig['localid_type']);
|
||||
if (!is_subnetv6($subnet)) {
|
||||
$input_errors[] = sprintf(
|
||||
gettext('Invalid local network: %s has no valid IPv6 network.'),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user