]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Jitter min age for hashes
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 Mar 2021 19:47:22 +0000 (19:47 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sat, 20 Mar 2021 19:47:22 +0000 (19:47 +0000)
src/fuzzy_storage.c

index 316e19d0eb53a2256c542f71e24fc76d3719325e..d710de17239842db39cd13a1a6e90f0433472e4c 100644 (file)
@@ -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 */