summaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/elastic.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-19 15:26:30 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-19 15:26:55 +0000
commit422749d19d44b508f226adbe66072d8a633dcc33 (patch)
tree860277e5c62e668aa7a1698a8252ede2037c49de /src/plugins/lua/elastic.lua
parentbef67cce03e24465a7f7ea1ed2689727fd83a859 (diff)
downloadrspamd-422749d19d44b508f226adbe66072d8a633dcc33.tar.gz
rspamd-422749d19d44b508f226adbe66072d8a633dcc33.zip
[Minor] Fix X-Originating-Ip handle in elastic plugin
Diffstat (limited to 'src/plugins/lua/elastic.lua')
-rw-r--r--src/plugins/lua/elastic.lua12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/lua/elastic.lua b/src/plugins/lua/elastic.lua
index 3c7830de6..854f5ec64 100644
--- a/src/plugins/lua/elastic.lua
+++ b/src/plugins/lua/elastic.lua
@@ -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