aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libserver/cfg_file.h1
-rw-r--r--src/libserver/cfg_rcl.c19
-rw-r--r--src/libserver/cfg_utils.c22
-rw-r--r--src/libserver/dynamic_cfg.c2
-rw-r--r--src/lua/lua_config.c6
-rw-r--r--src/plugins/dkim_check.c2
-rw-r--r--src/plugins/regexp.c11
7 files changed, 14 insertions, 49 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 48f352f49..39f57662a 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -607,7 +607,6 @@ gboolean rspamd_init_filters (struct rspamd_config *cfg, bool reconfig,
* @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,
const gchar *symbol, gdouble score, const gchar *description,
const gchar *group, guint flags,
guint priority,
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index af4198e15..d0b50a74f 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -345,7 +345,6 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
struct rspamd_rcl_section *section, GError **err)
{
struct rspamd_rcl_symbol_data *sd = ud;
- struct rspamd_metric *metric;
struct rspamd_config *cfg;
const ucl_object_t *elt;
const gchar *description = NULL;
@@ -354,8 +353,6 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
gint nshots;
g_assert (key != NULL);
- metric = sd->metric;
- g_assert (metric != NULL);
cfg = sd->cfg;
nshots = cfg->default_max_shots;
@@ -406,11 +403,11 @@ rspamd_rcl_symbol_handler (rspamd_mempool_t *pool, const ucl_object_t *obj,
}
if (sd->gr) {
- rspamd_config_add_metric_symbol (cfg, metric->name, key, score,
+ rspamd_config_add_metric_symbol (cfg, key, score,
description, sd->gr->name, flags, priority, nshots);
}
else {
- rspamd_config_add_metric_symbol (cfg, metric->name, key, score,
+ rspamd_config_add_metric_symbol (cfg, key, score,
description, NULL, flags, priority, nshots);
}
@@ -1434,7 +1431,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
struct rspamd_expression *expr;
struct rspamd_config *cfg = ud;
struct rspamd_composite *composite;
- const gchar *composite_name, *composite_expression, *group, *metric,
+ const gchar *composite_name, *composite_expression, *group,
*description;
gdouble score;
gboolean new = TRUE;
@@ -1494,14 +1491,6 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
group = "composite";
}
- val = ucl_object_lookup (obj, "metric");
- if (val != NULL) {
- metric = ucl_object_tostring (val);
- }
- else {
- metric = DEFAULT_METRIC;
- }
-
val = ucl_object_lookup (obj, "description");
if (val != NULL) {
description = ucl_object_tostring (val);
@@ -1510,7 +1499,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool,
description = composite_expression;
}
- rspamd_config_add_metric_symbol (cfg, metric, composite_name, score,
+ rspamd_config_add_metric_symbol (cfg, composite_name, score,
description, group, FALSE, FALSE,
1);
}
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 721419c4b..fdfb6b512 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -123,6 +123,7 @@ rspamd_config_new (void)
cfg->max_diff = 20480;
cfg->metrics = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
+ rspamd_config_new_metric (cfg, NULL, DEFAULT_METRIC);
cfg->c_modules = g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
cfg->composite_symbols =
g_hash_table_new (rspamd_str_hash, rspamd_str_equal);
@@ -649,7 +650,6 @@ rspamd_config_post_load (struct rspamd_config *cfg,
#ifdef HAVE_CLOCK_GETTIME
struct timespec ts;
#endif
- struct rspamd_metric *def_metric;
gboolean ret = TRUE;
#ifdef HAVE_CLOCK_GETTIME
@@ -692,12 +692,6 @@ rspamd_config_post_load (struct rspamd_config *cfg,
}
#endif
- if ((def_metric =
- g_hash_table_lookup (cfg->metrics, DEFAULT_METRIC)) == NULL) {
- def_metric = rspamd_config_new_metric (cfg, NULL, DEFAULT_METRIC);
- def_metric->actions[METRIC_ACTION_REJECT].score = DEFAULT_SCORE;
- }
-
if (opts & RSPAMD_CONFIG_INIT_URL) {
if (cfg->tld_file == NULL) {
/* Try to guess tld file */
@@ -1498,7 +1492,7 @@ rspamd_config_new_metric_symbol (struct rspamd_config *cfg,
gboolean
rspamd_config_add_metric_symbol (struct rspamd_config *cfg,
- const gchar *metric_name, const gchar *symbol,
+ const gchar *symbol,
gdouble score, const gchar *description, const gchar *group,
guint flags, guint priority, gint nshots)
{
@@ -1508,17 +1502,7 @@ rspamd_config_add_metric_symbol (struct rspamd_config *cfg,
g_assert (cfg != NULL);
g_assert (symbol != NULL);
- if (metric_name == NULL) {
- metric_name = DEFAULT_METRIC;
- }
-
- metric = g_hash_table_lookup (cfg->metrics, metric_name);
-
- if (metric == NULL) {
- msg_err_config ("metric %s has not been found", metric_name);
- return FALSE;
- }
-
+ metric = cfg->default_metric;
sym_def = g_hash_table_lookup (metric->symbols, symbol);
if (sym_def != NULL) {
diff --git a/src/libserver/dynamic_cfg.c b/src/libserver/dynamic_cfg.c
index 950b9719c..fa2cc6d1e 100644
--- a/src/libserver/dynamic_cfg.c
+++ b/src/libserver/dynamic_cfg.c
@@ -79,7 +79,7 @@ apply_dynamic_conf (const ucl_object_t *top, struct rspamd_config *cfg)
/*
* We use priority = 3 here
*/
- rspamd_config_add_metric_symbol (cfg, real_metric->name,
+ rspamd_config_add_metric_symbol (cfg,
ucl_object_tostring (n), nscore, NULL, NULL,
0, priority, cfg->default_max_shots);
}
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index aac585536..f12b7504e 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -1518,7 +1518,7 @@ lua_config_register_symbol (lua_State * L)
nshots = 1;
}
- rspamd_config_add_metric_symbol (cfg, DEFAULT_METRIC, name,
+ rspamd_config_add_metric_symbol (cfg, name,
score, description, group, flags, (guint)priority, nshots);
}
}
@@ -1823,7 +1823,7 @@ lua_config_set_metric_symbol (lua_State * L)
msg_err_config ("metric named %s is not defined", metric_name);
}
else if (name != NULL && weight != 0) {
- rspamd_config_add_metric_symbol (cfg, metric_name, name,
+ rspamd_config_add_metric_symbol (cfg, name,
weight, description, group, flags, (guint)priority, nshots);
}
}
@@ -2190,7 +2190,7 @@ lua_config_newindex (lua_State *L)
* Do not override the existing symbols (using zero priority),
* since we are defining default values here
*/
- rspamd_config_add_metric_symbol (cfg, NULL, name, score,
+ rspamd_config_add_metric_symbol (cfg, name, score,
description, group, flags, 0, nshots);
}
else {
diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c
index 4cc1093f6..b554ec48c 100644
--- a/src/plugins/dkim_check.c
+++ b/src/plugins/dkim_check.c
@@ -543,7 +543,7 @@ dkim_module_config (struct rspamd_config *cfg)
"DKIM_SIGN", dkim_module_ctx->symbol_reject);
}
- rspamd_config_add_metric_symbol (cfg, DEFAULT_METRIC,
+ rspamd_config_add_metric_symbol (cfg,
"DKIM_SIGN", 0.0, "DKIM signature fake symbol",
"dkim", RSPAMD_SYMBOL_FLAG_IGNORE, 1, 1);
diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c
index f73a31bd4..bd016ac82 100644
--- a/src/plugins/regexp.c
+++ b/src/plugins/regexp.c
@@ -189,8 +189,7 @@ regexp_module_config (struct rspamd_config *cfg)
nlua ++;
}
else if (value->type == UCL_OBJECT) {
- const gchar *description = NULL, *group = NULL,
- *metric = DEFAULT_METRIC;
+ const gchar *description = NULL, *group = NULL;
gdouble score = 0.0;
guint flags = 0, priority = 0;
gboolean is_lua = FALSE, valid_expression = TRUE;
@@ -254,12 +253,6 @@ regexp_module_config (struct rspamd_config *cfg)
conddata->L, conddata->idx);
}
- elt = ucl_object_lookup (value, "metric");
-
- if (elt) {
- metric = ucl_object_tostring (elt);
- }
-
elt = ucl_object_lookup (value, "description");
if (elt) {
@@ -310,7 +303,7 @@ regexp_module_config (struct rspamd_config *cfg)
priority = ucl_object_toint (elt);
}
- rspamd_config_add_metric_symbol (cfg, metric, cur_item->symbol,
+ rspamd_config_add_metric_symbol (cfg, cur_item->symbol,
score, description, group, flags, priority, nshots);
}
}