summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2015-02-17 12:47:17 +0200
committerAndrew Lewis <nerf@judo.za.org>2015-02-17 12:48:41 +0200
commit9ad2a7d1e58101e4dea0695a6d56bce7a1f4bce3 (patch)
tree5220ce2d5c0d80c4733a210272c9889a1e8e40c6
parent6088c2b15fec2aad5043a8b29b1ef250ae7d90dd (diff)
downloadrspamd-9ad2a7d1e58101e4dea0695a6d56bce7a1f4bce3.tar.gz
rspamd-9ad2a7d1e58101e4dea0695a6d56bce7a1f4bce3.zip
Support emails dnsbl
-rw-r--r--conf/modules.conf19
-rw-r--r--src/plugins/lua/rbl.lua51
2 files changed, 62 insertions, 8 deletions
diff --git a/conf/modules.conf b/conf/modules.conf
index 1a4185c97..1fd71f2ed 100644
--- a/conf/modules.conf
+++ b/conf/modules.conf
@@ -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;
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index 625333f01..852fe1f04 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -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