summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2010-06-16 20:43:26 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2010-06-16 20:43:26 +0400
commita639bf512e3df778fa33c49d83c3996c9fe60d77 (patch)
tree072c4167dae82382b1c8eef93e0270339635e389 /src/plugins
parentc4aab3053d2839e6d3b99f8a542b0a4f54f2b856 (diff)
downloadrspamd-a639bf512e3df778fa33c49d83c3996c9fe60d77.tar.gz
rspamd-a639bf512e3df778fa33c49d83c3996c9fe60d77.zip
* Change metric logic
* Completely remove lex/yacc readers for config * Make common sense of metric/action and symbols * Sync changes with all plugins TODO: add this to documentation
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/chartable.c33
-rw-r--r--src/plugins/emails.c26
-rw-r--r--src/plugins/fuzzy_check.c38
-rw-r--r--src/plugins/lua/forged_recipients.lua13
-rw-r--r--src/plugins/lua/maillist.lua14
-rw-r--r--src/plugins/lua/once_received.lua12
-rw-r--r--src/plugins/lua/received_rbl.lua14
-rw-r--r--src/plugins/lua/whitelist.lua13
-rw-r--r--src/plugins/regexp.c41
-rw-r--r--src/plugins/spf.c31
-rw-r--r--src/plugins/surbl.c38
11 files changed, 42 insertions, 231 deletions
diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c
index 8486f66c5..347fa5cab 100644
--- a/src/plugins/chartable.c
+++ b/src/plugins/chartable.c
@@ -26,7 +26,6 @@
* rspamd module that make marks based on symbol chains
*
* Allowed options:
- * - metric (string): metric to insert symbol (default: 'default')
* - symbol (string): symbol to insert (default: 'R_BAD_CHARSET')
* - threshold (double): value that would be used as threshold in expression characters_changed / total_characters
* (e.g. if threshold is 0.1 than charset change should occure more often than in 10 symbols), default: 0.1
@@ -45,7 +44,6 @@
struct chartable_ctx {
int (*filter) (struct worker_task * task);
- char *metric;
char *symbol;
double threshold;
@@ -76,21 +74,7 @@ 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);
- }
- else {
- chartable_module_ctx->metric = DEFAULT_METRIC;
- }
- if ((value = get_module_opt (cfg, "chartable", "symbol")) != NULL) {
- chartable_module_ctx->symbol = memory_pool_strdup (chartable_module_ctx->chartable_pool, value);
- }
- else {
- chartable_module_ctx->symbol = DEFAULT_SYMBOL;
- }
if ((value = get_module_opt (cfg, "chartable", "threshold")) != NULL) {
errno = 0;
chartable_module_ctx->threshold = strtod (value, NULL);
@@ -103,20 +87,7 @@ chartable_module_config (struct config_file *cfg)
chartable_module_ctx->threshold = DEFAULT_THRESHOLD;
}
- metric = g_hash_table_lookup (cfg->metrics, chartable_module_ctx->metric);
- if (metric == NULL) {
- msg_err ("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);
- }
+ register_symbol (&cfg->cache, chartable_module_ctx->symbol, 1, chartable_symbol_callback, NULL);
return res;
}
@@ -203,7 +174,7 @@ chartable_symbol_callback (struct worker_task *task, void *unused)
while (cur) {
part = cur->data;
if (!part->is_empty && check_part (part, task->cfg->raw_mode)) {
- insert_result (task, chartable_module_ctx->metric, chartable_module_ctx->symbol, 1, NULL);
+ insert_result (task, chartable_module_ctx->symbol, 1, NULL);
}
cur = g_list_next (cur);
}
diff --git a/src/plugins/emails.c b/src/plugins/emails.c
index 37d0b8d33..ed6702396 100644
--- a/src/plugins/emails.c
+++ b/src/plugins/emails.c
@@ -26,7 +26,6 @@
* rspamd module that extracts emails from messages and check them via blacklist
*
* Allowed options:
- * - metric (string): metric to insert symbol (default: 'default')
* - symbol (string): symbol to insert (default: 'R_BAD_EMAIL')
* - blacklist (map string): map that contains list of bad emails
*/
@@ -48,7 +47,6 @@ static const char *email_re_text =
struct email_ctx {
int (*filter) (struct worker_task * task);
- char *metric;
char *symbol;
GRegex *email_re;
@@ -89,15 +87,7 @@ 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);
- }
- else {
- email_module_ctx->metric = DEFAULT_METRIC;
- }
if ((value = get_module_opt (cfg, "emails", "symbol")) != NULL) {
email_module_ctx->symbol = memory_pool_strdup (email_module_ctx->email_pool, value);
}
@@ -110,20 +100,8 @@ emails_module_config (struct config_file *cfg)
}
}
- metric = g_hash_table_lookup (cfg->metrics, email_module_ctx->metric);
- if (metric == NULL) {
- msg_err ("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);
- }
+ register_symbol (&cfg->cache, email_module_ctx->symbol, 1, emails_symbol_callback, NULL);
return res;
}
@@ -233,7 +211,7 @@ emails_symbol_callback (struct worker_task *task, void *unused)
while (cur) {
if (g_hash_table_lookup (email_module_ctx->blacklist, cur->data) != NULL) {
- insert_result (task, email_module_ctx->metric, email_module_ctx->symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, (char *)cur->data)));
+ insert_result (task, email_module_ctx->symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, (char *)cur->data)));
}
cur = g_list_next (cur);
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index ddfe696ab..3782e1194 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -26,7 +26,6 @@
* rspamd module that checks fuzzy checksums for messages
*
* Allowed options:
- * - metric (string): metric to insert symbol (default: 'default')
* - symbol (string): symbol to insert (default: 'R_FUZZY')
* - max_score (double): maximum score to that weights of hashes would be normalized (default: 0 - no normalization)
*
@@ -74,7 +73,6 @@ struct fuzzy_mapping {
struct fuzzy_ctx {
int (*filter) (struct worker_task * task);
- char *metric;
char *symbol;
struct storage_server *servers;
int servers_num;
@@ -260,15 +258,7 @@ fuzzy_check_module_config (struct config_file *cfg)
{
char *value;
int res = TRUE;
- struct metric *metric;
- double *w;
- if ((value = get_module_opt (cfg, "fuzzy_check", "metric")) != NULL) {
- fuzzy_module_ctx->metric = memory_pool_strdup (fuzzy_module_ctx->fuzzy_pool, value);
- }
- else {
- fuzzy_module_ctx->metric = DEFAULT_METRIC;
- }
if ((value = get_module_opt (cfg, "fuzzy_check", "symbol")) != NULL) {
fuzzy_module_ctx->symbol = memory_pool_strdup (fuzzy_module_ctx->fuzzy_pool, value);
}
@@ -306,31 +296,7 @@ fuzzy_check_module_config (struct config_file *cfg)
parse_flags_string (value);
}
- metric = g_hash_table_lookup (cfg->metrics, fuzzy_module_ctx->metric);
- if (metric == NULL) {
- msg_err ("cannot find metric definition %s", fuzzy_module_ctx->metric);
- return FALSE;
- }
-
- /* Search in factors hash table */
- w = g_hash_table_lookup (cfg->factors, fuzzy_module_ctx->symbol);
-
- if (w == NULL) {
- if (fabs (fuzzy_module_ctx->max_score) < 0.001) {
- register_symbol (&metric->cache, fuzzy_module_ctx->symbol, 1, fuzzy_symbol_callback, NULL);
- }
- else {
- register_symbol (&metric->cache, fuzzy_module_ctx->symbol, fuzzy_module_ctx->max_score, fuzzy_symbol_callback, NULL);
- }
- }
- else {
- if (fabs (fuzzy_module_ctx->max_score) < 0.001) {
- register_symbol (&metric->cache, fuzzy_module_ctx->symbol, *w, fuzzy_symbol_callback, NULL);
- }
- else {
- register_symbol (&metric->cache, fuzzy_module_ctx->symbol, *w * fuzzy_module_ctx->max_score, fuzzy_symbol_callback, NULL);
- }
- }
+ register_symbol (&cfg->cache, fuzzy_module_ctx->symbol, fuzzy_module_ctx->max_score, fuzzy_symbol_callback, NULL);
register_custom_controller_command ("fuzzy_add", fuzzy_add_handler, TRUE, TRUE);
register_custom_controller_command ("fuzzy_del", fuzzy_delete_handler, TRUE, TRUE);
@@ -418,7 +384,7 @@ fuzzy_io_callback (int fd, short what, void *arg)
}
snprintf (buf, sizeof (buf), "%d: %d / %.2f", flag, value, nval);
- insert_result (session->task, fuzzy_module_ctx->metric, symbol, nval, g_list_prepend (NULL,
+ insert_result (session->task, symbol, nval, g_list_prepend (NULL,
memory_pool_strdup (session->task->task_pool, buf)));
}
goto ok;
diff --git a/src/plugins/lua/forged_recipients.lua b/src/plugins/lua/forged_recipients.lua
index 77188e830..af4ce3125 100644
--- a/src/plugins/lua/forged_recipients.lua
+++ b/src/plugins/lua/forged_recipients.lua
@@ -1,7 +1,6 @@
-- Plugin for comparing smtp dialog recipients and sender with recipients and sender
-- in mime headers
-local metric = 'default'
local symbol_rcpt = 'FORGED_RECIPIENTS'
local symbol_sender = 'FORGED_SENDER'
@@ -22,7 +21,7 @@ function check_forged_headers(task)
end
-- Check recipients count
if count < table.maxn(smtp_rcpt) then
- task:insert_result(metric, symbol_rcpt, 1)
+ task:insert_result(symbol_rcpt, 1)
else
-- Find pair for each smtp recipient recipient in To or Cc headers
for _,sr in ipairs(smtp_rcpt) do
@@ -48,7 +47,7 @@ function check_forged_headers(task)
end
if not res then
- task:insert_result(metric, symbol_rcpt, 1)
+ task:insert_result(symbol_rcpt, 1)
break
end
end
@@ -59,7 +58,7 @@ function check_forged_headers(task)
if smtp_form then
local mime_from = msg:get_header('From')
if not mime_from or not string.find(mime_from[0], smtp_from) then
- task:insert_result(metric, symbol_sender, 1)
+ task:insert_result(symbol_sender, 1)
end
end
end
@@ -74,11 +73,7 @@ if opts then
if opts['symbol_sender'] then
symbol_sender = opts['symbol_sender']
end
- if opts['metric'] then
- metric = opts['metric']
- end
- local m = rspamd_config:get_metric(metric)
- m:register_symbol(symbol_rcpt, 1.0, 'check_forged_headers')
+ rspamd_config:register_symbol(symbol_rcpt, 1.0, 'check_forged_headers')
end
end
diff --git a/src/plugins/lua/maillist.lua b/src/plugins/lua/maillist.lua
index 18514aa86..098c512a4 100644
--- a/src/plugins/lua/maillist.lua
+++ b/src/plugins/lua/maillist.lua
@@ -1,7 +1,5 @@
-- Module for checking mail list headers
-
-local metric = 'default'
local symbol = 'MAILLIST'
-- EZMLM
@@ -157,11 +155,11 @@ end
function check_maillist(task)
if check_ml_ezmlm(task) then
- task:insert_result(metric, symbol, 1, 'ezmlm')
+ task:insert_result(symbol, 1, 'ezmlm')
elseif check_ml_mailman(task) then
- task:insert_result(metric, symbol, 1, 'mailman')
+ task:insert_result(symbol, 1, 'mailman')
elseif check_ml_subscriberu(task) then
- task:insert_result(metric, symbol, 1, 'subscribe.ru')
+ task:insert_result(symbol, 1, 'subscribe.ru')
end
end
@@ -169,11 +167,7 @@ end
local opts = rspamd_config:get_all_opt('maillist')
if opts then
if opts['symbol'] then
- if opts['metric'] then
- metric = opts['metric']
- end
symbol = opts['symbol']
- local m = rspamd_config:get_metric(metric)
- m:register_symbol(symbol, 1.0, 'check_maillist')
+ rspamd_config:register_symbol(symbol, 1.0, 'check_maillist')
end
end
diff --git a/src/plugins/lua/once_received.lua b/src/plugins/lua/once_received.lua
index d858314dd..404f13899 100644
--- a/src/plugins/lua/once_received.lua
+++ b/src/plugins/lua/once_received.lua
@@ -1,6 +1,5 @@
-- 0 or 1 received: = spam
-local metric = 'default'
local symbol = 'ONCE_RECEIVED'
-- Symbol for strict checks
local symbol_strict = nil
@@ -10,7 +9,7 @@ local good_hosts = {}
function check_quantity_received (task)
local recvh = task:get_received_headers()
if table.maxn(recvh) <= 1 then
- task:insert_result(metric, symbol, 1)
+ task:insert_result(symbol, 1)
-- Strict checks
if symbol_strict then
local r = recvh[1]
@@ -19,7 +18,7 @@ function check_quantity_received (task)
end
-- Unresolved host
if not r['real_hostname'] or string.lower(r['real_hostname']) == 'unknown' or string.match(r['real_hostname'], '^%d+%.%d+%.%d+%.%d+$') then
- task:insert_result(metric, symbol_strict, 1)
+ task:insert_result(symbol_strict, 1)
return
end
@@ -36,7 +35,7 @@ function check_quantity_received (task)
end
end
if i then
- task:insert_result(metric, symbol_strict, 1, h)
+ task:insert_result(symbol_strict, 1, h)
return
end
end
@@ -58,13 +57,10 @@ if opts then
bad_hosts = v
elseif n == 'good_host' then
good_hosts = v
- elseif n == 'metric' then
- metric = v
end
end
-- Register symbol's callback
- local m = rspamd_config:get_metric(metric)
- m:register_symbol(symbol, 1.0, 'check_quantity_received')
+ rspamd_config:register_symbol(symbol, 1.0, 'check_quantity_received')
end
end
diff --git a/src/plugins/lua/received_rbl.lua b/src/plugins/lua/received_rbl.lua
index 304678613..0a74272c1 100644
--- a/src/plugins/lua/received_rbl.lua
+++ b/src/plugins/lua/received_rbl.lua
@@ -3,11 +3,9 @@
-- .module 'received_rbl' {
-- rbl = "insecure-bl.rambler.ru";
-- rbl = "xbl.spamhaus.org";
--- metric = "default";
-- symbol = "RECEIVED_RBL";
-- };
-local metric = 'default'
local symbol = 'RECEIVED_RBL'
local rbls = {}
@@ -18,15 +16,15 @@ function dns_cb(task, to_resolve, results, err)
-- Find incoming rbl in rbls list
for _,rbl in ipairs(rbls) do
if rbl == in_rbl then
- task:insert_result(metric, symbol, 1, rbl .. ': ' .. ip)
+ task:insert_result(symbol, 1, rbl .. ': ' .. ip)
else
local s, _ = string.find(rbl, in_rbl)
if s then
s, _ = string.find(rbl, ':')
if s then
- task:insert_result(metric, string.sub(rbl, s + 1, -1), 1, ip)
+ task:insert_result(string.sub(rbl, s + 1, -1), 1, ip)
else
- task:insert_result(metric, symbol, 1, rbl .. ': ' .. ip)
+ task:insert_result(symbol, 1, rbl .. ': ' .. ip)
end
end
end
@@ -63,15 +61,11 @@ if opts then
if opts['symbol'] then
symbol = opts['symbol']
- if opts['metric'] then
- metric = opts['metric']
- end
if opts['rbl'] then
rbls = opts['rbl']
end
-- Register symbol's callback
- local m = rspamd_config:get_metric(metric)
- m:register_symbol(symbol, 1.0, 'received_cb')
+ rspamd_config:register_symbol(symbol, 1.0, 'received_cb')
end
-- If no symbol defined, do not register this module
end
diff --git a/src/plugins/lua/whitelist.lua b/src/plugins/lua/whitelist.lua
index e95aca6c7..34867bd2f 100644
--- a/src/plugins/lua/whitelist.lua
+++ b/src/plugins/lua/whitelist.lua
@@ -1,6 +1,5 @@
-- Module that add symbols to those hosts or from domains that are contained in whitelist
-local metric = 'default'
local symbol_ip = nil
local symbol_from = nil
@@ -14,7 +13,7 @@ function check_whitelist (task)
if ipn then
local key = r:get_key(ipn)
if key then
- task:insert_result(metric, symbol_ip, 1)
+ task:insert_result( symbol_ip, 1)
end
end
end
@@ -26,7 +25,7 @@ function check_whitelist (task)
local _,_,domain = string.find(from, '@(.+)>?$')
local key = h:get_key(domain)
if key then
- task:insert_result(metric, symbol_from, 1)
+ task:insert_result(symbol_from, 1)
end
end
end
@@ -58,16 +57,12 @@ if opts then
end
end
- if opts['metric'] then
- metric = opts['metric']
- end
-- Register symbol's callback
- local m = rspamd_config:get_metric(metric)
if symbol_ip then
- m:register_symbol(symbol_ip, 1.0, 'check_whitelist')
+ rspamd_config:register_symbol(symbol_ip, 1.0, 'check_whitelist')
elseif symbol_from then
- m:register_symbol(symbol_from, 1.0, 'check_whitelist')
+ rspamd_config:register_symbol(symbol_from, 1.0, 'check_whitelist')
end
end
end
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index 00fd7ad4c..2b52f4d8f 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -59,7 +59,6 @@ struct autolearn_data {
struct regexp_ctx {
int (*filter) (struct worker_task * task);
GHashTable *autolearn_symbols;
- char *metric;
char *statfile_prefix;
memory_pool_t *regexp_pool;
@@ -87,7 +86,7 @@ regexp_dynamic_insert_result (struct worker_task *task, void *user_data)
{
char *symbol = user_data;
- insert_result (task, regexp_module_ctx->metric, symbol, 1, NULL);
+ insert_result (task, symbol, 1, NULL);
}
static gboolean
@@ -257,7 +256,6 @@ json_regexp_fin_cb (memory_pool_t * pool, struct map_cb_data *data)
GList *cur_networks = NULL;
struct dynamic_map_item *cur_nitem;
memory_pool_t *new_pool;
- struct metric *metric;
if (data->prev_data) {
jb = data->prev_data;
@@ -296,13 +294,8 @@ json_regexp_fin_cb (memory_pool_t * pool, struct map_cb_data *data)
}
new_pool = memory_pool_new (memory_pool_get_size ());
- metric = g_hash_table_lookup (jb->cfg->metrics, regexp_module_ctx->metric);
- if (metric == NULL) {
- msg_err ("cannot find metric definition %s", regexp_module_ctx->metric);
- return;
- }
- remove_dynamic_rules (metric->cache);
+ remove_dynamic_rules (jb->cfg->cache);
if (regexp_module_ctx->dynamic_pool != NULL) {
memory_pool_delete (regexp_module_ctx->dynamic_pool);
}
@@ -365,7 +358,7 @@ json_regexp_fin_cb (memory_pool_t * pool, struct map_cb_data *data)
cur_item = memory_pool_alloc0 (new_pool, sizeof (struct regexp_module_item));
cur_item->symbol = cur_symbol;
if (read_regexp_expression (new_pool, cur_item, cur_symbol, cur_rule, jb->cfg->raw_mode)) {
- register_dynamic_symbol (new_pool, &metric->cache, cur_symbol, score, process_regexp_item, cur_item, cur_networks);
+ register_dynamic_symbol (new_pool, &jb->cfg->cache, cur_symbol, score, process_regexp_item, cur_item, cur_networks);
}
else {
msg_warn ("cannot parse dynamic rule");
@@ -373,7 +366,7 @@ json_regexp_fin_cb (memory_pool_t * pool, struct map_cb_data *data)
}
else {
/* Just rule that is allways true (for whitelisting for example) */
- register_dynamic_symbol (new_pool, &metric->cache, cur_symbol, score, regexp_dynamic_insert_result, cur_symbol, cur_networks);
+ register_dynamic_symbol (new_pool, &jb->cfg->cache, cur_symbol, score, regexp_dynamic_insert_result, cur_symbol, cur_networks);
}
if (cur_networks) {
g_list_free (cur_networks);
@@ -439,18 +432,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;
struct regexp_json_buf *jb, **pjb;
- if ((value = get_module_opt (cfg, "regexp", "metric")) != NULL) {
- regexp_module_ctx->metric = memory_pool_strdup (regexp_module_ctx->regexp_pool, value);
- }
- else {
- regexp_module_ctx->metric = DEFAULT_METRIC;
- }
if ((value = get_module_opt (cfg, "regexp", "statfile_prefix")) != NULL) {
regexp_module_ctx->statfile_prefix = memory_pool_strdup (regexp_module_ctx->regexp_pool, value);
}
@@ -468,11 +453,6 @@ regexp_module_config (struct config_file *cfg)
}
}
- metric = g_hash_table_lookup (cfg->metrics, regexp_module_ctx->metric);
- if (metric == NULL) {
- msg_err ("cannot find metric definition %s", regexp_module_ctx->metric);
- return FALSE;
- }
cur_opt = g_hash_table_lookup (cfg->modules_opts, "regexp");
while (cur_opt) {
@@ -515,14 +495,7 @@ regexp_module_config (struct config_file *cfg)
break;
}
- /* 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);
- }
+ register_symbol (&cfg->cache, cur->param, 1, process_regexp_item, cur_item);
cur_opt = g_list_next (cur_opt);
}
@@ -947,13 +920,13 @@ process_regexp_item (struct worker_task *task, void *user_data)
if (item->lua_function) {
/* Just call function */
if (lua_call_expression_func (item->lua_function, task, NULL, &res) && res) {
- insert_result (task, regexp_module_ctx->metric, item->symbol, 1, NULL);
+ insert_result (task, item->symbol, 1, NULL);
}
}
else {
/* Process expression */
if (process_regexp_expression (item->expr, item->symbol, task, NULL)) {
- insert_result (task, regexp_module_ctx->metric, item->symbol, 1, NULL);
+ insert_result (task, item->symbol, 1, NULL);
}
}
}
diff --git a/src/plugins/spf.c b/src/plugins/spf.c
index 8f1e8a07e..302d12cc6 100644
--- a/src/plugins/spf.c
+++ b/src/plugins/spf.c
@@ -26,7 +26,6 @@
* rspamd module that checks spf records of incoming email
*
* Allowed options:
- * - metric (string): metric to insert symbol (default: 'default')
* - symbol_allow (string): symbol to insert (default: 'R_SPF_ALLOW')
* - symbol_fail (string): symbol to insert (default: 'R_SPF_FAIL')
* - symbol_softfail (string): symbol to insert (default: 'R_SPF_SOFTFAIL')
@@ -49,7 +48,6 @@
struct spf_ctx {
int (*filter) (struct worker_task * task);
- char *metric;
char *symbol_fail;
char *symbol_softfail;
char *symbol_allow;
@@ -79,15 +77,7 @@ spf_module_config (struct config_file *cfg)
{
char *value;
int res = TRUE;
- struct metric *metric;
- double *w;
- if ((value = get_module_opt (cfg, "spf", "metric")) != NULL) {
- spf_module_ctx->metric = memory_pool_strdup (spf_module_ctx->spf_pool, value);
- }
- else {
- spf_module_ctx->metric = DEFAULT_METRIC;
- }
if ((value = get_module_opt (cfg, "spf", "symbol_fail")) != NULL) {
spf_module_ctx->symbol_fail = memory_pool_strdup (spf_module_ctx->spf_pool, value);
}
@@ -107,20 +97,7 @@ spf_module_config (struct config_file *cfg)
spf_module_ctx->symbol_allow = DEFAULT_SYMBOL_ALLOW;
}
- metric = g_hash_table_lookup (cfg->metrics, spf_module_ctx->metric);
- if (metric == NULL) {
- msg_err ("cannot find metric definition %s", spf_module_ctx->metric);
- return FALSE;
- }
-
- /* Search in factors hash table */
- w = g_hash_table_lookup (cfg->factors, spf_module_ctx->symbol_fail);
- if (w == NULL) {
- register_symbol (&metric->cache, spf_module_ctx->symbol_fail, 1, spf_symbol_callback, NULL);
- }
- else {
- register_symbol (&metric->cache, spf_module_ctx->symbol_fail, *w, spf_symbol_callback, NULL);
- }
+ register_symbol (&cfg->cache, spf_module_ctx->symbol_fail, 1, spf_symbol_callback, NULL);
return res;
}
@@ -156,16 +133,16 @@ spf_plugin_callback (struct spf_record *record, struct worker_task *task)
if ((s & m) == (addr->addr & m)) {
switch (addr->mech) {
case SPF_FAIL:
- insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_fail, 1, g_list_prepend (NULL, addr->spf_string));
+ insert_result (task, spf_module_ctx->symbol_fail, 1, g_list_prepend (NULL, addr->spf_string));
task->messages = g_list_prepend (task->messages, "(SPF): spf fail");
break;
case SPF_SOFT_FAIL:
case SPF_NEUTRAL:
- insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_softfail, 1, g_list_prepend (NULL, addr->spf_string));
+ insert_result (task, spf_module_ctx->symbol_softfail, 1, g_list_prepend (NULL, addr->spf_string));
task->messages = g_list_prepend (task->messages, "(SPF): spf softfail");
break;
default:
- insert_result (task, spf_module_ctx->metric, spf_module_ctx->symbol_allow, 1, g_list_prepend (NULL, addr->spf_string));
+ insert_result (task, spf_module_ctx->symbol_allow, 1, g_list_prepend (NULL, addr->spf_string));
task->messages = g_list_prepend (task->messages, "(SPF): spf allow");
break;
}
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 1f84e6946..6a5a83f3c 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -26,7 +26,6 @@
* rspamd module that implements SURBL url checking
*
* Allowed options:
- * - metric (string): metric to insert symbol (default: 'default')
* - weight (integer): weight of symbol
* Redirecotor options:
* - redirector (string): address of http redirector utility in format "host:port"
@@ -116,8 +115,6 @@ 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;
@@ -177,12 +174,6 @@ surbl_module_config (struct config_file *cfg)
else {
surbl_module_ctx->max_urls = DEFAULT_SURBL_MAX_URLS;
}
- if ((value = get_module_opt (cfg, "surbl", "metric")) != NULL) {
- surbl_module_ctx->metric = memory_pool_strdup (surbl_module_ctx->surbl_pool, value);
- }
- else {
- surbl_module_ctx->metric = DEFAULT_METRIC;
- }
if ((value = get_module_opt (cfg, "surbl", "2tld")) != NULL) {
if (add_map (value, read_host_list, fin_host_list, (void **)&surbl_module_ctx->tld2)) {
surbl_module_ctx->tld2_file = memory_pool_strdup (surbl_module_ctx->surbl_pool, value + sizeof ("file://") - 1);
@@ -194,12 +185,6 @@ surbl_module_config (struct config_file *cfg)
}
}
- metric = g_hash_table_lookup (cfg->metrics, surbl_module_ctx->metric);
- if (metric == NULL) {
- msg_err ("cannot find metric definition %s", surbl_module_ctx->metric);
- return FALSE;
- }
-
cur_opt = g_hash_table_lookup (cfg->modules_opts, "surbl");
while (cur_opt) {
@@ -213,14 +198,7 @@ surbl_module_config (struct config_file *cfg)
msg_debug ("add new surbl suffix: %s with symbol: %s", 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, new_suffix);
- }
- else {
- register_symbol (&metric->cache, new_suffix->symbol, *w, surbl_test_url, new_suffix);
- }
+ register_symbol (&cfg->cache, new_suffix->symbol, 1, surbl_test_url, new_suffix);
}
}
if (!g_strncasecmp (cur->param, "bit", sizeof ("bit") - 1)) {
@@ -244,13 +222,7 @@ surbl_module_config (struct config_file *cfg)
new_suffix->symbol = memory_pool_strdup (surbl_module_ctx->surbl_pool, DEFAULT_SURBL_SYMBOL);
msg_debug ("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);
- }
+ register_symbol (&cfg->cache, new_suffix->symbol, 1, surbl_test_url, new_suffix);
}
return TRUE;
@@ -495,18 +467,18 @@ process_dns_results (struct worker_task *task, struct suffix_item *suffix, char
symbol = memory_pool_alloc (task->task_pool, len);
snprintf (symbol, len, "%s%s%s", suffix->symbol, bit->symbol, c + 2);
*c = '%';
- insert_result (task, surbl_module_ctx->metric, symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, url)));
+ insert_result (task, symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, url)));
found = 1;
}
cur = g_list_next (cur);
}
if (!found) {
- insert_result (task, surbl_module_ctx->metric, suffix->symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, url)));
+ insert_result (task, suffix->symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, url)));
}
}
else {
- insert_result (task, surbl_module_ctx->metric, suffix->symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, url)));
+ insert_result (task, suffix->symbol, 1, g_list_prepend (NULL, memory_pool_strdup (task->task_pool, url)));
}
}