diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-26 13:16:19 +0200 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2016-10-26 13:16:19 +0200 |
commit | a00b17d54e8fa92fb9e2f03df90d3089608bcf1a (patch) | |
tree | 1b19ab1c3795b15d05a71c85351e30a89b9abc48 /src/plugins/lua/dynamic_conf.lua | |
parent | 9d14da102659f864a908d9aabc52d31fe12c8e9d (diff) | |
download | rspamd-a00b17d54e8fa92fb9e2f03df90d3089608bcf1a.tar.gz rspamd-a00b17d54e8fa92fb9e2f03df90d3089608bcf1a.zip |
[Minor] Use alpha cmp for scores in dynamic conf
Diffstat (limited to 'src/plugins/lua/dynamic_conf.lua')
-rw-r--r-- | src/plugins/lua/dynamic_conf.lua | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/plugins/lua/dynamic_conf.lua b/src/plugins/lua/dynamic_conf.lua index ab7812c86..7bfbc6cb8 100644 --- a/src/plugins/lua/dynamic_conf.lua +++ b/src/plugins/lua/dynamic_conf.lua @@ -35,6 +35,15 @@ local cur_settings = { } } +local function alpha_cmp(v1, v2) + local math = math + if math.abs(v1 - v2) < 0.001 then + return true + end + + return false +end + local function redis_make_request(ev_base, cfg, key, is_write, callback, command, args) if not ev_base or not redis_params or not callback or not command then return false,nil,nil @@ -100,7 +109,7 @@ local function apply_dynamic_actions(cfg, acts) end end, filter(function(k, v) local act = rspamd_config:get_metric_action(k) - if (act and act == v) or cur_settings.updates.actions[k] then + if (act and alpha_cmp(act, v)) or cur_settings.updates.actions[k] then return false end @@ -126,7 +135,7 @@ local function apply_dynamic_scores(cfg, sc) end, filter(function(k, v) -- Select elts with scores that are different from local ones local sym = rspamd_config:get_metric_symbol(k) - if (sym and sym.score == v) or cur_settings.updates.symbols[k] then + if (sym and alpha_cmp(sym.score, v)) or cur_settings.updates.symbols[k] then return false end @@ -181,7 +190,7 @@ local function update_dynamic_conf(cfg, ev_base, recv) cur_settings.data.scores = {} end each(function(k, v) - cur_settings.data.score[k] = v + cur_settings.data.scores[k] = v end, filter(function(k,v) if cur_settings.updates.symbols[k] then |