]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix X-Originating-Ip handle in elastic plugin
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Mar 2018 15:26:30 +0000 (15:26 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Mon, 19 Mar 2018 15:26:55 +0000 (15:26 +0000)
src/plugins/lua/elastic.lua

index 3c7830de6a5712672c12603237dbc9e492625045..854f5ec644840bc7b7d481771b9703d5be44713f 100644 (file)
@@ -120,8 +120,16 @@ local function get_general_metadata(task)
     r.is_local = ip_addr:is_local()
     local origin = task:get_header('X-Originating-IP')
     if origin then
-      r.webmail = true
-      r.ip = origin
+      origin = string.sub(origin, 2, -2)
+      local rspamd_ip = require "rspamd_ip"
+      local test = rspamd_ip.from_string(origin)
+
+      if test and test:is_valid() then
+        r.webmail = true
+        r.ip = origin
+      else
+        r.ip = tostring(ip_addr)
+      end
     else
       r.ip = tostring(ip_addr)
     end