diff options
author | Andrew Lewis <nerf@judo.za.org> | 2015-08-31 22:37:53 +0200 |
---|---|---|
committer | Andrew Lewis <nerf@judo.za.org> | 2015-09-02 14:10:01 +0200 |
commit | 969e64cef11b6b6fe2cdb71c196464b85d3f27f9 (patch) | |
tree | b69345d06b5c37c527461bf451b6b64c52cff0d9 /src/plugins | |
parent | eca44757e9de09063f0c90240c12db84f0c8a219 (diff) | |
download | rspamd-969e64cef11b6b6fe2cdb71c196464b85d3f27f9.tar.gz rspamd-969e64cef11b6b6fe2cdb71c196464b85d3f27f9.zip |
Allow setting upper & lower limit on IP score
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/lua/ip_score.lua | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/plugins/lua/ip_score.lua b/src/plugins/lua/ip_score.lua index 67d7ece1b..8229e342a 100644 --- a/src/plugins/lua/ip_score.lua +++ b/src/plugins/lua/ip_score.lua @@ -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 |