@@ -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"); |
@@ -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" |
@@ -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 | |||
@@ -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, | |||
} |