diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-03-20 19:47:22 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-03-20 19:47:22 +0000 |
commit | 68f4c290ed18e91c3c0eb1afae41bf6a0303396f (patch) | |
tree | 0d2852fbbfe02d7e077d65f6cf12b41833a3809d /src/fuzzy_storage.c | |
parent | b8ea7f6b08f780a0463390934682a5e9cc5860df (diff) | |
download | rspamd-68f4c290ed18e91c3c0eb1afae41bf6a0303396f.tar.gz rspamd-68f4c290ed18e91c3c0eb1afae41bf6a0303396f.zip |
[Minor] Jitter min age for hashes
Diffstat (limited to 'src/fuzzy_storage.c')
-rw-r--r-- | src/fuzzy_storage.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index 316e19d0e..d710de172 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -906,10 +906,15 @@ rspamd_fuzzy_check_callback (struct rspamd_fuzzy_reply *result, void *ud) } if (!isnan (session->ctx->delay) && - rspamd_get_calendar_ticks () - result->ts < session->ctx->delay && rspamd_match_radix_map_addr (session->ctx->delay_whitelist, session->addr) == NULL) { - send_flags |= RSPAMD_FUZZY_REPLY_DELAY; + gdouble hash_age = rspamd_get_calendar_ticks () - result->ts; + gdouble jittered_age = rspamd_time_jitter (session->ctx->delay, + session->ctx->delay / 2.0); + + if (hash_age < jittered_age) { + send_flags |= RSPAMD_FUZZY_REPLY_DELAY; + } } /* Refresh hash if found with strong confidence */ |