system: patch -6 address support into pluginctl

This commit is contained in:
Franco Fichtner 2024-08-01 22:02:35 +02:00
parent 9b112c1c20
commit 12db8b5b2b

View File

@ -3,7 +3,7 @@
/*
* Copyright (C) 2019 Deciso B.V.
* Copyright (C) 2019-2023 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2019-2024 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2017 Alexander Shursha <kekek2@ya.ru>
* All rights reserved.
*
@ -148,8 +148,9 @@ $opts = getopt('46cDdfghIirSsXx', [], $optind);
$args = array_slice($argv, $optind);
if (isset($opts['h'])) {
echo "Usage: pluginctl [-4|-c|-D|-d|-f|-g|-h|-I|-i|-r|-S|-s|-X|-x] ...\n\n";
echo "Usage: pluginctl [-4|-6|-c|-D|-d|-f|-g|-h|-I|-i|-r|-S|-s|-X|-x] ...\n\n";
echo "\t-4 IPv4 address mode, return primary address of interface\n";
echo "\t-6 IPv4 address mode, return primary address of interface\n";
echo "\t-c configure mode (default), executes plugin [_configure] hook\n";
echo "\t-D ifconfig mode, lists available devices\n";
echo "\t-d device mode, lists registered devices\n";
@ -163,11 +164,11 @@ if (isset($opts['h'])) {
echo "\t-s service mode (e.g. myservice restart)\n";
echo "\t-X XMLRPC sync metadata dump\n";
echo "\t-x XMLRPC sync key/value list\n";
} elseif (isset($opts['4'])) {
} elseif (isset($opts['4']) || isset($opts['6'])) {
$int = $args[0] ?? '';
$ret = [];
if (!empty($config['interfaces'][$int])) {
$raw = interfaces_primary_address($int);
$raw = isset($opts['4']) ? interfaces_primary_address($int) : interfaces_primary_address6($int);
$ret = [
'address' => $raw[0],
'network' => $raw[1],