local rules = {}
local rspamd_logger = require "rspamd_logger"
-local util = require "rspamd_util"
-local regexp = require "rspamd_regexp"
+local rspamd_util = require "rspamd_util"
+local rspamd_regexp = require "rspamd_regexp"
local rspamd_expression = require "rspamd_expression"
local rspamd_ip = require "rspamd_ip"
local lua_util = require "lua_util"
local function apply_hostname_filter(task, filter, hostname, r)
if filter == 'tld' then
- local tld = util.get_tld(hostname)
+ local tld = rspamd_util.get_tld(hostname)
return tld
elseif filter == 'top' then
- local tld = util.get_tld(hostname)
+ local tld = rspamd_util.get_tld(hostname)
return tld:match('[^.]*$') or tld
else
if not r['re_filter'] then
rspamd_logger.errx(task, 'bad search filter: %s', filter)
return
end
- r['re_filter'] = regexp.create(pat)
+ r['re_filter'] = rspamd_regexp.create_cached(pat)
if not r['re_filter'] then
rspamd_logger.errx(task, 'couldnt create regex: %s', pat)
return
end
end
- local tld = util.get_tld(hostname)
+ local tld = rspamd_util.get_tld(hostname)
local res = r['re_filter']:search(tld)
if res then
return res[1]
if not r['re_filter'] then
local type,pat = string.match(filter, '(regexp:)(.+)')
if type and pat then
- r['re_filter'] = regexp.create(pat)
+ r['re_filter'] = rspamd_regexp.create_cached(pat)
end
end
if not r['re_filter'] then
local type,pat = string.match(filter, '(regexp:)(.+)')
if type and pat then
- r['re_filter'] = regexp.create(pat)
+ r['re_filter'] = rspamd_regexp.create_cached(pat)
end
end
if not r['re_filter'] then
local type,pat = string.match(filter, '(regexp:)(.+)')
if type and pat then
- r['re_filter'] = regexp.create(pat)
+ r['re_filter'] = rspamd_regexp.create_cached(pat)
end
end
local function apply_addr_filter(task, filter, input, rule)
if filter == 'email:addr' or filter == 'email' then
- local addr = util.parse_mail_address(input, task:get_mempool(), 1024)
+ local addr = rspamd_util.parse_mail_address(input, task:get_mempool(), 1024)
if addr and addr[1] then
return fun.totable(fun.map(function(a) return a.addr end, addr))
end
elseif filter == 'email:user' then
- local addr = util.parse_mail_address(input, task:get_mempool(), 1024)
+ local addr = rspamd_util.parse_mail_address(input, task:get_mempool(), 1024)
if addr and addr[1] then
return fun.totable(fun.map(function(a) return a.user end, addr))
end
elseif filter == 'email:domain' then
- local addr = util.parse_mail_address(input, task:get_mempool(), 1024)
+ local addr = rspamd_util.parse_mail_address(input, task:get_mempool(), 1024)
if addr and addr[1] then
return fun.totable(fun.map(function(a) return a.domain end, addr))
end
elseif filter == 'email:domain:tld' then
- local addr = util.parse_mail_address(input, task:get_mempool(), 1024)
+ local addr = rspamd_util.parse_mail_address(input, task:get_mempool(), 1024)
if addr and addr[1] then
- return fun.totable(fun.map(function(a) return util.get_tld(a.domain) end, addr))
+ return fun.totable(fun.map(function(a) return rspamd_util.get_tld(a.domain) end, addr))
end
elseif filter == 'email:name' then
- local addr = util.parse_mail_address(input, task:get_mempool(), 1024)
+ local addr = rspamd_util.parse_mail_address(input, task:get_mempool(), 1024)
if addr and addr[1] then
return fun.totable(fun.map(function(a) return a.name end, addr))
end
if not rule['re_filter'] then
local type,pat = string.match(filter, '(regexp:)(.+)')
if type and pat then
- rule['re_filter'] = regexp.create(pat)
+ rule['re_filter'] = rspamd_regexp.create_cached(pat)
end
end
if not r['re_filter'] then
local type,pat = string.match(filter, '(regexp:)(.+)')
if type and pat then
- r['re_filter'] = regexp.create(pat)
+ r['re_filter'] = rspamd_regexp.create_cached(pat)
end
end
if not r['re_filter'] then
local type,pat = string.match(filter, '(regexp:)(.+)')
if type and pat then
- r['re_filter'] = regexp.create(pat)
+ r['re_filter'] = rspamd_regexp.create_cached(pat)
end
end
end
else
if use_tld and type(v) == 'string' then
- v = util.get_tld(v)
+ v = rspamd_util.get_tld(v)
end
match_rule(r, v)
end