local rspamd_logger = require "rspamd_logger"
local lua_util = require "lua_util"
+local lua_redis = require "lua_redis"
local fun = require "fun"
local lua_antivirus = require("lua_scanners").filter('antivirus')
local common = require "lua_scanners/common"
rule.patterns = common.create_regex_table(opts.patterns or {})
rule.patterns_fail = common.create_regex_table(opts.patterns_fail or {})
+ lua_redis.register_prefix(rule.prefix .. '_*', N,
+ string.format('Antivirus cache for rule "%s"',
+ rule.type), {
+ type = 'string',
+ })
+
if opts.whitelist then
rule.whitelist = rspamd_config:add_hash_map(opts.whitelist)
end
-- Registration
local opts = rspamd_config:get_all_opt(N)
if opts and type(opts) == 'table' then
- redis_params = rspamd_parse_redis_server(N)
+ redis_params = lua_redis.parse_redis_server(N)
local has_valid = false
for k, m in pairs(opts) do
if type(m) == 'table' then
local rspamd_logger = require "rspamd_logger"
local lua_util = require "lua_util"
+local lua_redis = require "lua_redis"
local fun = require "fun"
local lua_scanners = require("lua_scanners").filter('scanner')
local common = require "lua_scanners/common"
rule.redis_params = redis_params
+ lua_redis.register_prefix(rule.prefix .. '_*', N,
+ string.format('External services cache for rule "%s"',
+ rule.type), {
+ type = 'string',
+ })
+
-- if any mime_part filter defined, do not scan all attachments
if opts.mime_parts_filter_regex ~= nil
or opts.mime_parts_filter_ext ~= nil then
-- Registration
local opts = rspamd_config:get_all_opt(N)
if opts and type(opts) == 'table' then
- redis_params = rspamd_parse_redis_server(N)
+ redis_params = lua_redis.parse_redis_server(N)
local has_valid = false
for k, m in pairs(opts) do
if type(m) == 'table' and m.servers then
rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
rspamd_lua_utils.disable_module(N, "redis")
else
+ lua_redis.register_prefix(settings.key_prefix .. 'b[a-z0-9]{20}', N,
+ 'Greylisting elements (body hashes)"', {
+ type = 'string',
+ })
+ lua_redis.register_prefix(settings.key_prefix .. 'm[a-z0-9]{20}', N,
+ 'Greylisting elements (meta hashes)"', {
+ type = 'string',
+ })
rspamd_config:register_symbol({
name = 'GREYLIST_SAVE',
type = 'postfilter',
end
redis_params = lua_redis.parse_redis_server(N, opts)
-
+-- XXX, this is a poor approach as not all maps are defined here...
+local tmaps = rspamd_config:get_maps()
+for _,m in ipairs(tmaps) do
+ if m:get_uri() ~= 'static' then
+ lua_redis.register_prefix(settings.prefix .. m:get_uri(), N,
+ 'Maps stats data', {
+ type = 'zlist',
+ persistent = true,
+ })
+ end
+end
if redis_params then
rspamd_config:add_on_load(function (_, ev_base, worker)
local rspamd_tcp = require "rspamd_tcp"
local rspamd_util = require "rspamd_util"
local lua_util = require "lua_util"
+local lua_redis = require "lua_redis"
local N = "mx_check"
local fun = require "fun"
return
end
if opts then
- redis_params = rspamd_parse_redis_server('mx_check')
+ redis_params = lua_redis.parse_redis_server('mx_check')
if not redis_params then
rspamd_logger.errx(rspamd_config, 'no redis servers are specified, disabling module')
lua_util.disable_module(N, "redis")
return
end
- for k,v in pairs(opts) do
- settings[k] = v
- end
+
+ settings = lua_util.override_defaults(settings, opts)
+ lua_redis.register_prefix(settings.key_prefix .. '*', N,
+ 'MX check cache', {
+ type = 'string',
+ })
local id = rspamd_config:register_symbol({
name = settings.symbol_bad_mx,
if rule then
rule.redis_params = lua_redis.parse_redis_server(N)
+ lua_redis.register_prefix(rule.prefix .. '*', N,
+ 'P0f check cache', {
+ type = 'string',
+ })
+
local id = rspamd_config:register_symbol({
name = 'P0F_CHECK',
type = 'prefilter,nostat',
settings.redirector_hosts_map = lua_maps.map_add_from_ucl(settings.redirector_hosts_map,
'set', 'Redirectors definitions')
+ lua_redis.register_prefix(settings.key_prefix .. '[a-z0-9]{32}', N,
+ 'URL redirector hashes', {
+ type = 'string',
+ })
+ if settings.top_urls_key then
+ lua_redis.register_prefix(settings.top_urls_key, N,
+ 'URL redirector top urls', {
+ type = 'zlist',
+ })
+ end
local id = rspamd_config:register_symbol{
name = 'URL_REDIRECTOR_CHECK',
type = 'callback,prefilter',