aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/settings.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-19 15:01:30 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-08-19 15:01:30 +0100
commit6965bc635343062e237a8921d2cb818d75792b37 (patch)
treeb1472cfd45ee4869cb9182702ca9b2b292e46c12 /src/plugins/lua/settings.lua
parent2f355af6708b43da2b2aea0834f24be4e58a6af7 (diff)
downloadrspamd-6965bc635343062e237a8921d2cb818d75792b37.tar.gz
rspamd-6965bc635343062e237a8921d2cb818d75792b37.zip
Fix settings priorities.
Diffstat (limited to 'src/plugins/lua/settings.lua')
-rw-r--r--src/plugins/lua/settings.lua20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index 07fb2d3de..a79157e3b 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -5,6 +5,7 @@
local set_section = rspamd_config:get_key("settings")
local settings = {}
local settings_initialized = false
+local max_pri = 0
-- Functional utilities
local function filter(func, tbl)
@@ -117,13 +118,15 @@ local function check_settings(task)
local from = task:get_from()
local rcpt = task:get_recipients()
-- Match rules according their order
- for i,v in pairs(settings) do
- for name, rule in pairs(v) do
- local rule = check_specific_setting(name, rule, ip, from, rcpt)
- if rule then
- rspamd_logger.info(string.format("<%s> apply settings according to rule %s",
- task:get_message_id(), name))
- task:set_settings(rule)
+ for pri = max_pri,1,-1 do
+ if settings[pri] then
+ for name, rule in pairs(settings[pri]) do
+ local rule = check_specific_setting(name, rule, ip, from, rcpt)
+ if rule then
+ rspamd_logger.info(string.format("<%s> apply settings according to rule %s",
+ task:get_message_id(), name))
+ task:set_settings(rule)
+ end
end
end
end
@@ -288,10 +291,12 @@ local function process_settings_table(tbl)
end, tbl)
-- clear all settings
+ max_pri = 0
for k,v in pairs(settings) do settings[k]=nil end
-- fill new settings by priority
for k,v in pairs(ft) do
local pri = get_priority(v)
+ if pri > max_pri then max_pri = pri end
if not settings[pri] then
settings[pri] = {}
end
@@ -300,6 +305,7 @@ local function process_settings_table(tbl)
settings[pri][k] = s
end
end
+
settings_initialized = true
--local dumper = require 'pl.pretty'.dump
--dumper(settings)