aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/settings.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-29 15:29:51 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-29 15:29:51 +0100
commit1424d904c9c5cb1593b369949354d376af56f111 (patch)
tree5689e151a760c0f7dcdcfa44f095653622bc4f52 /src/plugins/lua/settings.lua
parent64e862aae0b7257ff7688f1e1fe2c4d77720ab56 (diff)
downloadrspamd-1424d904c9c5cb1593b369949354d376af56f111.tar.gz
rspamd-1424d904c9c5cb1593b369949354d376af56f111.zip
[Feature] Allow to select settings by id in HTTP query
Diffstat (limited to 'src/plugins/lua/settings.lua')
-rw-r--r--src/plugins/lua/settings.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index 621e33a2b..5b27d4b66 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -25,6 +25,7 @@ local settings = {
[2] = {},
[3] = {}
}
+local settings_ids = {}
local settings_initialized = false
local max_pri = 0
local rspamd_logger = require "rspamd_logger"
@@ -73,6 +74,16 @@ local function check_query_settings(task)
end
end
+ local settings_id = task:get_request_header('settings-id')
+ if settings_id and settings_initialized then
+ local elt = settings_ids[settings_id]
+ if elt and elt['apply'] then
+ task:set_settings(elt['apply'])
+
+ return true
+ end
+ end
+
return false
end
@@ -398,6 +409,11 @@ local function process_settings_table(tbl)
-- Now we must process actions
if elt['symbols'] then out['symbols'] = elt['symbols'] end
+ if elt['id'] then
+ out['id'] = elt['id']
+ settings[elt['id']] = out
+ end
+
if elt['apply'] then
-- Just insert all metric results to the action key
out['apply'] = elt['apply']
@@ -424,6 +440,7 @@ local function process_settings_table(tbl)
-- clear all settings
max_pri = 0
local nrules = 0
+ settings_ids = {}
for k,v in pairs(settings) do settings[k]={} end
-- fill new settings by priority
for_each(function(k, v)