interfaces: tried keys before but list() is too dense

This commit is contained in:
Franco Fichtner 2023-09-18 10:52:40 +02:00
parent db5c43d106
commit 2a6845a6fb
2 changed files with 9 additions and 3 deletions

View File

@ -4394,8 +4394,7 @@ function interfaces_primary_address($interface, $ifconfig_details = null)
break; /* all done */
}
/* DO NOT REORDER */
return [ 'address' => $ifcfgip, 'network' => $network, 'bits' => $subnetbits, 'device' => $device ];
return [ $ifcfgip, $network, $subnetbits, $device ];
}
function _interfaces_primary_address6($interface, $ifconfig_details = null, $allow_track = true, $link_local = false)

View File

@ -162,7 +162,14 @@ if (isset($opts['h'])) {
echo "\t-S service metadata dump\n";
echo "\t-s service mode (e.g. myservice restart)\n";
} elseif (isset($opts['4'])) {
echo json_encode(interfaces_primary_address($args[0] ?? null), JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT) . PHP_EOL;
$raw = interfaces_primary_address($args[0] ?? null);
$ret = [
'address' => $raw[0],
'network' => $raw[1],
'bits' => $raw[2],
'device' => $raw[3],
];
echo json_encode($ret, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT) . PHP_EOL;
} elseif (isset($opts['D'])) {
echo json_encode(legacy_interfaces_details($args[0] ?? null), JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT) . PHP_EOL;
} elseif (isset($opts['d'])) {