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