diff options
-rw-r--r-- | src/fuzzy_storage.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c index ad1697dc1..770f428ad 100644 --- a/src/fuzzy_storage.c +++ b/src/fuzzy_storage.c @@ -138,6 +138,7 @@ struct fuzzy_key { double burst; double rate; ev_tstamp expire; + bool expired; ref_entry_t ref; }; @@ -1599,6 +1600,30 @@ rspamd_fuzzy_process_command(struct fuzzy_session *session) } } + if (session->key && !isnan(session->key->expire)) { + /* Check expire */ + static ev_tstamp today = NAN; + + if (isnan(today)) { + today = ev_time(); + } + else if (rspamd_random_uint64_fast() > 0xFFFF000000000000ULL) { + today = ev_time(); + } + + if (today > session->key->expire) { + if (!session->key->expired) { + msg_info("key %s is expired", session->key->name); + session->key->expired = true; + } + + result.v1.value = 503; + result.v1.prob = 0.0f; + rspamd_fuzzy_make_reply(cmd, &result, session, send_flags); + return; + } + } + if (is_rate_allowed) { REF_RETAIN(session); rspamd_fuzzy_backend_check(session->ctx->backend, cmd, |