aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-05 13:18:05 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-04-05 13:18:05 +0100
commit4b86e84051c9e3a9eb10e188ee8bc8840e796eca (patch)
tree4d16af480cefa900f2c917c75b81a30237db4409 /lualib
parentf422d322ec1b36547f4c8f95f13cb631ca387ed4 (diff)
downloadrspamd-4b86e84051c9e3a9eb10e188ee8bc8840e796eca.tar.gz
rspamd-4b86e84051c9e3a9eb10e188ee8bc8840e796eca.zip
[Minor] Use override_defaults from lua_util
Diffstat (limited to 'lualib')
-rw-r--r--lualib/lua_cfg_transform.lua29
-rw-r--r--lualib/rspamadm/rescore.lua16
2 files changed, 5 insertions, 40 deletions
diff --git a/lualib/lua_cfg_transform.lua b/lualib/lua_cfg_transform.lua
index 3d863e373..4dcfd8111 100644
--- a/lualib/lua_cfg_transform.lua
+++ b/lualib/lua_cfg_transform.lua
@@ -15,28 +15,7 @@ limitations under the License.
]]--
local logger = require "rspamd_logger"
-
-local function override_defaults(def, override)
- if not override then
- return def
- end
- if not def then
- return override
- end
- for k,v in pairs(override) do
- if def[k] then
- if type(v) == 'table' then
- def[k] = override_defaults(def[k], v)
- else
- def[k] = v
- end
- else
- def[k] = v
- end
- end
-
- return def
-end
+local lua_util = require "lua_util"
local function is_implicit(t)
local mt = getmetatable(t)
@@ -134,7 +113,7 @@ local function group_transform(cfg, k, v)
if not cfg.group then cfg.group = {} end
if cfg.group[k] then
- cfg.group[k] = override_defaults(cfg.group[k], new_group)
+ cfg.group[k] = lua_util.override_defaults(cfg.group[k], new_group)
else
cfg.group[k] = new_group
end
@@ -148,7 +127,7 @@ local function symbol_transform(cfg, k, v)
if gr.symbols and gr.symbols[k] then
-- We override group symbol with ungrouped symbol
logger.infox("overriding group symbol %s in the group %s", k, gr_n)
- gr.symbols[k] = override_defaults(gr.symbols[k], v)
+ gr.symbols[k] = lua_util.override_defaults(gr.symbols[k], v)
return
end
end
@@ -196,7 +175,7 @@ end
local function convert_metric(cfg, metric)
if metric.actions then
- cfg.actions = override_defaults(cfg.actions, metric.actions)
+ cfg.actions = lua_util.override_defaults(cfg.actions, metric.actions)
logger.infox("overriding actions from the legacy metric settings")
end
if metric.unknown_weight then
diff --git a/lualib/rspamadm/rescore.lua b/lualib/rspamadm/rescore.lua
index 56a92deff..231cf2ea6 100644
--- a/lualib/rspamadm/rescore.lua
+++ b/lualib/rspamadm/rescore.lua
@@ -383,20 +383,6 @@ local penalty_weights = {
0
}
-local function override_defaults(def, override)
- for k,v in pairs(override) do
- if def[k] then
- if type(v) == 'table' then
- override_defaults(def[k], v)
- else
- def[k] = v
- end
- else
- def[k] = v
- end
- end
-end
-
local function get_threshold()
local actions = rspamd_config:get_all_actions()
@@ -409,7 +395,7 @@ end
return function (args, cfg)
opts = default_opts
- override_defaults(opts, getopt.getopt(args, 'i:'))
+ opts = lua_util.override_defaults(opts, getopt.getopt(args, 'i:'))
local threshold,reject_score = get_threshold()
local logs = rescore_utility.get_all_logs(cfg["logdir"])