]> source.dussan.org Git - rspamd.git/commitdiff
User settings: add header rules 1821/head
authorMichael Kuron <m.kuron@gmx.de>
Fri, 1 Sep 2017 17:44:48 +0000 (19:44 +0200)
committerMichael Kuron <m.kuron@gmx.de>
Fri, 1 Sep 2017 17:46:16 +0000 (19:46 +0200)
src/plugins/lua/settings.lua

index 8f75d15c3d7253e95057b4e35d0b109db2a3979f..7d28f254559f2f5fd93940898f27ef8944a0dda0 100644 (file)
@@ -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