diff options
-rw-r--r-- | lualib/lua_maps.lua | 15 | ||||
-rw-r--r-- | rules/rspamd.lua | 2 | ||||
-rw-r--r-- | src/plugins/lua/settings.lua | 10 |
3 files changed, 12 insertions, 15 deletions
diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua index 362f54365..e3ce2af20 100644 --- a/lualib/lua_maps.lua +++ b/lualib/lua_maps.lua @@ -510,21 +510,18 @@ local function rspamd_maybe_check_map(key, what) end if type(rspamd_maps) == "table" then local mn - if starts(what, "map:") then - mn = string.sub(what, 4) - elseif starts(what, "map://") then - mn = string.sub(what, 6) + if starts(key, "map:") then + mn = string.sub(key, 5) + elseif starts(key, "map://") then + mn = string.sub(key, 7) end if mn and rspamd_maps[mn] then - return rspamd_maps[mn]:get_key(key) - else - return what:lower() == key + return rspamd_maps[mn]:get_key(what) end - else - return what:lower() == key end + return what:lower() == key end exports.rspamd_maybe_check_map = rspamd_maybe_check_map diff --git a/rules/rspamd.lua b/rules/rspamd.lua index 98fc5e09e..5d93dec00 100644 --- a/rules/rspamd.lua +++ b/rules/rspamd.lua @@ -57,7 +57,7 @@ local rmaps = rspamd_config:get_all_opt("lua_maps") if rmaps and type(rmaps) == 'table' then local rspamd_logger = require "rspamd_logger" for k,v in pairs(rmaps) do - local status,map_or_err = pcall(rspamd_config:add_map(v)) + local status,map_or_err = pcall(function () return rspamd_config:add_map(v) end) if not status then rspamd_logger.errx(rspamd_config, "cannot add map %s: %s", k, map_or_err) diff --git a/src/plugins/lua/settings.lua b/src/plugins/lua/settings.lua index 136de077a..db2f264e7 100644 --- a/src/plugins/lua/settings.lua +++ b/src/plugins/lua/settings.lua @@ -255,10 +255,10 @@ local function check_ip_setting(expected, ip) else if expected[2] ~= 0 then local nip = ip:apply_mask(expected[2]) - if nip and nip:to_string() == expected[1]:to_string() then + if nip and nip:to_string() == expected[1] then return true end - elseif ip:to_string() == expected[1]:to_string() then + elseif ip:to_string() == expected[1] then return true end end @@ -478,18 +478,18 @@ local function process_ip_condition(ip) local res = rspamd_ip.from_string(ip) if res:is_valid() then - out[1] = res + out[1] = res:to_string() out[2] = 0 else -- It can still be a map - out[1] = res + out[1] = ip end else local res = rspamd_ip.from_string(string.sub(ip, 1, slash - 1)) local mask = tonumber(string.sub(ip, slash + 1)) if res:is_valid() then - out[1] = res + out[1] = res:to_string() out[2] = mask else rspamd_logger.errx(rspamd_config, "bad IP address: " .. ip) |