aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-21 09:43:53 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2015-12-21 09:43:53 +0000
commit1714e4eb3d03b3a23c8c6ba51497868b9f54f808 (patch)
tree5bf321cfe8c7bfb98991ff94e34cf2b84e3eb63a /src
parent2d840d3532cf0f72b022e1bcc2afb2ed6ea7e17b (diff)
downloadrspamd-1714e4eb3d03b3a23c8c6ba51497868b9f54f808.tar.gz
rspamd-1714e4eb3d03b3a23c8c6ba51497868b9f54f808.zip
Do not parse URLs for getting TLD in lua
Diffstat (limited to 'src')
-rw-r--r--src/plugins/lua/dmarc.lua8
-rw-r--r--src/plugins/lua/rbl.lua38
-rw-r--r--src/plugins/lua/whitelist.lua9
3 files changed, 22 insertions, 33 deletions
diff --git a/src/plugins/lua/dmarc.lua b/src/plugins/lua/dmarc.lua
index 01eb3bfb1..f9bf43ccc 100644
--- a/src/plugins/lua/dmarc.lua
+++ b/src/plugins/lua/dmarc.lua
@@ -32,6 +32,7 @@ local rspamd_logger = require "rspamd_logger"
local rspamd_redis = require "rspamd_redis"
local rspamd_url = require "rspamd_url"
local upstream_list = require "rspamd_upstream_list"
+local rspamd_util = require "rspamd_util"
--local dumper = require 'pl.pretty'.dump
@@ -67,12 +68,7 @@ local function dmarc_callback(task)
local dmarc_domain
if from and from[1] and from[1]['domain'] and not from[2] then
- local url_from = rspamd_url.create(task:get_mempool(), from[1]['domain'])
- if url_from then
- dmarc_domain = url_from:get_tld()
- else
- return
- end
+ dmarc_domain = rspamd_util.get_tld(from[1]['domain'])
else
return
end
diff --git a/src/plugins/lua/rbl.lua b/src/plugins/lua/rbl.lua
index c1ea77ef1..0a2b9bdd9 100644
--- a/src/plugins/lua/rbl.lua
+++ b/src/plugins/lua/rbl.lua
@@ -36,6 +36,7 @@ local private_ips = nil
local rspamd_logger = require 'rspamd_logger'
local rspamd_ip = require 'rspamd_ip'
local rspamd_url = require 'rspamd_url'
+local rspamd_util = require 'rspamd_util'
local symbols = {
dkim_allow_symbol = 'R_DKIM_ALLOW',
@@ -163,8 +164,8 @@ local function rbl_cb (task)
end
end
task:get_resolver():resolve_a({task = task,
- name = havegot['helo'] .. '.' .. rbl['rbl'],
- callback = rbl_dns_cb,
+ name = havegot['helo'] .. '.' .. rbl['rbl'],
+ callback = rbl_dns_cb,
option = k})
end)()
end
@@ -185,17 +186,12 @@ local function rbl_cb (task)
end
for _, d in ipairs(havegot['dkim']) do
if rbl['dkim_domainonly'] then
- local url_from = rspamd_url.create(task:get_mempool(), d)
- if url_from then
- d = url_from:get_tld()
- else
- return
- end
+ d = rspamd_util.get_tld(d)
end
-
+
task:get_resolver():resolve_a({task = task,
- name = d .. '.' .. rbl['rbl'],
- callback = rbl_dns_cb,
+ name = d .. '.' .. rbl['rbl'],
+ callback = rbl_dns_cb,
option = k})
end
end)()
@@ -224,7 +220,7 @@ local function rbl_cb (task)
if validate_dns(localpart) and validate_dns(domainpart) then
table.insert(cleanList, localpart .. '.' .. domainpart)
end
- end
+ end
end
havegot['emails'] = cleanList
if not next(havegot['emails']) then
@@ -235,15 +231,15 @@ local function rbl_cb (task)
if rbl['emails'] == 'domain_only' then
for domain, _ in pairs(havegot['emails']) do
task:get_resolver():resolve_a({task = task,
- name = domain .. '.' .. rbl['rbl'],
- callback = rbl_dns_cb,
+ name = domain .. '.' .. rbl['rbl'],
+ callback = rbl_dns_cb,
option = k})
end
else
for _, email in pairs(havegot['emails']) do
task:get_resolver():resolve_a({task = task,
- name = email .. '.' .. rbl['rbl'],
- callback = rbl_dns_cb,
+ name = email .. '.' .. rbl['rbl'],
+ callback = rbl_dns_cb,
option = k})
end
end
@@ -264,7 +260,7 @@ local function rbl_cb (task)
end
task:get_resolver():resolve_a({task = task,
name = havegot['rdns'] .. '.' .. rbl['rbl'],
- callback = rbl_dns_cb,
+ callback = rbl_dns_cb,
option = k})
end)()
end
@@ -284,8 +280,8 @@ local function rbl_cb (task)
if (havegot['from']:get_version() == 6 and rbl['ipv6']) or
(havegot['from']:get_version() == 4 and rbl['ipv4']) then
task:get_resolver():resolve_a({task = task,
- name = ip_to_rbl(havegot['from'], rbl['rbl']),
- callback = rbl_dns_cb,
+ name = ip_to_rbl(havegot['from'], rbl['rbl']),
+ callback = rbl_dns_cb,
option = k})
end
end)()
@@ -311,8 +307,8 @@ local function rbl_cb (task)
not rbl['exclude_private_ips']) and ((rbl['exclude_local_ips'] and
not is_excluded_ip(rh['real_ip'])) or not rbl['exclude_local_ips']) then
task:get_resolver():resolve_a({task = task,
- name = ip_to_rbl(rh['real_ip'], rbl['rbl']),
- callback = rbl_dns_cb,
+ name = ip_to_rbl(rh['real_ip'], rbl['rbl']),
+ callback = rbl_dns_cb,
option = k})
end
end
diff --git a/src/plugins/lua/whitelist.lua b/src/plugins/lua/whitelist.lua
index 6bcc84bba..3028a279f 100644
--- a/src/plugins/lua/whitelist.lua
+++ b/src/plugins/lua/whitelist.lua
@@ -26,6 +26,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
local rspamd_logger = require "rspamd_logger"
local rspamd_url = require "rspamd_url"
+local rspamd_util = require "rspamd_util"
local ucl = require "ucl"
require "fun" ()
@@ -41,14 +42,10 @@ local function whitelist_cb(symbol, rule, task)
local from = task:get_from(1)
if from and from[1] and from[1]['domain'] then
local domain = from[1]['domain']
- local url_domain = rspamd_url.create(task:get_mempool(), 'http://' .. domain)
+ domain = rspamd_util.get_tld(domain)
local found = false
local mult = 1.0
- if url_domain then
- domain = url_domain:get_tld()
- end
-
if rule['map'] then
local val = rule['map']:get_key(domain)
if val then
@@ -191,4 +188,4 @@ local configure_whitelist_module = function()
end
end
-configure_whitelist_module() \ No newline at end of file
+configure_whitelist_module()