Browse Source

[Minor] Distinguish absent IP address in a more sane way

tags/2.0
Vsevolod Stakhov 4 years ago
parent
commit
d9f755c976
4 changed files with 15 additions and 5 deletions
  1. 12
    2
      src/lua/lua_task.c
  2. 1
    1
      src/plugins/lua/dmarc.lua
  3. 1
    1
      src/plugins/lua/rbl.lua
  4. 1
    1
      src/plugins/lua/settings.lua

+ 12
- 2
src/lua/lua_task.c View File

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

+ 1
- 1
src/plugins/lua/dmarc.lua View File

@@ -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"

+ 1
- 1
src/plugins/lua/rbl.lua View File

@@ -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


+ 1
- 1
src/plugins/lua/settings.lua View File

@@ -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,
}

Loading…
Cancel
Save