]]--
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)
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
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
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
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()
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"])
end
return copy
end
- 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
for k,r in pairs(rules) do
- local def_rules = deepcopy(default_options)
+ local def_rules = lua_util.override_defaults(default_options, r)
def_rules['redis'] = redis_params
- -- Override defaults
- override_defaults(def_rules, r)
if not def_rules.prefix then
def_rules.prefix = k