summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-10-19 20:35:27 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-10-19 20:35:27 +0400
commit966ffa12854e46ede0e1fe67fa5d02345b6e99a0 (patch)
tree377f3c79bab3ce1166797d6514776639aa47456d /src
parentf2fa5e52e91742bcb3111f154ead19fa2f9cf830 (diff)
downloadrspamd-966ffa12854e46ede0e1fe67fa5d02345b6e99a0.tar.gz
rspamd-966ffa12854e46ede0e1fe67fa5d02345b6e99a0.zip
* Do not really check messages that should be skipped
* Add Skip state for such messages (not False and not True)
Diffstat (limited to 'src')
-rw-r--r--src/filter.c18
-rw-r--r--src/main.h1
-rw-r--r--src/protocol.c31
-rw-r--r--src/view.c13
-rw-r--r--src/view.h1
5 files changed, 58 insertions, 6 deletions
diff --git a/src/filter.c b/src/filter.c
index fefdd968c..fc23d81b9 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -35,6 +35,7 @@
#include "util.h"
#include "expressions.h"
#include "settings.h"
+#include "view.h"
#include "classifiers/classifiers.h"
#include "tokenizers/tokenizers.h"
@@ -311,8 +312,17 @@ process_filters (struct worker_task *task)
task->save.saved = 0;
return continue_process_filters (task);
}
+ /* Check skip */
+ if (check_skip (task->cfg->views, task)) {
+ task->is_skipped = TRUE;
+ task->state = WRITE_REPLY;
+ msg_info ("process_filters: disable check for message id <%s>, view wants spam", task->message_id);
+ return 1;
+ }
/* Check want spam setting */
if (check_want_spam (task)) {
+ task->is_skipped = TRUE;
+ task->state = WRITE_REPLY;
msg_info ("process_filters: disable check for message id <%s>, user wants spam", task->message_id);
return 1;
}
@@ -527,6 +537,8 @@ classifiers_callback (gpointer value, void *arg)
f_str_t c;
cur = g_list_first (task->text_parts);
+ ctx = cl->classifier->init_func (task->task_pool, cl);
+
if ((tokens = g_hash_table_lookup (data->tokens, cl->tokenizer)) == NULL) {
while (cur != NULL) {
text_part = (struct mime_text_part *)cur->data;
@@ -550,7 +562,6 @@ classifiers_callback (gpointer value, void *arg)
return;
}
- ctx = cl->classifier->init_func (task->task_pool, cl);
cl->classifier->classify_func (ctx, task->worker->srv->statfile_pool, tokens, task);
/* Autolearning */
@@ -572,7 +583,10 @@ void
process_statfiles (struct worker_task *task)
{
struct statfile_callback_data cd;
-
+
+ if (task->is_skipped) {
+ return;
+ }
cd.task = task;
cd.tokens = g_hash_table_new (g_direct_hash, g_direct_equal);
diff --git a/src/main.h b/src/main.h
index 00b2d22bc..35ea627be 100644
--- a/src/main.h
+++ b/src/main.h
@@ -174,6 +174,7 @@ struct worker_task {
struct custom_command *custom_cmd; /**< custom command if any */
int sock; /**< socket descriptor */
gboolean is_mime; /**< if this task is mime task */
+ gboolean is_skipped; /**< whether message was skipped by configuration */
char *helo; /**< helo header value */
char *from; /**< from header value */
char *queue_id; /**< queue id if specified */
diff --git a/src/protocol.c b/src/protocol.c
index cb6966632..3758de8a2 100644
--- a/src/protocol.c
+++ b/src/protocol.c
@@ -540,13 +540,23 @@ show_metric_result (gpointer metric_name, gpointer metric_value, void *user_data
}
else {
if (strcmp (task->proto_ver, RSPAMC_PROTO_1_1) == 0) {
- r = snprintf (outbuf, sizeof (outbuf), "Metric: default; False; 0 / %.2f / %.2f" CRLF, ms, rs);
+ if (!task->is_skipped) {
+ r = snprintf (outbuf, sizeof (outbuf), "Metric: default; False; 0 / %.2f / %.2f" CRLF, ms, rs);
+ }
+ else {
+ r = snprintf (outbuf, sizeof (outbuf), "Metric: default; Skip; 0 / %.2f / %.2f" CRLF, ms, rs);
+ }
}
else {
r = snprintf (outbuf, sizeof (outbuf), "Metric: default; False; 0 / %.2f" CRLF, ms);
}
}
- cd->log_offset += snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "(%s: F: [0/%.2f/%.2f] [", "default", ms, rs);
+ if (!task->is_skipped) {
+ cd->log_offset += snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "(%s: F: [0/%.2f/%.2f] [", "default", ms, rs);
+ }
+ else {
+ cd->log_offset += snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "(%s: S: [0/%.2f/%.2f] [", "default", ms, rs);
+ }
}
else {
if (!check_metric_settings (task, metric_res->metric, &ms, &rs)) {
@@ -561,16 +571,29 @@ show_metric_result (gpointer metric_name, gpointer metric_value, void *user_data
}
else {
if (strcmp (task->proto_ver, RSPAMC_PROTO_1_1) == 0) {
- r = snprintf (outbuf, sizeof (outbuf), "Metric: %s; %s; %.2f / %.2f / %.2f" CRLF,
+ if (!task->is_skipped) {
+ r = snprintf (outbuf, sizeof (outbuf), "Metric: %s; %s; %.2f / %.2f / %.2f" CRLF,
(char *)metric_name, (is_spam) ? "True" : "False", metric_res->score, ms, rs);
+ }
+ else {
+ r = snprintf (outbuf, sizeof (outbuf), "Metric: %s; Skip; %.2f / %.2f / %.2f" CRLF,
+ (char *)metric_name, metric_res->score, ms, rs);
+ }
}
else {
r = snprintf (outbuf, sizeof (outbuf), "Metric: %s; %s; %.2f / %.2f" CRLF,
(char *)metric_name, (is_spam) ? "True" : "False", metric_res->score, ms);
}
}
- cd->log_offset += snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "(%s: %s: [%.2f/%.2f/%.2f] [",
+ if (!task->is_skipped) {
+ cd->log_offset += snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "(%s: %s: [%.2f/%.2f/%.2f] [",
(char *)metric_name, is_spam ? "T" : "F", metric_res->score, ms, rs);
+ }
+ else {
+ cd->log_offset += snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "(%s: %s: [%.2f/%.2f/%.2f] [",
+ (char *)metric_name, "S", metric_res->score, ms, rs);
+
+ }
}
if (task->cmd == CMD_PROCESS) {
#ifndef GMIME24
diff --git a/src/view.c b/src/view.c
index 393882049..0f9aefcf7 100644
--- a/src/view.c
+++ b/src/view.c
@@ -163,6 +163,10 @@ match_view_symbol (struct rspamd_view *v, const char *symbol)
GList *cur;
struct rspamd_regexp *re;
+ /* Special case */
+ if (symbol == NULL) {
+ return TRUE;
+ }
/* First try to lookup in hashtable */
if (g_hash_table_lookup (v->symbols_hash, symbol) != NULL) {
return TRUE;
@@ -218,3 +222,12 @@ check_view (GList * views, const char *symbol, struct worker_task * task)
return FALSE;
}
+
+gboolean
+check_skip (GList * views, struct worker_task * task)
+{
+ if (check_view (views, NULL, task) == FALSE) {
+ return TRUE;
+ }
+ return FALSE;
+}
diff --git a/src/view.h b/src/view.h
index 91a5d6277..9114c6393 100644
--- a/src/view.h
+++ b/src/view.h
@@ -25,5 +25,6 @@ gboolean add_view_ip (struct rspamd_view *view, char *line);
gboolean add_view_symbols (struct rspamd_view *view, char *line);
gboolean check_view (GList *views, const char *symbol, struct worker_task *task);
+gboolean check_skip (GList *views, struct worker_task *task);
#endif