diff options
-rw-r--r-- | conf/metrics.conf | 4 | ||||
-rw-r--r-- | src/libmime/filter.h | 4 | ||||
-rw-r--r-- | src/libserver/cfg_rcl.c | 11 | ||||
-rw-r--r-- | src/libserver/symbols_cache.h | 3 |
4 files changed, 21 insertions, 1 deletions
diff --git a/conf/metrics.conf b/conf/metrics.conf index 7a735f839..0d41ed96b 100644 --- a/conf/metrics.conf +++ b/conf/metrics.conf @@ -2,6 +2,10 @@ metric { name = "default"; + # If this param is set to non-zero + # then a metric would accept all symbols + # unknown_weight = 1.0 + actions { reject = 15; add_header = 6; diff --git a/src/libmime/filter.h b/src/libmime/filter.h index f0a343483..c7ac43951 100644 --- a/src/libmime/filter.h +++ b/src/libmime/filter.h @@ -50,7 +50,9 @@ struct metric { const gchar *name; /**< name of metric */ gchar *func_name; /**< name of consolidation function */ metric_cons_func func; /**< c consolidation function */ - double grow_factor; /**< grow factor for metric */ + gboolean accept_unknown_symbols; /**< if true unknown symbols are registered here */ + gdouble unknown_weight; /**< weight of unknown symbols */ + gdouble grow_factor; /**< grow factor for metric */ GHashTable *symbols; /**< weights of symbols in metric */ GHashTable *descriptions; /**< descriptions of symbols in metric */ struct metric_action actions[METRIC_ACTION_MAX]; /**< all actions of the metric */ diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index 1cfcf2560..d8f70de07 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -329,6 +329,7 @@ rspamd_rcl_metric_handler (struct rspamd_config *cfg, const ucl_object_t *obj, gdouble action_score, grow_factor; gint action_value; gboolean new = TRUE, have_actions = FALSE; + gdouble unknown_weight; ucl_object_iter_t it = NULL; val = ucl_object_find_key (obj, "name"); @@ -463,10 +464,20 @@ rspamd_rcl_metric_handler (struct rspamd_config *cfg, const ucl_object_t *obj, metric->subject = (gchar *)subject_name; } + val = ucl_object_find_key (obj, "unknown_weight"); + if (val && ucl_object_todouble_safe (val, &unknown_weight) && + unknown_weight != 0.) { + metric->unknown_weight = unknown_weight; + metric->accept_unknown_symbols = TRUE; + } + /* Insert the resulting metric */ if (new) { g_hash_table_insert (cfg->metrics, (void *)metric->name, metric); cfg->metrics_list = g_list_prepend (cfg->metrics_list, metric); + if (strcmp (metric->name, DEFAULT_METRIC) == 0) { + cfg->default_metric = metric; + } } return TRUE; diff --git a/src/libserver/symbols_cache.h b/src/libserver/symbols_cache.h index e1fd3286f..36128460d 100644 --- a/src/libserver/symbols_cache.h +++ b/src/libserver/symbols_cache.h @@ -33,6 +33,8 @@ struct cache_item { guint32 networks_number; gboolean is_dynamic; + gboolean is_skipped; + /* Callback data */ symbol_func_t func; gpointer user_data; @@ -41,6 +43,7 @@ struct cache_item { gboolean is_virtual; gboolean is_callback; + /* Priority */ gint priority; gdouble metric_weight; |