aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/elastic.lua
diff options
context:
space:
mode:
authorDmitriy Alekseev <1865999+dragoangel@users.noreply.github.com>2022-09-14 12:16:29 +0300
committerGitHub <noreply@github.com>2022-09-14 12:16:29 +0300
commit09717437a9c72d3a61cd45d9dc2f49a54432d5c0 (patch)
tree0bc12ce372e56787bfacf479f407f06fb9931ce7 /src/plugins/lua/elastic.lua
parent22e5105506338a8177a8ad1e2aeb2c34c5850ac5 (diff)
downloadrspamd-09717437a9c72d3a61cd45d9dc2f49a54432d5c0.tar.gz
rspamd-09717437a9c72d3a61cd45d9dc2f49a54432d5c0.zip
Update elastic.lua
Diffstat (limited to 'src/plugins/lua/elastic.lua')
-rw-r--r--src/plugins/lua/elastic.lua31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/plugins/lua/elastic.lua b/src/plugins/lua/elastic.lua
index 8d20720bc..b93186f9a 100644
--- a/src/plugins/lua/elastic.lua
+++ b/src/plugins/lua/elastic.lua
@@ -121,29 +121,26 @@ local function get_general_metadata(task)
local r = {}
local ip_addr = task:get_ip()
- r.webmail = false
-
if ip_addr and ip_addr:is_valid() then
r.is_local = ip_addr:is_local()
- local origin = task:get_header('X-Originating-IP')
- if origin then
- 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
+ r.ip = tostring(ip_addr)
else
r.ip = '127.0.0.1'
end
+ r.webmail = false
+ r.sender_ip = 'unknown'
+ local origin = task:get_header('X-Originating-IP')
+ if origin then
+ origin = origin:gsub('%[', ''):gsub('%]', '')
+ local rspamd_ip = require "rspamd_ip"
+ local origin_ip = rspamd_ip.from_string(origin)
+ if origin_ip and origin_ip:is_valid() then
+ r.webmail = true
+ r.sender_ip = origin -- use string here
+ end
+ end
+
r.direction = "Inbound"
r.user = task:get_user() or 'unknown'
r.qid = task:get_queue_id() or 'unknown'