diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-18 00:10:56 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-18 00:10:56 +0100 |
commit | ab15b9a3c95d6c0d37330c96d8827ac59b2fee78 (patch) | |
tree | 70a9faf4dc79456cfa4aa804a5ce3dbe5c695024 /src/plugins | |
parent | af127078a26a41e6254d97f760c2afcfea2110ef (diff) | |
download | rspamd-ab15b9a3c95d6c0d37330c96d8827ac59b2fee78.tar.gz rspamd-ab15b9a3c95d6c0d37330c96d8827ac59b2fee78.zip |
Remove legacy fuzzy code completely.
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/fuzzy_check.c | 57 |
1 files changed, 22 insertions, 35 deletions
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index ec849da54..857033ec0 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -563,46 +563,34 @@ fuzzy_cmd_from_text_part (struct fuzzy_rule *rule, rspamd_fstring_t *word; GArray *words; - if (legacy || part->words == NULL || part->words->len == 0) { - cmd = rspamd_mempool_alloc0 (pool, sizeof (*cmd)); + shcmd = rspamd_mempool_alloc0 (pool, sizeof (*shcmd)); - cmd->shingles_count = 0; - rspamd_strlcpy (cmd->digest, part->fuzzy->hash_pipe, sizeof (cmd->digest)); + /* + * Generate hash from all words in the part + */ + g_assert (blake2b_init_key (&st, BLAKE2B_OUTBYTES, rule->hash_key->str, + rule->hash_key->len) != -1); + words = fuzzy_preprocess_words (part, pool); - if (size != NULL) { - *size = sizeof (struct rspamd_fuzzy_cmd); - } + for (i = 0; i < words->len; i ++) { + word = &g_array_index (words, rspamd_fstring_t, i); + blake2b_update (&st, word->begin, word->len); } - else { - shcmd = rspamd_mempool_alloc0 (pool, sizeof (*shcmd)); - - /* - * Generate hash from all words in the part - */ - g_assert (blake2b_init_key (&st, BLAKE2B_OUTBYTES, rule->hash_key->str, - rule->hash_key->len) != -1); - words = fuzzy_preprocess_words (part, pool); + blake2b_final (&st, shcmd->basic.digest, sizeof (shcmd->basic.digest)); - for (i = 0; i < words->len; i ++) { - word = &g_array_index (words, rspamd_fstring_t, i); - blake2b_update (&st, word->begin, word->len); - } - blake2b_final (&st, shcmd->basic.digest, sizeof (shcmd->basic.digest)); - - msg_debug ("loading shingles with key %*xs", 16, rule->shingles_key->str); - sh = rspamd_shingles_generate (words, - rule->shingles_key->str, pool, - rspamd_shingles_default_filter, NULL); - if (sh != NULL) { - memcpy (&shcmd->sgl, sh, sizeof (shcmd->sgl)); - shcmd->basic.shingles_count = RSPAMD_SHINGLE_SIZE; - } + msg_debug ("loading shingles with key %*xs", 16, rule->shingles_key->str); + sh = rspamd_shingles_generate (words, + rule->shingles_key->str, pool, + rspamd_shingles_default_filter, NULL); + if (sh != NULL) { + memcpy (&shcmd->sgl, sh, sizeof (shcmd->sgl)); + shcmd->basic.shingles_count = RSPAMD_SHINGLE_SIZE; + } - cmd = (struct rspamd_fuzzy_cmd *)shcmd; + cmd = (struct rspamd_fuzzy_cmd *)shcmd; - if (size != NULL) { - *size = sizeof (struct rspamd_fuzzy_shingle_cmd); - } + if (size != NULL) { + *size = sizeof (struct rspamd_fuzzy_shingle_cmd); } cmd->tag = ottery_rand_uint32 (); @@ -959,7 +947,6 @@ fuzzy_generate_commands (struct rspamd_task *task, struct fuzzy_rule *rule, struct mime_part *mime_part; struct rspamd_image *image; struct rspamd_fuzzy_cmd *cmd; - gsize hashlen; guint i; GPtrArray *res; |