]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
json: Print single synproxy flags as non-array
authorPhil Sutter <phil@nwl.cc>
Thu, 8 May 2025 14:44:39 +0000 (16:44 +0200)
committerPhil Sutter <phil@nwl.cc>
Tue, 13 May 2025 08:48:53 +0000 (10:48 +0200)
Signed-off-by: Phil Sutter <phil@nwl.cc>
src/json.c

index a8b0abeba6396f7d10750c19e79ca1c4c69896f6..0034c02f678ff3290d20b1cb12fa9164a32f70b6 100644 (file)
@@ -1686,10 +1686,14 @@ json_t *synproxy_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
        if (stmt->synproxy.flags & NF_SYNPROXY_OPT_SACK_PERM)
                json_array_append_new(flags, json_string("sack-perm"));
 
-       if (json_array_size(flags) > 0)
+       if (json_array_size(flags) > 1) {
                json_object_set_new(root, "flags", flags);
-       else
+       } else {
+               if (json_array_size(flags))
+                       json_object_set(root, "flags",
+                                       json_array_get(flags, 0));
                json_decref(flags);
+       }
 
        if (!json_object_size(root)) {
                json_decref(root);