diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-11-09 14:23:34 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2023-11-09 14:23:34 +0000 |
commit | 1fbc13099ee4dbabc26be7814258db6b54bd14d4 (patch) | |
tree | e688d1890fb3cac41a86670de3305b688bde156a /src/fuzzy_storage.c | |
parent | 1e62c2b68bf06496e32fd947e3a9297facfa5708 (diff) | |
download | rspamd-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.c | 11 |
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 */ |