summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-19 14:10:23 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-19 14:10:23 +0100
commita4cde432d8cf9ac5f4f2eaf49a7dcbecd4f14be8 (patch)
tree93462f420e72396f0d737d0b25fd2e38b8895ce4 /src
parent098113caf8d1db6a85ddb42aeadfb26298550fab (diff)
downloadrspamd-a4cde432d8cf9ac5f4f2eaf49a7dcbecd4f14be8.tar.gz
rspamd-a4cde432d8cf9ac5f4f2eaf49a7dcbecd4f14be8.zip
Process settings in rspamd.
Diffstat (limited to 'src')
-rw-r--r--src/libmime/filter.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/libmime/filter.c b/src/libmime/filter.c
index f340b9dbc..c8273ed65 100644
--- a/src/libmime/filter.c
+++ b/src/libmime/filter.c
@@ -73,6 +73,7 @@ insert_metric_result (struct rspamd_task *task,
struct metric_result *metric_res;
struct symbol *s;
gdouble *weight, w;
+ const ucl_object_t *mobj, *sobj;
metric_res = g_hash_table_lookup (task->results, metric->name);
@@ -102,6 +103,20 @@ insert_metric_result (struct rspamd_task *task,
w = (*weight) * flag;
}
+ if (task->settings) {
+ mobj = ucl_object_find_key (task->settings, metric->name);
+ if (mobj) {
+ gdouble corr;
+
+ sobj = ucl_object_find_key (mobj, symbol);
+ if (sobj != NULL && ucl_object_todouble_safe (sobj, &corr)) {
+ msg_debug ("settings: changed weight of symbol %s from %.2f to %.2f",
+ symbol, w, corr);
+ w = corr * flag;
+ }
+ }
+ }
+
/* Add metric score */
if ((s = g_hash_table_lookup (metric_res->symbols, symbol)) != NULL) {
if (s->options && opts && opts != s->options) {
@@ -320,6 +335,17 @@ process_filters (struct rspamd_task *task)
struct metric *metric;
gpointer item = NULL;
+ if (task->settings) {
+ const ucl_object_t *wl;
+
+ wl = ucl_object_find_key (task->settings, "whitelist");
+ if (wl != NULL) {
+ msg_info ("<%s> is whitelisted", task->message_id);
+ task->is_skipped = TRUE;
+ return 0;
+ }
+ }
+
/* Process metrics symbols */
while (call_symbol_callback (task, task->cfg->cache, &item)) {
/* Check reject actions */