summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-07-13 20:54:13 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-07-13 20:54:13 +0400
commita8cdd33ac7ee59e195dca03a395c264877ee5168 (patch)
tree077413b678005aad4f66dbeae82a982cb71ce75f /src/plugins
parent74b38eb87d0ee6e401e06d8c604d55be2d93a1b2 (diff)
downloadrspamd-a8cdd33ac7ee59e195dca03a395c264877ee5168.tar.gz
rspamd-a8cdd33ac7ee59e195dca03a395c264877ee5168.zip
* Rework the whole filters system
* Add metrics optimization and symbols cache * Change all plugins [DRAGONS]: not for production usage, some things are still not working!
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/chartable.c41
-rw-r--r--src/plugins/emails.c40
-rw-r--r--src/plugins/regexp.c77
-rw-r--r--src/plugins/surbl.c129
-rw-r--r--src/plugins/surbl.h7
5 files changed, 168 insertions, 126 deletions
diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c
index bb0f79da7..19c46c7b7 100644
--- a/src/plugins/chartable.c
+++ b/src/plugins/chartable.c
@@ -38,10 +38,7 @@
#define DEFAULT_THRESHOLD 0.1
struct chartable_ctx {
- int (*header_filter)(struct worker_task *task);
- int (*mime_filter)(struct worker_task *task);
- int (*message_filter)(struct worker_task *task);
- int (*url_filter)(struct worker_task *task);
+ int (*filter)(struct worker_task *task);
char *metric;
char *symbol;
double threshold;
@@ -52,16 +49,14 @@ struct chartable_ctx {
static struct chartable_ctx *chartable_module_ctx = NULL;
static int chartable_mime_filter (struct worker_task *task);
+static void chartable_symbol_callback (struct worker_task *task, void *unused);
int
chartable_module_init (struct config_file *cfg, struct module_ctx **ctx)
{
chartable_module_ctx = g_malloc (sizeof (struct chartable_ctx));
- chartable_module_ctx->header_filter = NULL;
- chartable_module_ctx->mime_filter = chartable_mime_filter;
- chartable_module_ctx->message_filter = NULL;
- chartable_module_ctx->url_filter = NULL;
+ chartable_module_ctx->filter = chartable_mime_filter;
chartable_module_ctx->chartable_pool = memory_pool_new (memory_pool_get_size ());
*ctx = (struct module_ctx *)chartable_module_ctx;
@@ -75,6 +70,8 @@ chartable_module_config (struct config_file *cfg)
{
char *value;
int res = TRUE;
+ struct metric *metric;
+ double *w;
if ((value = get_module_opt (cfg, "chartable", "metric")) != NULL) {
chartable_module_ctx->metric = memory_pool_strdup (chartable_module_ctx->chartable_pool, value);
@@ -101,7 +98,22 @@ chartable_module_config (struct config_file *cfg)
else {
chartable_module_ctx->threshold = DEFAULT_THRESHOLD;
}
-
+
+ metric = g_hash_table_lookup (cfg->metrics, chartable_module_ctx->metric);
+ if (metric == NULL) {
+ msg_err ("chartable_module_config: cannot find metric definition %s", chartable_module_ctx->metric);
+ return FALSE;
+ }
+
+ /* Search in factors hash table */
+ w = g_hash_table_lookup (cfg->factors, chartable_module_ctx->symbol);
+ if (w == NULL) {
+ register_symbol (metric->cache, chartable_module_ctx->symbol, 1, chartable_symbol_callback, NULL);
+ }
+ else {
+ register_symbol (metric->cache, chartable_module_ctx->symbol, *w, chartable_symbol_callback, NULL);
+ }
+
return res;
}
@@ -178,8 +190,8 @@ check_part (struct mime_text_part *part, gboolean raw_mode)
return ((double)mark / (double)total) > chartable_module_ctx->threshold;
}
-static int
-chartable_mime_filter (struct worker_task *task)
+static void
+chartable_symbol_callback (struct worker_task *task, void *unused)
{
GList *cur;
@@ -193,6 +205,11 @@ chartable_mime_filter (struct worker_task *task)
}
}
- return 0;
}
+static int
+chartable_mime_filter (struct worker_task *task)
+{
+ /* XXX: remove it */
+ return 0;
+}
diff --git a/src/plugins/emails.c b/src/plugins/emails.c
index 0b7e35d84..6b789916b 100644
--- a/src/plugins/emails.c
+++ b/src/plugins/emails.c
@@ -40,10 +40,7 @@
static const char *email_re_text = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+(?:[A-Z]{2}|com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum)\\b";
struct email_ctx {
- int (*header_filter)(struct worker_task *task);
- int (*mime_filter)(struct worker_task *task);
- int (*message_filter)(struct worker_task *task);
- int (*url_filter)(struct worker_task *task);
+ int (*filter)(struct worker_task *task);
char *metric;
char *symbol;
GRegex *email_re;
@@ -57,6 +54,7 @@ struct email_ctx {
static struct email_ctx *email_module_ctx = NULL;
static int emails_mime_filter (struct worker_task *task);
+static void emails_symbol_callback (struct worker_task *task, void *unused);
static int emails_command_handler (struct worker_task *task);
int
@@ -66,10 +64,7 @@ emails_module_init (struct config_file *cfg, struct module_ctx **ctx)
email_module_ctx = g_malloc (sizeof (struct email_ctx));
- email_module_ctx->header_filter = NULL;
- email_module_ctx->mime_filter = emails_mime_filter;
- email_module_ctx->message_filter = NULL;
- email_module_ctx->url_filter = NULL;
+ email_module_ctx->filter = emails_mime_filter;
email_module_ctx->email_pool = memory_pool_new (memory_pool_get_size ());
email_module_ctx->email_re = g_regex_new (email_re_text, G_REGEX_RAW | G_REGEX_OPTIMIZE | G_REGEX_CASELESS, 0, &err);
email_module_ctx->blacklist = g_hash_table_new (g_str_hash, g_str_equal);
@@ -87,6 +82,8 @@ emails_module_config (struct config_file *cfg)
{
char *value;
int res = TRUE;
+ struct metric *metric;
+ double *w;
if ((value = get_module_opt (cfg, "emails", "metric")) != NULL) {
email_module_ctx->metric = memory_pool_strdup (email_module_ctx->email_pool, value);
@@ -109,6 +106,22 @@ emails_module_config (struct config_file *cfg)
}
}
}
+
+ metric = g_hash_table_lookup (cfg->metrics, email_module_ctx->metric);
+ if (metric == NULL) {
+ msg_err ("emails_module_config: cannot find metric definition %s", email_module_ctx->metric);
+ return FALSE;
+ }
+
+ /* Search in factors hash table */
+ w = g_hash_table_lookup (cfg->factors, email_module_ctx->symbol);
+ if (w == NULL) {
+ register_symbol (metric->cache, email_module_ctx->symbol, 1, emails_symbol_callback, NULL);
+ }
+ else {
+ register_symbol (metric->cache, email_module_ctx->symbol, *w, emails_symbol_callback, NULL);
+ }
+
return res;
}
@@ -198,8 +211,8 @@ emails_command_handler (struct worker_task *task)
return 0;
}
-static int
-emails_mime_filter (struct worker_task *task)
+static void
+emails_symbol_callback (struct worker_task *task, void *unused)
{
GList *emails, *cur;
@@ -220,6 +233,11 @@ emails_mime_filter (struct worker_task *task)
}
}
- return 0;
}
+static int
+emails_mime_filter (struct worker_task *task)
+{
+ /* XXX: remove this */
+ return 0;
+}
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 097df7f96..7b123dd33 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -53,11 +53,7 @@ struct autolearn_data {
};
struct regexp_ctx {
- int (*header_filter)(struct worker_task *task);
- int (*mime_filter)(struct worker_task *task);
- int (*message_filter)(struct worker_task *task);
- int (*url_filter)(struct worker_task *task);
- GList *items;
+ int (*filter)(struct worker_task *task);
GHashTable *autolearn_symbols;
char *metric;
char *statfile_prefix;
@@ -70,18 +66,16 @@ static struct regexp_ctx *regexp_module_ctx = NULL;
static int regexp_common_filter (struct worker_task *task);
static gboolean rspamd_regexp_match_number (struct worker_task *task, GList *args);
static gboolean rspamd_raw_header_exists (struct worker_task *task, GList *args);
+static void process_regexp_item (struct worker_task *task, void *user_data);
+
int
regexp_module_init (struct config_file *cfg, struct module_ctx **ctx)
{
regexp_module_ctx = g_malloc (sizeof (struct regexp_ctx));
- regexp_module_ctx->header_filter = regexp_common_filter;
- regexp_module_ctx->mime_filter = NULL;
- regexp_module_ctx->message_filter = NULL;
- regexp_module_ctx->url_filter = NULL;
+ regexp_module_ctx->filter = regexp_common_filter;
regexp_module_ctx->regexp_pool = memory_pool_new (1024);
- regexp_module_ctx->items = NULL;
regexp_module_ctx->autolearn_symbols = g_hash_table_new (g_str_hash, g_str_equal);
*ctx = (struct module_ctx *)regexp_module_ctx;
@@ -155,8 +149,10 @@ regexp_module_config (struct config_file *cfg)
GList *cur_opt = NULL;
struct module_opt *cur;
struct regexp_module_item *cur_item;
+ struct metric *metric;
char *value;
int res = TRUE;
+ double *w;
if ((value = get_module_opt (cfg, "regexp", "metric")) != NULL) {
regexp_module_ctx->metric = memory_pool_strdup (regexp_module_ctx->regexp_pool, value);
@@ -172,6 +168,12 @@ regexp_module_config (struct config_file *cfg)
else {
regexp_module_ctx->statfile_prefix = DEFAULT_STATFILE_PREFIX;
}
+
+ metric = g_hash_table_lookup (cfg->metrics, regexp_module_ctx->metric);
+ if (metric == NULL) {
+ msg_err ("regexp_module_config: cannot find metric definition %s", regexp_module_ctx->metric);
+ return FALSE;
+ }
cur_opt = g_hash_table_lookup (cfg->modules_opts, "regexp");
while (cur_opt) {
@@ -188,8 +190,16 @@ regexp_module_config (struct config_file *cfg)
if (!read_regexp_expression (regexp_module_ctx->regexp_pool, cur_item, cur->param, cur->value, cfg)) {
res = FALSE;
}
- set_counter (cur_item->symbol, 0);
- regexp_module_ctx->items = g_list_prepend (regexp_module_ctx->items, cur_item);
+
+ /* Search in factors hash table */
+ w = g_hash_table_lookup (cfg->factors, cur->param);
+ if (w == NULL) {
+ register_symbol (metric->cache, cur->param, 1, process_regexp_item, cur_item);
+ }
+ else {
+ register_symbol (metric->cache, cur->param, *w, process_regexp_item, cur_item);
+ }
+
cur_opt = g_list_next (cur_opt);
}
@@ -587,47 +597,20 @@ process_regexp_expression (struct expression *expr, struct worker_task *task)
}
static void
-process_regexp_item (struct regexp_module_item *item, struct worker_task *task)
-{
- struct timespec ts1, ts2;
- uint64_t diff;
-
- if (check_view (task->cfg->views, item->symbol, task)) {
-#ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID
- clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts1);
-#elif defined(HAVE_CLOCK_VIRTUAL)
- clock_gettime (CLOCK_VIRTUAL, &ts1);
-#else
- clock_gettime (CLOCK_REALTIME, &ts1);
-#endif
- if (process_regexp_expression (item->expr, task)) {
- insert_result (task, regexp_module_ctx->metric, item->symbol, 1, NULL);
- }
-
-#ifdef HAVE_CLOCK_PROCESS_CPUTIME_ID
- clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &ts2);
-#elif defined(HAVE_CLOCK_VIRTUAL)
- clock_gettime (CLOCK_VIRTUAL, &ts2);
-#else
- clock_gettime (CLOCK_REALTIME, &ts2);
-#endif
+process_regexp_item (struct worker_task *task, void *user_data)
+{
+ struct regexp_module_item *item = user_data;
- diff = (ts2.tv_sec - ts1.tv_sec) * 1000000 + (ts2.tv_nsec - ts1.tv_nsec) / 1000;
- set_counter (item->symbol, diff);
+ if (process_regexp_expression (item->expr, task)) {
+ insert_result (task, regexp_module_ctx->metric, item->symbol, 1, NULL);
}
}
-static int
+static int
regexp_common_filter (struct worker_task *task)
{
- GList *cur_expr = g_list_first (regexp_module_ctx->items);
-
- while (cur_expr) {
- process_regexp_item ((struct regexp_module_item *)cur_expr->data, task);
- cur_expr = g_list_next (cur_expr);
- }
-
- return 0;
+ /* XXX: remove this shit too */
+ return 0;
}
static gboolean
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 3e00b0e73..691c57681 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -36,7 +36,8 @@
static struct surbl_ctx *surbl_module_ctx = NULL;
-static int surbl_test_url (struct worker_task *task);
+static int surbl_filter (struct worker_task *task);
+static void surbl_test_url (struct worker_task *task, void *user_data);
static void dns_callback (int result, char type, int count, int ttl, void *addresses, void *data);
static void process_dns_results (struct worker_task *task, struct suffix_item *suffix, char *url, uint32_t addr);
static int urls_command_handler (struct worker_task *task);
@@ -56,10 +57,7 @@ surbl_module_init (struct config_file *cfg, struct module_ctx **ctx)
surbl_module_ctx = g_malloc (sizeof (struct surbl_ctx));
- surbl_module_ctx->header_filter = NULL;
- surbl_module_ctx->mime_filter = NULL;
- surbl_module_ctx->message_filter = NULL;
- surbl_module_ctx->url_filter = surbl_test_url;
+ surbl_module_ctx->filter = surbl_filter;
surbl_module_ctx->use_redirector = 0;
surbl_module_ctx->suffixes = NULL;
surbl_module_ctx->bits = NULL;
@@ -98,6 +96,8 @@ surbl_module_config (struct config_file *cfg)
struct module_opt *cur;
struct suffix_item *new_suffix;
struct surbl_bit_item *new_bit;
+ struct metric *metric;
+ double *w;
char *value, *cur_tok, *str;
uint32_t bit;
@@ -172,6 +172,13 @@ surbl_module_config (struct config_file *cfg)
}
}
+ metric = g_hash_table_lookup (cfg->metrics, surbl_module_ctx->metric);
+ if (metric == NULL) {
+ msg_err ("surbl_module_config: cannot find metric definition %s", surbl_module_ctx->metric);
+ return FALSE;
+ }
+
+
cur_opt = g_hash_table_lookup (cfg->modules_opts, "surbl");
while (cur_opt) {
cur = cur_opt->data;
@@ -185,6 +192,14 @@ surbl_module_config (struct config_file *cfg)
new_suffix->suffix, new_suffix->symbol);
*str = '_';
surbl_module_ctx->suffixes = g_list_prepend (surbl_module_ctx->suffixes, new_suffix);
+ /* Search in factors hash table */
+ w = g_hash_table_lookup (cfg->factors, new_suffix->symbol);
+ if (w == NULL) {
+ register_symbol (metric->cache, new_suffix->symbol, 1, surbl_test_url, NULL);
+ }
+ else {
+ register_symbol (metric->cache, new_suffix->symbol, *w, surbl_test_url, NULL);
+ }
}
}
if (!g_strncasecmp (cur->param, "bit", sizeof ("bit") - 1)) {
@@ -210,6 +225,13 @@ surbl_module_config (struct config_file *cfg)
msg_debug ("surbl_module_config: add default surbl suffix: %s with symbol: %s",
new_suffix->suffix, new_suffix->symbol);
surbl_module_ctx->suffixes = g_list_prepend (surbl_module_ctx->suffixes, new_suffix);
+ w = g_hash_table_lookup (cfg->factors, new_suffix->symbol);
+ if (w == NULL) {
+ register_symbol (metric->cache, new_suffix->symbol, 1, surbl_test_url, new_suffix);
+ }
+ else {
+ register_symbol (metric->cache, new_suffix->symbol, *w, surbl_test_url, new_suffix);
+ }
}
return TRUE;
@@ -356,55 +378,48 @@ format_surbl_request (memory_pool_t *pool, f_str_t *hostname, struct suffix_item
}
static void
-make_surbl_requests (struct uri* url, struct worker_task *task, GTree *tree)
+make_surbl_requests (struct uri* url, struct worker_task *task, GTree *tree, struct suffix_item *suffix)
{
char *surbl_req;
f_str_t f;
- GList *cur;
GError *err = NULL;
struct dns_param *param;
- struct suffix_item *suffix;
char *host_end;
- cur = g_list_first (surbl_module_ctx->suffixes);
f.begin = url->host;
f.len = url->hostlen;
- while (cur) {
- suffix = (struct suffix_item *)cur->data;
- if (check_view (task->cfg->views, suffix->symbol, task)) {
- if ((surbl_req = format_surbl_request (task->task_pool, &f, suffix, &host_end, TRUE, &err)) != NULL) {
- if (g_tree_lookup (tree, surbl_req) == NULL) {
- g_tree_insert (tree, surbl_req, surbl_req);
- param = memory_pool_alloc (task->task_pool, sizeof (struct dns_param));
- param->url = url;
- param->task = task;
- param->suffix = suffix;
- *host_end = '\0';
- param->host_resolve = memory_pool_strdup (task->task_pool, surbl_req);
- *host_end = '.';
- msg_debug ("surbl_test_url: send surbl dns request %s", surbl_req);
- if (evdns_resolve_ipv4 (surbl_req, DNS_QUERY_NO_SEARCH, dns_callback, (void *)param) == 0) {
- param->task->save.saved ++;
- }
- }
- else {
- msg_debug ("make_surbl_requests: request %s is already sent", surbl_req);
+ if (check_view (task->cfg->views, suffix->symbol, task)) {
+ if ((surbl_req = format_surbl_request (task->task_pool, &f, suffix, &host_end, TRUE, &err)) != NULL) {
+ if (g_tree_lookup (tree, surbl_req) == NULL) {
+ g_tree_insert (tree, surbl_req, surbl_req);
+ param = memory_pool_alloc (task->task_pool, sizeof (struct dns_param));
+ param->url = url;
+ param->task = task;
+ param->suffix = suffix;
+ *host_end = '\0';
+ param->host_resolve = memory_pool_strdup (task->task_pool, surbl_req);
+ *host_end = '.';
+ msg_debug ("surbl_test_url: send surbl dns request %s", surbl_req);
+ if (evdns_resolve_ipv4 (surbl_req, DNS_QUERY_NO_SEARCH, dns_callback, (void *)param) == 0) {
+ param->task->save.saved ++;
}
}
- else if (err != NULL && err->code != WHITELIST_ERROR) {
- msg_info ("surbl_test_url: cannot format url string for surbl %s, %s", struri (url), err->message);
- g_error_free (err);
- return;
- }
- else if (err != NULL) {
- g_error_free (err);
+ else {
+ msg_debug ("make_surbl_requests: request %s is already sent", surbl_req);
}
}
- else {
- msg_debug ("make_surbl_requests: skipping symbol that is not in view: %s", suffix->symbol);
+ else if (err != NULL && err->code != WHITELIST_ERROR) {
+ msg_info ("surbl_test_url: cannot format url string for surbl %s, %s", struri (url), err->message);
+ g_error_free (err);
+ return;
+ }
+ else if (err != NULL) {
+ g_error_free (err);
}
- cur = g_list_next (cur);
+ }
+ else {
+ msg_debug ("make_surbl_requests: skipping symbol that is not in view: %s", suffix->symbol);
}
}
@@ -531,7 +546,7 @@ memcached_callback (memcached_ctx_t *ctx, memc_error_t error, void *data)
param->task->save.saved = 1;
process_filters (param->task);
}
- make_surbl_requests (param->url, param->task, param->tree);
+ make_surbl_requests (param->url, param->task, param->tree, param->suffix);
break;
default:
return;
@@ -539,7 +554,7 @@ memcached_callback (memcached_ctx_t *ctx, memc_error_t error, void *data)
}
static void
-register_memcached_call (struct uri *url, struct worker_task *task, GTree *url_tree)
+register_memcached_call (struct uri *url, struct worker_task *task, GTree *url_tree, struct suffix_item *suffix)
{
struct memcached_param *param;
struct memcached_server *selected;
@@ -554,6 +569,7 @@ register_memcached_call (struct uri *url, struct worker_task *task, GTree *url_t
param->url = url;
param->task = task;
param->tree = url_tree;
+ param->suffix = suffix;
param->ctx = memory_pool_alloc0 (task->task_pool, sizeof (memcached_ctx_t));
@@ -614,7 +630,7 @@ redirector_callback (int fd, short what, void *arg)
event_del (&param->ev);
close (fd);
param->task->save.saved --;
- make_surbl_requests (param->url, param->task, param->tree);
+ make_surbl_requests (param->url, param->task, param->tree, param->suffix);
if (param->task->save.saved == 0) {
/* Call other filters */
param->task->save.saved = 1;
@@ -630,7 +646,7 @@ redirector_callback (int fd, short what, void *arg)
msg_info ("redirector_callback: <%s> connection to redirector timed out while waiting for write",
param->task->message_id);
param->task->save.saved --;
- make_surbl_requests (param->url, param->task, param->tree);
+ make_surbl_requests (param->url, param->task, param->tree, param->suffix);
if (param->task->save.saved == 0) {
/* Call other filters */
@@ -660,7 +676,7 @@ redirector_callback (int fd, short what, void *arg)
event_del (&param->ev);
close (fd);
param->task->save.saved --;
- make_surbl_requests (param->url, param->task, param->tree);
+ make_surbl_requests (param->url, param->task, param->tree, param->suffix);
if (param->task->save.saved == 0) {
/* Call other filters */
param->task->save.saved = 1;
@@ -673,7 +689,7 @@ redirector_callback (int fd, short what, void *arg)
msg_info ("redirector_callback: <%s> reading redirector timed out, while waiting for read",
param->task->message_id);
param->task->save.saved --;
- make_surbl_requests (param->url, param->task, param->tree);
+ make_surbl_requests (param->url, param->task, param->tree, param->suffix);
if (param->task->save.saved == 0) {
/* Call other filters */
param->task->save.saved = 1;
@@ -686,7 +702,7 @@ redirector_callback (int fd, short what, void *arg)
static void
-register_redirector_call (struct uri *url, struct worker_task *task, GTree *url_tree)
+register_redirector_call (struct uri *url, struct worker_task *task, GTree *url_tree, struct suffix_item *suffix)
{
int s;
struct redirector_param *param;
@@ -698,7 +714,7 @@ register_redirector_call (struct uri *url, struct worker_task *task, GTree *url_
msg_info ("register_redirector_call: <%s> cannot create tcp socket failed: %s",
task->message_id, strerror (errno));
task->save.saved --;
- make_surbl_requests (url, task, url_tree);
+ make_surbl_requests (url, task, url_tree, suffix);
return;
}
@@ -708,6 +724,7 @@ register_redirector_call (struct uri *url, struct worker_task *task, GTree *url_
param->state = STATE_CONNECT;
param->sock = s;
param->tree = url_tree;
+ param->suffix = suffix;
timeout = memory_pool_alloc (task->task_pool, sizeof (struct timeval));
timeout->tv_sec = surbl_module_ctx->connect_timeout / 1000;
timeout->tv_usec = surbl_module_ctx->connect_timeout - timeout->tv_sec * 1000;
@@ -724,29 +741,30 @@ tree_url_callback (gpointer key, gpointer value, void *data)
msg_debug ("surbl_test_url: check url %s", struri (url));
if (surbl_module_ctx->use_redirector) {
- register_redirector_call (url, param->task, param->tree);
+ register_redirector_call (url, param->task, param->tree, param->suffix);
param->task->save.saved++;
}
else {
if (param->task->worker->srv->cfg->memcached_servers_num > 0) {
- register_memcached_call (url, param->task, param->tree);
+ register_memcached_call (url, param->task, param->tree, param->suffix);
param->task->save.saved++;
}
else {
- make_surbl_requests (url, param->task, param->tree);
+ make_surbl_requests (url, param->task, param->tree, param->suffix);
}
}
return FALSE;
}
-static int
-surbl_test_url (struct worker_task *task)
+static void
+surbl_test_url (struct worker_task *task, void *user_data)
{
GTree *url_tree;
GList *cur;
struct mime_text_part *part;
struct redirector_param param;
+ struct suffix_item *suffix = user_data;
/* Try to check lists */
if (surbl_module_ctx->tld2_file) {
@@ -760,6 +778,7 @@ surbl_test_url (struct worker_task *task)
param.tree = url_tree;
param.task = task;
+ param.suffix = suffix;
cur = task->text_parts;
while (cur) {
part = cur->data;
@@ -774,6 +793,12 @@ surbl_test_url (struct worker_task *task)
}
memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_tree_destroy, url_tree);
+}
+
+static int
+surbl_filter (struct worker_task *task)
+{
+ /* XXX: remove this shit */
return 0;
}
diff --git a/src/plugins/surbl.h b/src/plugins/surbl.h
index 8f674c9ca..cfe17b404 100644
--- a/src/plugins/surbl.h
+++ b/src/plugins/surbl.h
@@ -17,10 +17,7 @@
#define DEFAULT_SURBL_SUFFIX "multi.surbl.org"
struct surbl_ctx {
- int (*header_filter)(struct worker_task *task);
- int (*mime_filter)(struct worker_task *task);
- int (*message_filter)(struct worker_task *task);
- int (*url_filter)(struct worker_task *task);
+ int (*filter)(struct worker_task *task);
struct in_addr redirector_addr;
uint16_t redirector_port;
uint16_t weight;
@@ -64,6 +61,7 @@ struct redirector_param {
struct event ev;
int sock;
GTree *tree;
+ struct suffix_item *suffix;
};
struct memcached_param {
@@ -71,6 +69,7 @@ struct memcached_param {
struct worker_task *task;
memcached_ctx_t *ctx;
GTree *tree;
+ struct suffix_item *suffix;
};
struct surbl_bit_item {