From 437727abc962967796b726814dcdf9d3c713a475 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 12 Jul 2016 17:22:31 +0100 Subject: [PATCH] [Fix] Use new postfilters and prefilters API in the plugins --- src/plugins/lua/fann_scores.lua | 7 +++++-- src/plugins/lua/greylist.lua | 13 +++++++++++-- src/plugins/lua/ip_score.lua | 12 ++++++++++-- src/plugins/lua/multimap.lua | 6 +++++- src/plugins/lua/ratelimit.lua | 12 ++++++++++-- src/plugins/lua/replies.lua | 13 +++++++++++-- src/plugins/lua/settings.lua | 7 ++++++- 7 files changed, 58 insertions(+), 12 deletions(-) diff --git a/src/plugins/lua/fann_scores.lua b/src/plugins/lua/fann_scores.lua index 98b0f7849..c62923521 100644 --- a/src/plugins/lua/fann_scores.lua +++ b/src/plugins/lua/fann_scores.lua @@ -255,8 +255,11 @@ else fann_file = opts['fann_file'] use_settings = opts['use_settings'] rspamd_config:set_metric_symbol(fann_symbol, 3.0, 'Experimental FANN adjustment') - rspamd_config:register_post_filter(fann_scores_filter) - + rspamd_config:register_symbol({ + name = fann_symbol, + type = 'postfilter', + callback = fann_scores_filter + }) if opts['train'] then rspamd_config:add_on_load(function(cfg) if opts['train']['max_train'] then diff --git a/src/plugins/lua/greylist.lua b/src/plugins/lua/greylist.lua index 09c587b8b..226d3eef2 100644 --- a/src/plugins/lua/greylist.lua +++ b/src/plugins/lua/greylist.lua @@ -323,8 +323,17 @@ if opts then if not redis_params then rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module') else - rspamd_config:register_pre_filter(greylist_check) - rspamd_config:register_post_filter(greylist_set, 10) + rspamd_config:register_symbol({ + name = 'GREYLIST_SAVE', + type = 'postfilter', + callback = greylist_set, + priority = 10 + }) + rspamd_config:register_symbol({ + name = 'GREYLIST_SAVE', + type = 'prefilter', + callback = greylist_check, + }) end for k,v in pairs(opts) do diff --git a/src/plugins/lua/ip_score.lua b/src/plugins/lua/ip_score.lua index 1541038fe..f3f4800b2 100644 --- a/src/plugins/lua/ip_score.lua +++ b/src/plugins/lua/ip_score.lua @@ -365,11 +365,19 @@ configure_ip_score_module() if redis_params then -- Register ip_score module if options['asn_provider'] then - rspamd_config:register_pre_filter(asn_check) + rspamd_config:register_symbol({ + name = 'ASN_CHECK', + type = 'prefilter', + callback = asn_check, + }) end + rspamd_config:register_symbol({ + name = 'IPSCORE_SAVE', + type = 'postfilter', + callback = ip_score_set, + }) rspamd_config:register_symbol({ name = options['symbol'], callback = ip_score_check }) - rspamd_config:register_post_filter(ip_score_set) end diff --git a/src/plugins/lua/multimap.lua b/src/plugins/lua/multimap.lua index 690953be0..de20bb323 100644 --- a/src/plugins/lua/multimap.lua +++ b/src/plugins/lua/multimap.lua @@ -572,6 +572,10 @@ if opts and type(opts) == 'table' then end if _.any(function(r) return r['prefilter'] end, rules) then - rspamd_config:register_pre_filter(multimap_prefilter_callback) + rspamd_config:register_symbol({ + type = 'prefilter', + name = 'MULTIMAP_PREFILTERS', + callback = multimap_prefilter_callback + }) end end diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index e73dc63ed..f6ac4893c 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -415,7 +415,11 @@ if opts then rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module') else if not ratelimit_symbol then - rspamd_config:register_pre_filter(rate_test) + rspamd_config:register_symbol({ + name = 'RATELIMIT_CHECK', + type = 'prefilter', + callback = rate_test, + }) else rspamd_config:register_symbol({ name = ratelimit_symbol, @@ -424,7 +428,11 @@ if opts then }) end - rspamd_config:register_post_filter(rate_set) + rspamd_config:register_symbol({ + name = 'RATELIMIT_SET', + type = 'postfilter', + callback = rate_set, + }) end end diff --git a/src/plugins/lua/replies.lua b/src/plugins/lua/replies.lua index 106a738cb..631ee02d0 100644 --- a/src/plugins/lua/replies.lua +++ b/src/plugins/lua/replies.lua @@ -113,8 +113,17 @@ if opts then if not redis_params then rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module') else - rspamd_config:register_pre_filter(replies_check) - rspamd_config:register_post_filter(replies_set, 10) + 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, + }) end for k,v in pairs(opts) do diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index 0621914a3..ed44e2dba 100644 --- a/src/plugins/lua/settings.lua +++ b/src/plugins/lua/settings.lua @@ -493,4 +493,9 @@ elseif set_section and type(set_section) == "table" then process_settings_table(set_section) end -rspamd_config:register_pre_filter(check_settings) +rspamd_config:register_symbol({ + name = 'SETTINGS_CHECK', + type = 'prefilter', + callback = check_settings, + priority = 10 +}) -- 2.39.5