diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-07-15 18:23:22 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2010-07-15 18:23:22 +0400 |
commit | ecbbd935773673d8df1f2cb8334b447f7b834b5a (patch) | |
tree | f97a716b471f52c3f6e05347c1e7866d497868a4 /src | |
parent | 99cd57ba7f0e6b9178ccacc6987b0854ed137d83 (diff) | |
download | rspamd-ecbbd935773673d8df1f2cb8334b447f7b834b5a.tar.gz rspamd-ecbbd935773673d8df1f2cb8334b447f7b834b5a.zip |
* Add ability to set metric's action from config file
* Fix bug with writing garbadge if message has no urls or no messages
* Fix bug with incorrect behaviour of compare_parts_distance function
Diffstat (limited to 'src')
-rw-r--r-- | src/cfg_xml.c | 27 | ||||
-rw-r--r-- | src/cfg_xml.h | 1 | ||||
-rw-r--r-- | src/expressions.c | 2 | ||||
-rw-r--r-- | src/greylist.h | 1 | ||||
-rw-r--r-- | src/protocol.c | 7 |
5 files changed, 37 insertions, 1 deletions
diff --git a/src/cfg_xml.c b/src/cfg_xml.c index aeb64d1ae..c88bf60db 100644 --- a/src/cfg_xml.c +++ b/src/cfg_xml.c @@ -261,6 +261,12 @@ static struct xml_parser_rule grammar[] = { 0, NULL }, + { + "action", + handle_metric_action, + 0, + NULL + }, NULL_ATTR }, NULL_ATTR @@ -667,6 +673,27 @@ worker_handle_bind (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GH } gboolean +handle_metric_action (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset) +{ + struct metric *metric = ctx->section_pointer; + + if (g_ascii_strcasecmp (data, "reject") == 0) { + metric->action = METRIC_ACTION_REJECT; + } + else if (g_ascii_strcasecmp (data, "greylist") == 0) { + metric->action = METRIC_ACTION_GREYLIST; + } + else if (g_ascii_strcasecmp (data, "add_header") == 0) { + metric->action = METRIC_ACTION_ADD_HEADER; + } + else { + msg_err ("unknown action for metric: %s", data); + return FALSE; + } + return TRUE; +} + +gboolean handle_metric_symbol (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset) { char *strval, *err; diff --git a/src/cfg_xml.h b/src/cfg_xml.h index b61c2f825..c91bb1779 100644 --- a/src/cfg_xml.h +++ b/src/cfg_xml.h @@ -92,6 +92,7 @@ gboolean worker_handle_type (struct config_file *cfg, struct rspamd_xml_userdata gboolean worker_handle_bind (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset); gboolean handle_metric_symbol (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset); +gboolean handle_metric_action (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset); gboolean handle_module_opt (struct config_file *cfg, struct rspamd_xml_userdata *ctx, GHashTable *attrs, gchar *data, gpointer user_data, gpointer dest_struct, int offset); diff --git a/src/expressions.c b/src/expressions.c index c4465742c..650721b9e 100644 --- a/src/expressions.c +++ b/src/expressions.c @@ -952,7 +952,7 @@ rspamd_parts_distance (struct worker_task * task, GList * args, void *unused) return FALSE; } p2 = cur->data; - if (fuzzy_compare_hashes (p1->fuzzy, p2->fuzzy) >= threshold) { + if (fuzzy_compare_hashes (p1->fuzzy, p2->fuzzy) <= threshold) { return TRUE; } } diff --git a/src/greylist.h b/src/greylist.h index b17004c2e..e113d2e94 100644 --- a/src/greylist.h +++ b/src/greylist.h @@ -43,5 +43,6 @@ struct rspamd_grey_reply { } reply; }; +typedef void (*greylist_cb_t) (gboolean greylisted, struct worker_task *task, gpointer ud); #endif diff --git a/src/protocol.c b/src/protocol.c index 999de65ab..1b349b49e 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -508,6 +508,9 @@ show_url_header (struct worker_task *task) } cur = g_list_next (cur); } + if (r == 0) { + return TRUE; + } return rspamd_dispatcher_write (task->dispatcher, outbuf, r, FALSE, FALSE); } @@ -720,6 +723,10 @@ show_messages (struct worker_task *task) cur = g_list_next (cur); } + if (r == 0) { + return TRUE; + } + return rspamd_dispatcher_write (task->dispatcher, outbuf, r, FALSE, FALSE); } |