local default_port = 6379
local logger = require "rspamd_logger"
+ local upstream_list = require "rspamd_upstream_list"
local function try_load_redis_servers(options)
local key = options['servers']
dkim_deny_symbol = 'R_DKIM_REJECT',
}
-- Default port for redis upstreams
-local default_port = 6379
local upstreams = nil
local dmarc_redis_key_prefix = "dmarc_"
local dmarc_domain = nil
return
end
-if not opts['servers'] then
- rspamd_logger.infox(rspamd_config, 'no servers are specified for dmarc stats')
-else
- upstreams = upstream_list.create(rspamd_config, opts['servers'], default_port)
- if not upstreams then
- rspamd_logger.errx(rspamd_config, 'cannot parse servers parameter')
- end
+upstreams = rspamd_parse_redis_server('dmarc')
+if not upstreams then
+ rspamd_logger.errx(rspamd_config, 'cannot parse servers parameter')
end
if opts['key_prefix'] then
-- A plugin that implements greylisting using redis
--- Default port for redis upstreams
-local default_port = 6379
local upstreams
local whitelisted_ip
local settings = {
whitelisted_ip = rspamd_config:add_radix_map(opts['whitelisted_ip'],
'Greylist whitelist ip map')
end
- if not opts['servers'] then
+
+ upstreams = rspamd_parse_redis_server('greylist')
+ if not upstreams then
rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
else
- upstreams = upstream_list.create(rspamd_config, opts['servers'], default_port)
- if not upstreams then
- rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
- else
- rspamd_config:register_pre_filter(greylist_check)
- rspamd_config:register_post_filter(greylist_set, 10)
- end
+ rspamd_config:register_pre_filter(greylist_check)
+ rspamd_config:register_post_filter(greylist_set, 10)
end
for k,v in pairs(opts) do
local _ = require "fun"
-- Default settings
-local default_port = 6379
local upstreams = nil
local whitelist = nil
local asn_cc_whitelist = nil
for k,v in pairs(opts) do
options[k] = v
end
- if options['servers'] and options['servers'] ~= '' then
- upstreams = upstream_list.create(rspamd_config, options['servers'], default_port)
- if not upstreams then
- rspamd_logger.infox(rspamd_config, 'no servers are specified')
- end
- end
- if options['whitelist'] then
- whitelist = rspamd_config:add_radix_map(opts['whitelist'])
- end
- if options['asn_cc_whitelist'] then
- asn_cc_whitelist = rspamd_config:add_hash_map(opts['asn_cc_whitelist'])
+ upstreams = rspamd_parse_redis_server('ip_score')
+ if not upstreams then
+ rspamd_logger.infox(rspamd_config, 'no servers are specified')
end
end
+ if options['whitelist'] then
+ whitelist = rspamd_config:add_radix_map(opts['whitelist'])
+ end
+ if options['asn_cc_whitelist'] then
+ asn_cc_whitelist = rspamd_config:add_hash_map(opts['asn_cc_whitelist'])
+ end
end
-- A plugin that implements ratelimits using redis or kvstorage server
--- Default port for redis upstreams
-local default_port = 6379
-- Default settings for limits, 1-st member is burst, second is rate and the third is numeric type
local settings = {
-- Limit for all mail per recipient (burst 100, rate 2 per minute)
max_rcpt = tonumber(opts['max_delay'])
end
- if not opts['servers'] then
+ upstreams = rspamd_parse_redis_server('ratelimit')
+ if not upstreams then
rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
else
- upstreams = upstream_list.create(rspamd_config, opts['servers'], default_port)
- if not upstreams then
- rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
+ if not ratelimit_symbol then
+ rspamd_config:register_pre_filter(rate_test)
else
- if not ratelimit_symbol then
- rspamd_config:register_pre_filter(rate_test)
- else
- rspamd_config:register_symbol({
- name = ratelimit_symbol,
- callback = rate_test,
- flags = 'empty'
- })
- end
-
- rspamd_config:register_post_filter(rate_set)
+ rspamd_config:register_symbol({
+ name = ratelimit_symbol,
+ callback = rate_test,
+ flags = 'empty'
+ })
end
+
+ rspamd_config:register_post_filter(rate_set)
end
end
-- A plugin that implements replies check using redis
-- Default port for redis upstreams
-local default_port = 6379
local upstreams
local whitelisted_ip
local settings = {
local opts = rspamd_config:get_all_opt('replies')
if opts then
- if not opts['servers'] then
- rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
- else
- upstreams = upstream_list.create(rspamd_config, opts['servers'], default_port)
+ upstreams = rspamd_parse_redis_server('replies')
if not upstreams then
rspamd_logger.infox(rspamd_config, 'no servers are specified, disabling module')
else
rspamd_config:register_pre_filter(replies_check)
rspamd_config:register_post_filter(replies_set, 10)
end
- end
for k,v in pairs(opts) do
settings[k] = v