diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-02 12:55:55 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-02 12:55:55 +0100 |
commit | 4c9f6b21186be5c87785d5f6c91fb26cb8300b5b (patch) | |
tree | 74802fea670606876175e8bccef2d41a4986bc65 /src/plugins/lua/spamtrap.lua | |
parent | 0b7bbd9a1df25d3cf93173dc0f853d1863930ae8 (diff) | |
download | rspamd-4c9f6b21186be5c87785d5f6c91fb26cb8300b5b.tar.gz rspamd-4c9f6b21186be5c87785d5f6c91fb26cb8300b5b.zip |
[Minor] Unify check_auth/check_local options
Diffstat (limited to 'src/plugins/lua/spamtrap.lua')
-rw-r--r-- | src/plugins/lua/spamtrap.lua | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/plugins/lua/spamtrap.lua b/src/plugins/lua/spamtrap.lua index cf0b89957..f1582f8ce 100644 --- a/src/plugins/lua/spamtrap.lua +++ b/src/plugins/lua/spamtrap.lua @@ -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 |