aboutsummaryrefslogtreecommitdiffstats
path: root/src/fuzzy_storage.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-11-09 14:23:34 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-11-09 14:23:34 +0000
commit1fbc13099ee4dbabc26be7814258db6b54bd14d4 (patch)
treee688d1890fb3cac41a86670de3305b688bde156a /src/fuzzy_storage.c
parent1e62c2b68bf06496e32fd947e3a9297facfa5708 (diff)
downloadrspamd-1fbc13099ee4dbabc26be7814258db6b54bd14d4.tar.gz
rspamd-1fbc13099ee4dbabc26be7814258db6b54bd14d4.zip
[Feature] Support ping command in fuzzy storage
Diffstat (limited to 'src/fuzzy_storage.c')
-rw-r--r--src/fuzzy_storage.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/fuzzy_storage.c b/src/fuzzy_storage.c
index 23a4f45cd..5adf54e46 100644
--- a/src/fuzzy_storage.c
+++ b/src/fuzzy_storage.c
@@ -1337,6 +1337,17 @@ rspamd_fuzzy_process_command(struct fuzzy_session *session)
result.v1.flag = session->ctx->stat.fuzzy_hashes;
rspamd_fuzzy_make_reply(cmd, &result, session, send_flags);
}
+ else if (cmd->cmd == FUZZY_PING) {
+ /* Obtain milliseconds since midnight */
+ double now = rspamd_get_calendar_ticks();
+ double millis = now - (int64_t) now;
+ now = ((int64_t) now % 86400) + millis;
+
+ result.v1.prob = 1.0f;
+ result.v1.flag = now * 1000;
+ result.v1.value = result.v1.flag - cmd->value; /* This is transmitted time from our PoV */
+ rspamd_fuzzy_make_reply(cmd, &result, session, send_flags);
+ }
else {
if (rspamd_fuzzy_check_write(session)) {
/* Check whitelist */