diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-12-17 18:29:33 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2014-12-17 18:29:33 +0000 |
commit | 491f27d645695c3db05054d8674a212fc819dbff (patch) | |
tree | 9b9a53a99da0ea25021f49c3acc0aa4e7c7a83cf /src/libutil/shingles.c | |
parent | e771cd9604aca7831495e2cb04592ae9ebc9eba8 (diff) | |
download | rspamd-491f27d645695c3db05054d8674a212fc819dbff.tar.gz rspamd-491f27d645695c3db05054d8674a212fc819dbff.zip |
Tune shingles settings.
Diffstat (limited to 'src/libutil/shingles.c')
-rw-r--r-- | src/libutil/shingles.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libutil/shingles.c b/src/libutil/shingles.c index 653fa5356..3775b9e16 100644 --- a/src/libutil/shingles.c +++ b/src/libutil/shingles.c @@ -25,7 +25,7 @@ #include "fstring.h" #include "siphash.h" -#define SHINGLES_WINDOW 10 +#define SHINGLES_WINDOW 3 static void rspamd_shingles_update_row (rspamd_fstring_t *in, struct siphash *h) @@ -84,6 +84,7 @@ rspamd_shingles_generate (GArray *input, g_checksum_reset (cksum); cur_key = out_key; out_key += 16; + memset (&h[i], 0, sizeof (h[0])); sip24_init (&h[i], &keys[i]); } @@ -96,15 +97,17 @@ rspamd_shingles_generate (GArray *input, rspamd_shingles_update_row (&g_array_index (input, rspamd_fstring_t, j), h); } + beg++; /* Now we need to create a new row here */ for (j = 0; j < RSPAMD_SHINGLE_SIZE; j ++) { guint64 val; - val = sip24_final (&h[i]); + val = sip24_final (&h[j]); /* Reinit siphash state */ - sip24_init (&h[i], &keys[i]); - g_array_append_val (hashes[i], val); + memset (&h[j], 0, sizeof (h[0])); + sip24_init (&h[j], &keys[j]); + g_array_append_val (hashes[j], val); } } } @@ -148,5 +151,5 @@ gdouble rspamd_shingles_compare (const struct rspamd_shingle *a, } } - return (gdouble)common / 84.0; + return (gdouble)common / (gdouble)RSPAMD_SHINGLE_SIZE; } |