From 5185b6f6e8d09428da4a289495d7ad413d9edf1a Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Thu, 28 May 2026 16:44:54 +0200 Subject: [PATCH] swanctl: Add option to only list a specific connection with --list-conns --- src/swanctl/commands/list_conns.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/swanctl/commands/list_conns.c b/src/swanctl/commands/list_conns.c index 7eaf4bfe9..b6608b9d1 100644 --- a/src/swanctl/commands/list_conns.c +++ b/src/swanctl/commands/list_conns.c @@ -329,7 +329,7 @@ static int list_conns(vici_conn_t *conn) vici_req_t *req; vici_res_t *res; command_format_options_t format = COMMAND_FORMAT_NONE; - char *arg; + char *arg, *ike = NULL; int ret; while (TRUE) @@ -338,6 +338,9 @@ static int list_conns(vici_conn_t *conn) { case 'h': return command_usage(NULL); + case 'i': + ike = arg; + continue; case 'P': format |= COMMAND_FORMAT_PRETTY; /* fall through to raw */ @@ -359,6 +362,10 @@ static int list_conns(vici_conn_t *conn) return ret; } req = vici_begin("list-conns"); + if (ike) + { + vici_add_key_valuef(req, "ike", "%s", ike); + } res = vici_submit(req, conn); if (!res) { @@ -382,9 +389,10 @@ static void __attribute__ ((constructor))reg() { command_register((command_t) { list_conns, 'L', "list-conns", "list loaded configurations", - {"[--raw|--pretty]"}, + {"[--ike ] [--raw|--pretty]"}, { {"help", 'h', 0, "show usage information"}, + {"ike", 'i', 1, "filter connections by name"}, {"raw", 'r', 0, "dump raw response message"}, {"pretty", 'P', 0, "dump raw response message in pretty print"}, }