From: Vsevolod Stakhov Date: Mon, 19 Mar 2018 15:26:30 +0000 (+0000) Subject: [Minor] Fix X-Originating-Ip handle in elastic plugin X-Git-Tag: 1.7.1~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=422749d19d44b508f226adbe66072d8a633dcc33;p=rspamd.git [Minor] Fix X-Originating-Ip handle in elastic plugin --- 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