aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/replies.lua
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2016-09-01 17:25:12 +0200
committerAndrew Lewis <nerf@judo.za.org>2016-09-01 17:25:12 +0200
commitf552edd887794a5086dcf93d36f8f82d83553196 (patch)
tree3e4073dbcd20744cb02caa51d8b12d6e451bcae0 /src/plugins/lua/replies.lua
parent99c2eb287a15649c0dac67065b0254c2a94a768f (diff)
downloadrspamd-f552edd887794a5086dcf93d36f8f82d83553196.tar.gz
rspamd-f552edd887794a5086dcf93d36f8f82d83553196.zip
[Feature] Add common way to disable Lua modules
Diffstat (limited to 'src/plugins/lua/replies.lua')
-rw-r--r--src/plugins/lua/replies.lua41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/plugins/lua/replies.lua b/src/plugins/lua/replies.lua
index 360f14ffe..39eb3705b 100644
--- a/src/plugins/lua/replies.lua
+++ b/src/plugins/lua/replies.lua
@@ -109,23 +109,30 @@ end
local opts = rspamd_config:get_all_opt('replies')
if opts then
- redis_params = rspamd_parse_redis_server('replies')
- if not redis_params then
- rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
- else
- rspamd_config:register_symbol({
- name = 'REPLIES_SET',
- type = 'postfilter',
- callback = replies_set,
- priority = 10
- })
- rspamd_config:register_symbol({
- name = 'REPLIES_CHECK',
- type = 'prefilter',
- callback = replies_check,
- priority = 10
- })
- end
+ if not (opts and type(opts) == 'table') then
+ rspamd_logger.info('Module is unconfigured')
+ return
+ elseif opts['enabled'] == false then
+ rspamd_logger.info('Module is disabled')
+ return
+ end
+ redis_params = rspamd_parse_redis_server('replies')
+ if not redis_params then
+ rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
+ else
+ rspamd_config:register_symbol({
+ name = 'REPLIES_SET',
+ type = 'postfilter',
+ callback = replies_set,
+ priority = 10
+ })
+ rspamd_config:register_symbol({
+ name = 'REPLIES_CHECK',
+ type = 'prefilter',
+ callback = replies_check,
+ priority = 10
+ })
+ end
for k,v in pairs(opts) do
settings[k] = v