-- Check whitelist
if whitelist then
local ipnum = task:get_from_ip():to_number()
- if ipnum and whitelist:get_key(ipnum) then
+ if task:get_from_ip():is_valid() and whitelist:get_key(ipnum) then
-- Address is whitelisted
return
end
-- Now check action
if action == 'reject' then
local ip = task:get_from_ip()
- if ip then
+ if ip:is_valid() then
local cb = make_key_cb(ip)
if reject_score > 0 then
rspamd_redis.make_request(task, keystorage_host, keystorage_port, cb, 'INCRBY %b %b', ip, reject_score)
end
elseif action == 'add header' then
local ip = task:get_from_ip()
- if ip then
+ if ip:is_valid() then
local cb = make_key_cb(ip)
if add_header_score > 0 then
rspamd_redis.make_request(task, keystorage_host, keystorage_port, cb, 'INCRBY %b %b', ip, add_header_score)
end
elseif action == 'no action' then
local ip = task:get_from_ip()
- if ip then
+ if ip:is_valid() then
local cb = make_key_cb(ip)
if no_action_score > 0 then
rspamd_redis.make_request(task, keystorage_host, keystorage_port, cb, 'INCRBY %b %b', ip, no_action_score)
end
end
local ip = task:get_from_ip()
- if ip then
+ if ip:is_valid() then
if whitelist then
local ipnum = task:get_from_ip():to_number()
if whitelist:get_key(ipnum) then
if rule['type'] == 'ip' then
if rule['cdb'] then
local ip = task:get_from_ip()
- if ip and rule['hash']:lookup(ip) then
+ if ip:is_valid() and rule['hash']:lookup(ip) then
task:insert_result(rule['symbol'], 1)
end
else
local ip = task:get_from_ip():to_number()
- if ip and rule['ips'] and rule['ips']:get_key(ip) then
+ if ip:is_valid() and rule['ips'] and rule['ips']:get_key(ip) then
task:insert_result(rule['symbol'], 1)
end
end
end
elseif rule['type'] == 'dnsbl' then
local ip = task:get_from_ip()
- if ip and ip:to_string() ~= "0.0.0.0" then
+ if ip:is_valid() then
if ip:get_version() == 6 and rule['ipv6'] then
task:get_resolver():resolve_a(task:get_session(), task:get_mempool(),
ip_to_rbl(ip, rule['map']), multimap_rbl_cb, rule['map'])