end
end
-local function maybe_force_action(task)
- if settings.force_action then
- rspamd_logger.warnx(task, 'forcing action: %s', settings.force_action)
- task:set_metric_action('default', settings.force_action)
- end
-end
-
local pushers = {
redis_pubsub = function(task, formatted)
local _,ret,upstream
err, upstream:get_addr())
return maybe_defer(task)
end
- maybe_force_action(task)
+ return true
end
ret,_,upstream = rspamd_redis_make_request(task,
redis_params, -- connect params
rspamd_logger.errx(task, 'got unexpected http status: %s', code)
return maybe_defer(task)
end
- maybe_force_action(task)
+ return true
end
rspamd_http.request({
task=task,
return true
end
local function all_done_cb(merr, mdata)
- maybe_force_action(task)
if conn then
conn:close()
end
+ return true
end
local function quit_done_cb(merr, mdata)
conn:add_read(all_done_cb, '\r\n')
end
local function from_done_cb(merr, mdata)
if no_error(merr, mdata) then
- conn:add_write(rcpt_cb, 'RCPT TO: <' .. settings.mail_to .. '>\r\n')
+ conn:add_write(rcpt_cb, {'RCPT TO: <', settings.mail_to, '>\r\n'})
end
end
local function from_cb(merr, mdata)
end
local function hello_done_cb(merr, mdata)
if no_error(merr, mdata) then
- conn:add_write(from_cb, 'MAIL FROM: <' .. settings.mail_from .. '>\r\n')
+ conn:add_write(from_cb, {'MAIL FROM: <', settings.mail_from, '>\r\n'})
end
end
local function hello_cb(merr)
end
end
if no_error(err, data) then
- conn:add_write(hello_cb, 'HELO ' .. settings.helo .. '\r\n')
+ conn:add_write(hello_cb, {'HELO ', settings.helo, '\r\n'})
end
end
rspamd_tcp.request({
settings.pusher_enabled.redis_pubsub = true
end
if settings.smtp and settings.mail_to then
- rspamd_logger.warnx(rspamd_config, 'Redis Pubsub pusher implicitly enabled')
+ rspamd_logger.warnx(rspamd_config, 'SMTP pusher implicitly enabled')
settings.pusher_enabled.send_mail = true
end
end
return
end
-local function metadata_exporter(task)
- local results = {
- select = {},
- format = {},
- }
- for k in pairs(settings.pusher_enabled) do
- local selector = settings.pusher_select[k] or 'default'
+local function gen_exporter(backend)
+ return function (task)
+ local results = {
+ select = {},
+ format = {},
+ }
+ local selector = settings.pusher_select[backend] or 'default'
local selected = results.select[selector]
if selected == nil then
results.select[selector] = selectors[selector](task)
end
if selected then
rspamd_logger.debugm(N, task, 'Message selected for processing')
- local formatter = settings.pusher_format[k]
- local formatted = results.format[k]
+ local formatter = settings.pusher_format[backend]
+ local formatted = results.format[backend]
if formatted == nil then
results.format[formatter] = formatters[formatter](task)
formatted = results.format[formatter]
end
if formatted then
- pushers[k](task, formatted)
+ pushers[backend](task, formatted)
elseif formatted == nil then
rspamd_logger.warnx(task, 'Formatter [%s] returned NIL', formatter)
else
rspamd_logger.debugm(N, task, 'Formatter [%s] returned non-truthy value [%s]', formatter, formatted)
end
+ elseif selected == nil then
+ rspamd_logger.warnx(task, 'Selector [%s] returned NIL', selector)
+ else
+ rspamd_logger.debugm(N, task, 'Selector [%s] returned non-truthy value [%s]', selector, selected)
end
end
end
-rspamd_config:register_symbol({
- name = 'EXPORT_METADATA',
- type = 'postfilter',
- callback = metadata_exporter,
- priority = 10
-})
+for k in pairs(settings.pusher_enabled) do
+ rspamd_config:register_symbol({
+ name = 'EXPORT_METADATA_' .. k:upper(),
+ type = 'postfilter',
+ callback = gen_exporter(k),
+ priority = 10
+ })
+end