summaryrefslogtreecommitdiffstats
path: root/src/fuzzy_storage.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-05-08 19:31:43 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-05-08 19:31:43 +0100
commit3b6b440518ab6cd5994afe9d9ff2e35e05f56302 (patch)
tree8bef1e5aa15e740cb63be5e188581f2f0355dd80 /src/fuzzy_storage.c
parent852a21d68ec2850f95b74a829639264ddf264f30 (diff)
downloadrspamd-3b6b440518ab6cd5994afe9d9ff2e35e05f56302.tar.gz
rspamd-3b6b440518ab6cd5994afe9d9ff2e35e05f56302.zip
[Minor] Output flags stat per key
Diffstat (limited to 'src/fuzzy_storage.c')
-rw-r--r--src/fuzzy_storage.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 37a0efe1e..dac76e6a4 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -1927,7 +1927,7 @@ rspamd_fuzzy_storage_reload (struct rspamd_main *rspamd_main,
}
static ucl_object_t *
-rspamd_fuzzy_storage_stat_key (struct fuzzy_key_stat *key_stat)
+rspamd_fuzzy_storage_stat_key (const struct fuzzy_key_stat *key_stat)
{
ucl_object_t *res;
@@ -1990,6 +1990,19 @@ rspamd_fuzzy_stat_to_ucl (struct rspamd_fuzzy_storage_ctx *ctx, gboolean ip_stat
ucl_object_insert_key (elt, ip_elt, "ips", 0, false);
}
+ int flag;
+ struct fuzzy_key_stat *flag_stat;
+ ucl_object_t *flags_ucl = ucl_object_typed_new(UCL_OBJECT);
+
+ kh_foreach_key_value_ptr(fuzzy_key->flags_stat, flag, flag_stat, {
+ char intbuf[16];
+ rspamd_snprintf(intbuf, sizeof(intbuf), "%d", flag);
+ ucl_object_insert_key (flags_ucl, rspamd_fuzzy_storage_stat_key (flag_stat),
+ intbuf, 0, true);
+ });
+
+ ucl_object_insert_key (elt, flags_ucl, "flags", 0, false);
+
ucl_object_insert_key (elt,
rspamd_keypair_to_ucl (fuzzy_key->key, RSPAMD_KEYPAIR_DUMP_NO_SECRET|RSPAMD_KEYPAIR_DUMP_FLATTENED),
"keypair", 0, false);