aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-05-12 10:50:14 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-05-12 10:50:14 +0100
commit862123f88a73517b4c994b66dd8a5263f80a54dd (patch)
tree6c7ee93b76d8180f989c596599bb7231d586f3c3 /src
parentb43b4d481f10eefdb330c742624c2e30ab264381 (diff)
downloadrspamd-862123f88a73517b4c994b66dd8a5263f80a54dd.tar.gz
rspamd-862123f88a73517b4c994b66dd8a5263f80a54dd.zip
[Fix] Update stats before encryption...
Diffstat (limited to 'src')
-rw-r--r--src/fuzzy_storage.c39
1 files changed, 27 insertions, 12 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 347130c41..4146d636f 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -859,6 +859,20 @@ rspamd_fuzzy_make_reply (struct rspamd_fuzzy_cmd *cmd,
len = sizeof (session->reply.rep.v1);
}
+ /* Update stats before encryption */
+ if (cmd->cmd != FUZZY_STAT && cmd->cmd <= FUZZY_CLIENT_MAX) {
+ rspamd_fuzzy_update_stats(session->ctx,
+ session->epoch,
+ session->reply.rep.v1.prob > 0.5f,
+ flags & RSPAMD_FUZZY_REPLY_SHINGLE,
+ flags & RSPAMD_FUZZY_REPLY_DELAY,
+ session->key,
+ session->ip_stat,
+ cmd->cmd,
+ &session->reply.rep,
+ session->timestamp);
+ }
+
rspamd_cryptobox_encrypt_nm_inplace ((guchar *)&session->reply.rep,
len,
session->reply.hdr.nonce,
@@ -873,18 +887,19 @@ rspamd_fuzzy_make_reply (struct rspamd_fuzzy_cmd *cmd,
session->reply.rep.v1.value = 0;
session->reply.rep.v1.flag = 0;
}
-
- if (cmd->cmd != FUZZY_STAT && cmd->cmd <= FUZZY_CLIENT_MAX) {
- rspamd_fuzzy_update_stats(session->ctx,
- session->epoch,
- session->reply.rep.v1.prob > 0.5f,
- flags & RSPAMD_FUZZY_REPLY_SHINGLE,
- flags & RSPAMD_FUZZY_REPLY_DELAY,
- session->key,
- session->ip_stat,
- cmd->cmd,
- &session->reply.rep,
- session->timestamp);
+ if (!(flags & RSPAMD_FUZZY_REPLY_ENCRYPTED)) {
+ if (cmd->cmd != FUZZY_STAT && cmd->cmd <= FUZZY_CLIENT_MAX) {
+ rspamd_fuzzy_update_stats(session->ctx,
+ session->epoch,
+ session->reply.rep.v1.prob > 0.5f,
+ flags & RSPAMD_FUZZY_REPLY_SHINGLE,
+ flags & RSPAMD_FUZZY_REPLY_DELAY,
+ session->key,
+ session->ip_stat,
+ cmd->cmd,
+ &session->reply.rep,
+ session->timestamp);
+ }
}
}