aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lua/lua_task.c14
-rw-r--r--src/plugins/lua/dmarc.lua2
-rw-r--r--src/plugins/lua/rbl.lua2
-rw-r--r--src/plugins/lua/settings.lua2
4 files changed, 15 insertions, 5 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index b04596ed3..97523a1fa 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -3843,7 +3843,12 @@ lua_task_get_from_ip (lua_State *L)
struct rspamd_task *task = lua_check_task (L, 1);
if (task) {
- rspamd_lua_ip_push (L, task->from_addr);
+ if (task->from_addr) {
+ rspamd_lua_ip_push (L, task->from_addr);
+ }
+ else {
+ lua_pushnil (L);
+ }
}
else {
return luaL_error (L, "invalid arguments");
@@ -3901,7 +3906,12 @@ lua_task_get_client_ip (lua_State *L)
struct rspamd_task *task = lua_check_task (L, 1);
if (task) {
- rspamd_lua_ip_push (L, task->client_addr);
+ if (task->client_addr) {
+ rspamd_lua_ip_push (L, task->client_addr);
+ }
+ else {
+ lua_pushnil (L);
+ }
}
else {
return luaL_error (L, "invalid arguments");
diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua
index f922f63d2..ab8a3bf53 100644
--- a/src/plugins/lua/dmarc.lua
+++ b/src/plugins/lua/dmarc.lua
@@ -181,7 +181,7 @@ local dmarc_grammar = gen_dmarc_grammar()
local function dmarc_report(task, spf_ok, dkim_ok, disposition,
sampled_out, hfromdom, spfdom, dres, spf_result)
local ip = task:get_from_ip()
- if not ip:is_valid() then
+ if ip and not ip:is_valid() then
return nil
end
local rspamd_lua_utils = require "lua_util"
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index 7016d9c5e..f66186fa6 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -391,7 +391,7 @@ local function gen_rbl_callback(rule)
local function check_local(task, _)
local ip = task:get_from_ip()
- if not ip:is_valid() then
+ if ip and not ip:is_valid() then
ip = nil
end
diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua
index 5fe2353d4..0f895dc0b 100644
--- a/src/plugins/lua/settings.lua
+++ b/src/plugins/lua/settings.lua
@@ -552,7 +552,7 @@ local function process_settings_table(tbl, allow_ids, mempool)
check = gen_check_closure(convert_to_table(elt.ip, ips_table), check_ip_setting),
extract = function(task)
local ip = task:get_from_ip()
- if ip:is_valid() then return ip end
+ if ip and ip:is_valid() then return ip end
return nil
end,
}