]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Use new postfilters and prefilters API in the plugins
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Jul 2016 16:22:31 +0000 (17:22 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Jul 2016 16:22:31 +0000 (17:22 +0100)
src/plugins/lua/fann_scores.lua
src/plugins/lua/greylist.lua
src/plugins/lua/ip_score.lua
src/plugins/lua/multimap.lua
src/plugins/lua/ratelimit.lua
src/plugins/lua/replies.lua
src/plugins/lua/settings.lua

index 98b0f7849e19ce2b38cc568726d5b54a65a78b8c..c62923521a5e263c10f3cd06537b13cea5567760 100644 (file)
@@ -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
index 09c587b8b5d1f5d663c569077b42f5f0a9ec1310..226d3eef23eaf375e8859454968e847c31b6e09a 100644 (file)
@@ -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
index 1541038fef977510299335097b85ff5d0ca0f77a..f3f4800b283d3b05e6cdf2ca128c9eb08e0d0bd1 100644 (file)
@@ -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
index 690953be05e027a03a5acdc97f271e5dc73b81f0..de20bb32391b43e628ef5563bc8b2509b40f4892 100644 (file)
@@ -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
index e73dc63edba5237d64596ec41bee6fa3b8ca008d..f6ac4893cdfb179a4940caf19cba6048e08449b6 100644 (file)
@@ -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
 
index 106a738cbd3efb09379d70a702b0a37b485a0b2b..631ee02d045827e3559cd7aff6691d7847143815 100644 (file)
@@ -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
index 0621914a3f9f659b3bea955ac09a5215a4712a8a..ed44e2dba55fcdd9cf7ee68d325ef8fc3b8a40bb 100644 (file)
@@ -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
+})