Browse Source

Support emails dnsbl

tags/0.9.0
Andrew Lewis 9 years ago
parent
commit
9ad2a7d1e5
2 changed files with 62 additions and 8 deletions
  1. 12
    7
      conf/modules.conf
  2. 50
    1
      src/plugins/lua/rbl.lua

+ 12
- 7
conf/modules.conf View File

@@ -201,6 +201,16 @@ rbl {
}
}

rambleremails {
symbol = RAMBLER_EMAILBL;
rbl = email-bl.rambler.ru;
from = false;
emails = true;
exclude_users = false;
exclude_private_ips = false;
exclude_local = false;
}

}
}

@@ -222,13 +232,8 @@ once_received {
phishing {
symbol = "PHISHING";
}
emails {
rule {
symbol = RAMBLER_EMAILBL;
dnsbl = email-bl.rambler.ru;
domain_only = false;
}
}
#emails {
#}
spf {
spf_cache_size = 2k;
spf_cache_expire = 1d;

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

@@ -165,6 +165,51 @@ local function rbl_cb (task)
end)()
end

if rbl['emails'] then
(function()
if notgot['emails'] then
return
end
if not havegot['emails'] then
havegot['emails'] = task:get_emails()
if havegot['emails'] == nil then
notgot['emails'] = true
return
end
local cleanList = {}
for _, e in pairs(havegot['emails']) do
local localpart = e:get_user()
local domainpart = e:get_host()
if rbl['emails'] == 'domain_only' then
if not cleanList[domainpart] and validate_dns(domainpart) then
cleanList[domainpart] = true
end
else
if validate_dns(localpart) and validate_dns(domainpart) then
table.insert(cleanList, localpart .. '.' .. domainpart)
end
end
end
havegot['emails'] = cleanList
if not next(havegot['emails']) then
notgot['emails'] = true
return
end
end
if rbl['emails'] == 'domain_only' then
for domain, _ in pairs(havegot['emails']) do
task:get_resolver():resolve_a(task:get_session(), task:get_mempool(),
domain .. '.' .. rbl['rbl'], rbl_dns_cb, k)
end
else
for _, email in pairs(havegot['emails']) do
task:get_resolver():resolve_a(task:get_session(), task:get_mempool(),
email .. '.' .. rbl['rbl'], rbl_dns_cb, k)
end
end
end)()
end

if rbl['rdns'] then
(function()
if notgot['rdns'] then
@@ -248,6 +293,7 @@ if type(rspamd_config.get_api_version) ~= 'nil' then
rspamd_config:register_module_option('rbl', 'local_exclude_ip_map', 'string')
rspamd_config:register_module_option('rbl', 'default_exclude_local', 'string')
rspamd_config:register_module_option('rbl', 'private_ips', 'string')
rspamd_config:register_module_option('rbl', 'default_emails', 'string')
end
end

@@ -286,6 +332,9 @@ end
if(opts['default_exclude_local'] == nil) then
opts['default_exclude_local'] = true
end
if(opts['default_emails'] == nil) then
opts['default_emails'] = false
end
if(opts['local_exclude_ip_map'] ~= nil) then
local_exclusions = rspamd_config:add_radix_map(opts['local_exclude_ip_map'])
end
@@ -296,7 +345,7 @@ end
for key,rbl in pairs(opts['rbls']) do
local o = {
"ipv4", "ipv6", "from", "received", "unknown", "rdns", "helo", "exclude_users",
"exclude_private_ips", "exclude_local"
"exclude_private_ips", "exclude_local", "emails"
}
for i=1,table.maxn(o) do
if(rbl[o[i]] == nil) then

Loading…
Cancel
Save