diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-26 22:15:11 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-07-26 22:15:11 +0100 |
commit | f21d8633f6117949473f6e6a28490fdb0fea81c6 (patch) | |
tree | 6d277363dcf8cc279e571ea36f5fdab46e698af8 /src/libstat | |
parent | 277ffc972d161a0928bc07c2e5d110b00115744c (diff) | |
download | rspamd-f21d8633f6117949473f6e6a28490fdb0fea81c6.tar.gz rspamd-f21d8633f6117949473f6e6a28490fdb0fea81c6.zip |
Use some headers information in statistics.
Diffstat (limited to 'src/libstat')
-rw-r--r-- | src/libstat/stat_process.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/libstat/stat_process.c b/src/libstat/stat_process.c index 458c42cad..cd7c504c6 100644 --- a/src/libstat/stat_process.c +++ b/src/libstat/stat_process.c @@ -298,6 +298,44 @@ rspamd_stat_preprocess (struct rspamd_stat_ctx *st_ctx, return cl_runtimes; } +static void +rspamd_stat_tokenize_header (struct rspamd_tokenizer_config *cf, + struct rspamd_task *task, struct rspamd_tokenizer_runtime *tok, + const gchar *name, const gchar *prefix) +{ + struct raw_header *rh, *cur; + GArray *ar; + rspamd_fstring_t str; + + rh = g_hash_table_lookup (task->raw_headers, name); + + if (rh != NULL) { + ar = g_array_sized_new (FALSE, FALSE, sizeof (str), 4); + + LL_FOREACH (rh, cur) { + if (cur->value != NULL) { + str.begin = cur->value; + str.len = strlen (cur->value); + g_array_append_val (ar, str); + } + if (cur->decoded != NULL) { + str.begin = cur->decoded; + str.len = strlen (cur->decoded); + g_array_append_val (ar, str); + } + } + + tok->tokenizer->tokenize_func (cf, + task->task_pool, + ar, + tok->tokens, + TRUE, + prefix); + + g_array_free (ar, TRUE); + } +} + /* * Tokenize task using the tokenizer specified */ @@ -347,6 +385,11 @@ rspamd_stat_process_tokenize (struct rspamd_tokenizer_config *cf, g_array_free (words, TRUE); } } + + rspamd_stat_tokenize_header (cf, task, tok, "User-Agent", "UA:"); + rspamd_stat_tokenize_header (cf, task, tok, "X-Mailer", "XM:"); + rspamd_stat_tokenize_header (cf, task, tok, "Content-Type", "CT:"); + rspamd_stat_tokenize_header (cf, task, tok, "X-MimeOLE", "XMOLE:"); } |