aboutsummaryrefslogtreecommitdiffstats
path: root/src/libserver
diff options
context:
space:
mode:
Diffstat (limited to 'src/libserver')
-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
4 files changed, 8 insertions, 36 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);
}