aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Kuron <m.kuron@gmx.de>2017-09-01 19:44:48 +0200
committerMichael Kuron <m.kuron@gmx.de>2017-09-01 19:46:16 +0200
commit1b320f794510d741771de2c5dea1dcd35d5ff835 (patch)
tree8211f5833dce169f9945f4bea9f25fe3257905bd /src
parent2b872fd3c7cf6b5ca9defd4c7e025cf46816d0ff (diff)
downloadrspamd-1b320f794510d741771de2c5dea1dcd35d5ff835.tar.gz
rspamd-1b320f794510d741771de2c5dea1dcd35d5ff835.zip
User settings: add header rules
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lua/settings.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index 8f75d15c3..7d28f2545 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -250,6 +250,19 @@ local function check_settings(task)
end
end
+ if rule['header'] then
+ for k, v in pairs(rule['header']) do
+ local h = task:get_header(k)
+ res = (h and v:match(h))
+ if res then
+ break
+ end
+ end
+ if not res then
+ return nil
+ end
+ end
+
if res then
if rule['whitelist'] then
rule['apply'] = {whitelist = true}
@@ -483,6 +496,19 @@ local function process_settings_table(tbl)
end
out['request_header'] = rho
end
+ if elt['header'] then
+ local rho = {}
+ for k, v in pairs(elt['header']) do
+ local re = rspamd_regexp.get_cached(v)
+ if not re then
+ re = rspamd_regexp.create_cached(v)
+ end
+ if re then
+ rho[k] = re
+ end
+ end
+ out['header'] = rho
+ end
-- Now we must process actions
if elt['symbols'] then out['symbols'] = elt['symbols'] end