commit 68f4c29: [Minor] Jitter min age for hashes

Vsevolod Stakhov vsevolod at highsecure.ru
Sat Mar 20 19:49:05 UTC 2021


Author: Vsevolod Stakhov
Date: 2021-03-20 19:47:22 +0000
URL: https://github.com/rspamd/rspamd/commit/68f4c290ed18e91c3c0eb1afae41bf6a0303396f (HEAD -> master)

[Minor] Jitter min age for hashes

---
 src/fuzzy_storage.c | 9 +++++++--
 1 file 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 */


More information about the Commits mailing list