Przeglądaj źródła

[Minor] Unify check_auth/check_local options

tags/1.8.1
Vsevolod Stakhov 5 lat temu
rodzic
commit
4c9f6b2118

+ 15
- 4
src/plugins/dkim_check.c Wyświetl plik

@@ -320,15 +320,26 @@ dkim_module_config (struct rspamd_config *cfg)
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 {

+ 17
- 8
src/plugins/lua/dmarc.lua Wyświetl plik

@@ -561,17 +561,26 @@ local function dmarc_callback(task)
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

+ 17
- 8
src/plugins/lua/hfilter.lua Wyświetl plik

@@ -569,17 +569,26 @@ local symbols_from = {
"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

+ 18
- 6
src/plugins/lua/ip_score.lua Wyświetl plik

@@ -356,18 +356,29 @@ local ip_score_check = function(task)
end
end

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

+ 19
- 8
src/plugins/lua/once_received.lua Wyświetl plik

@@ -32,6 +32,7 @@ local whitelist = nil

local rspamd_logger = require "rspamd_logger"
local fun = require "fun"
local N = 'once_received'

local check_local = false
local check_authed = false
@@ -152,17 +153,27 @@ local function check_quantity_received (task)
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']

+ 25
- 4
src/plugins/lua/spamtrap.lua Wyświetl plik

@@ -31,10 +31,11 @@ local settings = {
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()
@@ -42,8 +43,8 @@ local function spamtrap_cb(task)
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
@@ -141,6 +142,26 @@ if not (opts and type(opts) == 'table') then
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

+ 15
- 4
src/plugins/spf.c Wyświetl plik

@@ -206,15 +206,26 @@ spf_module_config (struct rspamd_config *cfg)

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 {

Ładowanie…
Anuluj
Zapisz