diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-28 22:58:20 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-02-28 22:58:20 +0000 |
commit | 0c9184dcbde07a7f9cf04835ce10b45891f4c628 (patch) | |
tree | 8241c348605aa072b1e8e16d7cf0efdaa8131ab1 /src/libserver/dynamic_cfg.c | |
parent | f309a84d17bce0456f369b693ae270288e72892f (diff) | |
download | rspamd-0c9184dcbde07a7f9cf04835ce10b45891f4c628.tar.gz rspamd-0c9184dcbde07a7f9cf04835ce10b45891f4c628.zip |
[Feature] Add priorities for actions
Add dedicated API to modify action limits with priorities from different
configuration place. This follows the logic of symbols' priorities and
will be used for dynamic rules and override definitions.
Diffstat (limited to 'src/libserver/dynamic_cfg.c')
-rw-r--r-- | src/libserver/dynamic_cfg.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c index 041438698..27fec9da9 100644 --- a/src/libserver/dynamic_cfg.c +++ b/src/libserver/dynamic_cfg.c @@ -37,8 +37,9 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg) const ucl_object_t *cur_elt, *cur_nm, *it_val; ucl_object_iter_t it = NULL; struct metric *real_metric; - struct metric_action *cur_action; + const gchar *name; gdouble nscore; + static const guint priority = 3; while ((cur_elt = ucl_object_iterate (top, &it, true))) { if (ucl_object_type (cur_elt) != UCL_OBJECT) { @@ -79,7 +80,7 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg) */ rspamd_config_add_metric_symbol (cfg, real_metric->name, ucl_object_tostring (n), nscore, NULL, NULL, - 0, 3); + 0, priority); } else { msg_info ( @@ -102,18 +103,18 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg) while ((it_val = ucl_object_iterate (cur_nm, &nit, true))) { if (ucl_object_lookup (it_val, "name") && ucl_object_lookup (it_val, "value")) { - if (!rspamd_action_from_str (ucl_object_tostring ( - ucl_object_lookup (it_val, "name")), &test_act)) { + name = ucl_object_tostring (ucl_object_lookup (it_val, "name")); + + if (!name || !rspamd_action_from_str (name, &test_act)) { msg_err ("unknown action: %s", ucl_object_tostring (ucl_object_lookup (it_val, "name"))); continue; } - cur_action = &real_metric->actions[test_act]; - cur_action->action = test_act; - cur_action->score = - ucl_object_todouble (ucl_object_lookup (it_val, - "value")); + nscore = ucl_object_todouble (ucl_object_lookup (it_val, + "value")); + rspamd_config_set_action_score (cfg, real_metric->name, + name, nscore, priority); } else { msg_info ( |