aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-11-05 12:39:58 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-11-05 12:39:58 +0000
commitdd28b2b6d81bdba77f78d9b4ebd230901b3c96d3 (patch)
treeb205dbcdd589c194499e8db7e1f7aa00afc4772d
parent8913a040207b0274a267d1988a9c37603418c560 (diff)
downloadrspamd-dd28b2b6d81bdba77f78d9b4ebd230901b3c96d3.tar.gz
rspamd-dd28b2b6d81bdba77f78d9b4ebd230901b3c96d3.zip
[Minor] Deal with ungrouped symbols
-rw-r--r--lualib/rspamd_config_transform.lua28
1 files changed, 28 insertions, 0 deletions
diff --git a/lualib/rspamd_config_transform.lua b/lualib/rspamd_config_transform.lua
index 8b7027d37..750862a8c 100644
--- a/lualib/rspamd_config_transform.lua
+++ b/lualib/rspamd_config_transform.lua
@@ -118,6 +118,28 @@ local function group_transform(cfg, k, v)
logger.warnx("overriding group %s from the legacy metric settings", k)
end
+local function symbol_transform(cfg, k, v)
+ -- first try to find any group where there is a definition of this symbol
+ for gr_n, gr in pairs(cfg.group) do
+ if gr.symbols and gr.symbols[k] then
+ -- We override group symbol with ungrouped symbol
+ logger.warnx("overriding group symbol %s in the group %s", k, gr_n)
+ gr.symbols[k] = override_defaults(gr.symbols[k], v)
+ return
+ end
+ end
+
+ -- Otherwise we just use group 'ungrouped'
+ if not cfg.group.ungrouped then
+ cfg.group.ungrouped = {
+ symbols = {}
+ }
+ end
+
+ cfg.group.ungrouped.symbols[k] = v
+ logger.warnx("adding symbol %s to the group 'ungrouped'", k)
+end
+
local function convert_metric(cfg, metric)
if type(metric[1]) == 'table' then
logger.warnx("multiple metrics have never been supported")
@@ -142,6 +164,12 @@ local function convert_metric(cfg, metric)
end
end
+ if metric.symbol then
+ for k, v in metric_pairs(metric.symbol) do
+ symbol_transform(cfg, k, v)
+ end
+ end
+
return true, cfg
end