diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-01-04 13:56:29 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-01-04 13:56:29 +0000 |
commit | 3f5ca5e8b061e34b713b1a2022e46c37529751db (patch) | |
tree | bcb41fb48640e2360290177ade281a9884d5e846 | |
parent | 3099e3427614dd06081a5395b2b3edb632e2ba4a (diff) | |
download | rspamd-3f5ca5e8b061e34b713b1a2022e46c37529751db.tar.gz rspamd-3f5ca5e8b061e34b713b1a2022e46c37529751db.zip |
[Minor] Allow to flatten keypair output
-rw-r--r-- | src/fuzzy_storage.c | 3 | ||||
-rw-r--r-- | src/libcryptobox/keypair.c | 13 | ||||
-rw-r--r-- | src/libcryptobox/keypair.h | 1 |
3 files changed, 13 insertions, 4 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index bea32134f..71f63adbd 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -1882,7 +1882,8 @@ rspamd_fuzzy_stat_to_ucl (struct rspamd_fuzzy_storage_ctx *ctx, gboolean ip_stat ucl_object_insert_key (elt, ip_elt, "ips", 0, false); } - ucl_object_insert_key (elt, rspamd_keypair_to_ucl (fuzzy_key->key, RSPAMD_KEYPAIR_DUMP_NO_SECRET), + ucl_object_insert_key (elt, + rspamd_keypair_to_ucl (fuzzy_key->key, RSPAMD_KEYPAIR_DUMP_NO_SECRET|RSPAMD_KEYPAIR_DUMP_FLATTENED), "keypair", 0, false); ucl_object_insert_key (keys_obj, elt, keyname, 0, true); } diff --git a/src/libcryptobox/keypair.c b/src/libcryptobox/keypair.c index b97cd699e..2ef996527 100644 --- a/src/libcryptobox/keypair.c +++ b/src/libcryptobox/keypair.c @@ -805,9 +805,16 @@ rspamd_keypair_to_ucl (struct rspamd_cryptobox_keypair *kp, encoding = "base32"; } - ucl_out = ucl_object_typed_new (UCL_OBJECT); - elt = ucl_object_typed_new (UCL_OBJECT); - ucl_object_insert_key (ucl_out, elt, "keypair", 0, false); + if (flags & RSPAMD_KEYPAIR_DUMP_FLATTENED) { + ucl_out = ucl_object_typed_new (UCL_OBJECT); + elt = ucl_out; + } + else { + ucl_out = ucl_object_typed_new (UCL_OBJECT); + elt = ucl_object_typed_new (UCL_OBJECT); + ucl_object_insert_key (ucl_out, elt, "keypair", 0, false); + } + /* pubkey part */ keypair_out = rspamd_keypair_print (kp, diff --git a/src/libcryptobox/keypair.h b/src/libcryptobox/keypair.h index ed247e8ca..18a87d7f5 100644 --- a/src/libcryptobox/keypair.h +++ b/src/libcryptobox/keypair.h @@ -249,6 +249,7 @@ enum rspamd_keypair_dump_flags { RSPAMD_KEYPAIR_DUMP_DEFAULT = 0, RSPAMD_KEYPAIR_DUMP_HEX = 1u << 0u, RSPAMD_KEYPAIR_DUMP_NO_SECRET = 1u << 1u, + RSPAMD_KEYPAIR_DUMP_FLATTENED = 1u << 2u, }; /** |