struct rspamd_hash_map_helper *skip_map;
struct fuzzy_ctx *ctx;
int lua_id;
+ gboolean server_supports_v2;
/* TCP configuration */
gboolean tcp_enabled; /* Explicitly enable TCP */
gboolean enabled;
};
+static inline uint8_t
+fuzzy_cmd_version(const struct fuzzy_rule *rule)
+{
+ if (rule->server_supports_v2) {
+ return 5; /* Native v5 after server confirmed v2 support */
+ }
+ return RSPAMD_FUZZY_VERSION | RSPAMD_FUZZY_V2_CAP; /* 4 | 0x10 = 0x14 */
+}
+
enum fuzzy_result_type {
FUZZY_RESULT_TXT,
FUZZY_RESULT_IMG,
}
}
+ if (is_v2) {
+ rule->server_supports_v2 = TRUE;
+ }
+
/* Extract tag and lookup pending command */
tag = rep->v1.tag;
khiter_t k = kh_get(fuzzy_pending_hash, rule->pending_requests, tag);
}
cmd->cmd = c;
- cmd->version = RSPAMD_FUZZY_PLUGIN_VERSION;
+ cmd->version = fuzzy_cmd_version(rule);
cmd->shingles_count = 0;
cmd->tag = ottery_rand_uint32();
cmd->cmd = FUZZY_PING;
- cmd->version = RSPAMD_FUZZY_PLUGIN_VERSION;
+ cmd->version = fuzzy_cmd_version(rule);
cmd->shingles_count = 0;
cmd->value = fuzzy_milliseconds_since_midnight(); /* Record timestamp */
cmd->tag = ottery_rand_uint32();
}
cmd->cmd = c;
- cmd->version = RSPAMD_FUZZY_PLUGIN_VERSION;
+ cmd->version = fuzzy_cmd_version(rule);
cmd->shingles_count = 0;
cmd->tag = ottery_rand_uint32();
if (!short_text) {
shcmd->basic.tag = ottery_rand_uint32();
shcmd->basic.cmd = c;
- shcmd->basic.version = RSPAMD_FUZZY_PLUGIN_VERSION;
+ shcmd->basic.version = fuzzy_cmd_version(rule);
if (c != FUZZY_CHECK) {
shcmd->basic.flag = flag;
else {
cmd->tag = ottery_rand_uint32();
cmd->cmd = c;
- cmd->version = RSPAMD_FUZZY_PLUGIN_VERSION;
+ cmd->version = fuzzy_cmd_version(rule);
if (c != FUZZY_CHECK) {
cmd->flag = flag;
shcmd->basic.tag = ottery_rand_uint32();
shcmd->basic.cmd = c;
- shcmd->basic.version = RSPAMD_FUZZY_PLUGIN_VERSION;
+ shcmd->basic.version = fuzzy_cmd_version(rule);
if (c != FUZZY_CHECK) {
shcmd->basic.flag = flag;
shcmd->basic.tag = ottery_rand_uint32 ();
shcmd->basic.cmd = c;
- shcmd->basic.version = RSPAMD_FUZZY_PLUGIN_VERSION;
+ shcmd->basic.version = fuzzy_cmd_version(rule);
if (c != FUZZY_CHECK) {
shcmd->basic.flag = flag;
}
cmd->cmd = c;
- cmd->version = RSPAMD_FUZZY_PLUGIN_VERSION;
+ cmd->version = fuzzy_cmd_version(rule);
if (c != FUZZY_CHECK) {
cmd->flag = flag;
cmd->value = weight;
while ((rep = fuzzy_process_reply(&p, &r,
session->commands, session->rule, &cmd, &io, &rep_v2)) != NULL) {
+ if (rep_v2) {
+ session->rule->server_supports_v2 = TRUE;
+ }
if (rep->v1.prob > 0.5) {
if (cmd->cmd == FUZZY_CHECK) {
fuzzy_insert_result(session, rep, cmd, io, rep->v1.flag);