aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver/cfg_file.h
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-28 22:58:20 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-28 22:58:20 +0000
commit0c9184dcbde07a7f9cf04835ce10b45891f4c628 (patch)
tree8241c348605aa072b1e8e16d7cf0efdaa8131ab1 /src/libserver/cfg_file.h
parentf309a84d17bce0456f369b693ae270288e72892f (diff)
downloadrspamd-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/cfg_file.h')
-rw-r--r--src/libserver/cfg_file.h48
1 files changed, 47 insertions, 1 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 2ed82930b..8a59f8c74 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -221,6 +221,37 @@ struct rspamd_log_format {
struct rspamd_log_format *prev, *next;
};
+enum rspamd_metric_action {
+ METRIC_ACTION_REJECT = 0,
+ METRIC_ACTION_SOFT_REJECT,
+ METRIC_ACTION_REWRITE_SUBJECT,
+ METRIC_ACTION_ADD_HEADER,
+ METRIC_ACTION_GREYLIST,
+ METRIC_ACTION_NOACTION,
+ METRIC_ACTION_MAX
+};
+
+struct metric_action {
+ enum rspamd_metric_action action;
+ gdouble score;
+ guint priority;
+};
+
+/**
+ * Common definition of metric
+ */
+struct metric {
+ const gchar *name; /**< name of metric */
+ gchar *func_name; /**< name of consolidation function */
+ 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 */
+ gchar *subject; /**< subject rewrite string */
+ GHashTable * groups; /**< groups of symbols */
+ struct metric_action actions[METRIC_ACTION_MAX]; /**< all actions of the metric */
+};
+
/**
* Structure that stores all config data
*/
@@ -506,7 +537,7 @@ gboolean rspamd_init_filters (struct rspamd_config *cfg, bool reconfig);
* @param one_shot TRUE if symbol can add its score once
* @param rewrite_existing TRUE if we need to rewrite the existing symbol
* @param priority use the following priority for a symbol
- * @return TRUE if symbol has been inserted or FALSE if `rewrite_existing` is not enabled and symbol already exists
+ * @return TRUE if symbol has been inserted or FALSE if symbol already exists with higher priority
*/
gboolean rspamd_config_add_metric_symbol (struct rspamd_config *cfg,
const gchar *metric,
@@ -515,6 +546,21 @@ gboolean rspamd_config_add_metric_symbol (struct rspamd_config *cfg,
guint priority);
/**
+ * Sets action score for a specified metric with the specified priority
+ * @param cfg config file
+ * @param metric metric name (or NULL for default metric)
+ * @param action_name symbolic name of action
+ * @param score score limit
+ * @param priority priority for action
+ * @return TRUE if symbol has been inserted or FALSE if action already exists with higher priority
+ */
+gboolean rspamd_config_set_action_score (struct rspamd_config *cfg,
+ const gchar *metric,
+ const gchar *action_name,
+ gdouble score,
+ guint priority);
+
+/**
* Checks if a specified C or lua module is enabled or disabled in the config.
* The logic of check is the following:
*