]> source.dussan.org Git - rspamd.git/commitdiff
Allow setting upper & lower limit on IP score 353/head
authorAndrew Lewis <nerf@judo.za.org>
Mon, 31 Aug 2015 20:37:53 +0000 (22:37 +0200)
committerAndrew Lewis <nerf@judo.za.org>
Wed, 2 Sep 2015 12:10:01 +0000 (14:10 +0200)
src/plugins/lua/ip_score.lua

index 67d7ece1b87d162fe2bd0f60bd204f1e0e2c516e..8229e342a86c64965861aedb6f48416e7213bf9c 100644 (file)
@@ -59,7 +59,9 @@ local options = {
   ipnet_prefix = 'n:', -- prefix for ipnet hashes
   servers = '', -- list of servers
   lower_bound = 10, -- minimum number of messages to be scored
-  metric = 'default'
+  metric = 'default',
+  min_score = nil,
+  max_score = nil
 }
 
 local asn_re = rspamd_regexp.create_cached("[\\|\\s]")
@@ -185,7 +187,7 @@ local ip_score_set = function(task)
   local hkey = ip_score_hash_key(asn, country, ipnet, ip)
   local upstream = upstreams:get_upstream_by_hash(hkey)
   local addr = upstream:get_addr()
-
   asn_score,total_asn = new_score_set(score, asn_score, total_asn)
   country_score,total_country = new_score_set(score, country_score, total_country)
   ipnet_score,total_ipnet = new_score_set(score, ipnet_score, total_ipnet)
@@ -274,7 +276,10 @@ local ip_score_check = function(task)
         total_score = total_score + country_score
         table.insert(description_t, 'country: ' .. country .. '(' .. math.floor(country_score * 1000) / 100 .. ')')
       end
-      
+
+      if options['max_score'] and (total_score*10) > options['max_score'] then total_score = options['max_score']/10 end
+      if options['min_score'] and (total_score*10) < options['min_score'] then total_score = options['min_score']/10 end
       if total_score ~= 0 then
         task:insert_result(options['symbol'], total_score, table.concat(description_t, ', '))
       end