lua_pop (cfg->lua_state, 1); /* Remove global function */
dkim_module_ctx->whitelist_ip = NULL;
- if ((value =
- rspamd_config_get_module_opt (cfg, "dkim", "check_local")) != NULL) {
+ value = rspamd_config_get_module_opt (cfg, "dkim", "check_local");
+
+ if (value == NULL) {
+ rspamd_config_get_module_opt (cfg, "options", "check_local");
+ }
+
+ if (value != NULL) {
dkim_module_ctx->check_local = ucl_object_toboolean (value);
}
else {
dkim_module_ctx->check_local = FALSE;
}
- if ((value =
- rspamd_config_get_module_opt (cfg, "dkim", "check_authed")) != NULL) {
+
+ value = rspamd_config_get_module_opt (cfg, "dkim", "check_authed");
+
+ if (value == NULL) {
+ rspamd_config_get_module_opt (cfg, "options", "check_authed");
+ }
+
+ if (value != NULL) {
dkim_module_ctx->check_authed = ucl_object_toboolean (value);
}
else {
forced = true})
end
-local opts = rspamd_config:get_all_opt('options')
-if type(opts) == 'table' then
- if type(opts['check_local']) == 'boolean' then
- check_local = opts['check_local']
- end
- if type(opts['check_authed']) == 'boolean' then
- check_authed = opts['check_authed']
+local function try_opts(where)
+ local ret = false
+ local opts = rspamd_config:get_all_opt(where)
+ if type(opts) == 'table' then
+ if type(opts['check_local']) == 'boolean' then
+ check_local = opts['check_local']
+ ret = true
+ end
+ if type(opts['check_authed']) == 'boolean' then
+ check_authed = opts['check_authed']
+ ret = true
+ end
end
+
+ return ret
end
-opts = rspamd_config:get_all_opt('dmarc')
+if not try_opts(N) then try_opts('options') end
+
+local opts = rspamd_config:get_all_opt('dmarc')
if not opts or type(opts) ~= 'table' then
return
end
"HFILTER_FROM_BOUNCE"
}
-local opts = rspamd_config:get_all_opt('options')
-if type(opts) == 'table' then
- if type(opts['check_local']) == 'boolean' then
- check_local = opts['check_local']
- end
- if type(opts['check_authed']) == 'boolean' then
- check_authed = opts['check_authed']
+local function try_opts(where)
+ local ret = false
+ local opts = rspamd_config:get_all_opt(where)
+ if type(opts) == 'table' then
+ if type(opts['check_local']) == 'boolean' then
+ check_local = opts['check_local']
+ ret = true
+ end
+ if type(opts['check_authed']) == 'boolean' then
+ check_authed = opts['check_authed']
+ ret = true
+ end
end
+
+ return ret
end
-opts = rspamd_config:get_all_opt('hfilter')
+if not try_opts(N) then try_opts('options') end
+
+local opts = rspamd_config:get_all_opt('hfilter')
if opts then
for k,v in pairs(opts) do
config[k] = v
end
end
-
--- Configuration options
-local configure_ip_score_module = function()
- local opts = rspamd_config:get_all_opt(N)
+local function try_opts(where)
+ local ret = false
+ local opts = rspamd_config:get_all_opt(where)
if type(opts) == 'table' then
- if type(opts['check_authed']) == 'boolean' then
- check_authed = opts['check_authed']
- end
if type(opts['check_local']) == 'boolean' then
check_local = opts['check_local']
+ ret = true
+ end
+ if type(opts['check_authed']) == 'boolean' then
+ check_authed = opts['check_authed']
+ ret = true
end
end
+
+ return ret
+end
+
+if not try_opts(N) then try_opts('options') end
+
+-- Configuration options
+local configure_ip_score_module = function()
+ local opts = rspamd_config:get_all_opt(N)
+
if not opts then return end
for k,v in pairs(opts) do
options[k] = v
local rspamd_logger = require "rspamd_logger"
local fun = require "fun"
+local N = 'once_received'
local check_local = false
local check_authed = false
end
end
-local opts = rspamd_config:get_all_opt('options')
-if type(opts) == 'table' then
- if type(opts['check_local']) == 'boolean' then
- check_local = opts['check_local']
- end
- if type(opts['check_authed']) == 'boolean' then
- check_authed = opts['check_authed']
+local function try_opts(where)
+ local ret = false
+ local opts = rspamd_config:get_all_opt(where)
+ if type(opts) == 'table' then
+ if type(opts['check_local']) == 'boolean' then
+ check_local = opts['check_local']
+ ret = true
+ end
+ if type(opts['check_authed']) == 'boolean' then
+ check_authed = opts['check_authed']
+ ret = true
+ end
end
+
+ return ret
end
+
+if not try_opts(N) then try_opts('options') end
+
-- Configuration
-opts = rspamd_config:get_all_opt('once_received')
+local opts = rspamd_config:get_all_opt(N)
if opts then
if opts['symbol'] then
symbol = opts['symbol']
fuzzy_flag = 1,
fuzzy_weight = 10.0,
key_prefix = 'sptr_',
- check_authed = true,
- check_local = true,
}
+local check_authed = true
+local check_local = true
+
local function spamtrap_cb(task)
local rcpts = task:get_recipients('smtp')
local authed_user = task:get_user()
local called_for_domain = false
local target
- if ((not settings['check_authed'] and authed_user) or
- (not settings['check_local'] and ip_addr and ip_addr:is_local())) then
+ if ((not check_authed and authed_user) or
+ (not check_local and ip_addr and ip_addr:is_local())) then
rspamd_logger.infox(task, "skip spamtrap checks for local networks or authenticated user");
return
end
rspamd_logger.infox(rspamd_config, 'module is unconfigured')
return
end
+
+local function try_opts(where)
+ local ret = false
+ local opts = rspamd_config:get_all_opt(where)
+ if type(opts) == 'table' then
+ if type(opts['check_local']) == 'boolean' then
+ check_local = opts['check_local']
+ ret = true
+ end
+ if type(opts['check_authed']) == 'boolean' then
+ check_authed = opts['check_authed']
+ ret = true
+ end
+ end
+
+ return ret
+end
+
+if not try_opts(M) then try_opts('options') end
+
if opts then
for k,v in pairs(opts) do
settings[k] = v
spf_module_ctx->whitelist_ip = NULL;
- if ((value =
- rspamd_config_get_module_opt (cfg, "options", "check_local")) != NULL) {
+ value = rspamd_config_get_module_opt (cfg, "spf", "check_local");
+
+ if (value == NULL) {
+ rspamd_config_get_module_opt (cfg, "options", "check_local");
+ }
+
+ if (value != NULL) {
spf_module_ctx->check_local = ucl_obj_toboolean (value);
}
else {
spf_module_ctx->check_local = FALSE;
}
- if ((value =
- rspamd_config_get_module_opt (cfg, "options", "check_authed")) != NULL) {
+
+ value = rspamd_config_get_module_opt (cfg, "spf", "check_authed");
+
+ if (value == NULL) {
+ rspamd_config_get_module_opt (cfg, "options", "check_authed");
+ }
+
+ if (value != NULL) {
spf_module_ctx->check_authed = ucl_obj_toboolean (value);
}
else {