struct rspamd_milter_context {
gchar *spam_header;
void *sessions_cache;
+ gboolean discard_on_reject;
};
static struct rspamd_milter_context *milter_ctx = NULL;
switch (action) {
case METRIC_ACTION_REJECT:
- rcode = rspamd_fstring_new_init (RSPAMD_MILTER_RCODE_REJECT,
- sizeof (RSPAMD_MILTER_RCODE_REJECT) - 1);
- xcode = rspamd_fstring_new_init (RSPAMD_MILTER_XCODE_REJECT,
- sizeof (RSPAMD_MILTER_XCODE_REJECT) - 1);
-
- if (!reply) {
- reply = rspamd_fstring_new_init (RSPAMD_MILTER_REJECT_MESSAGE,
- sizeof (RSPAMD_MILTER_REJECT_MESSAGE) - 1);
+ if (milter_ctx->discard_on_reject) {
+ rspamd_milter_send_action (session, RSPAMD_MILTER_DISCARD);
}
+ else {
+ rcode = rspamd_fstring_new_init (RSPAMD_MILTER_RCODE_REJECT,
+ sizeof (RSPAMD_MILTER_RCODE_REJECT) - 1);
+ xcode = rspamd_fstring_new_init (RSPAMD_MILTER_XCODE_REJECT,
+ sizeof (RSPAMD_MILTER_XCODE_REJECT) - 1);
+
+ if (!reply) {
+ reply = rspamd_fstring_new_init (RSPAMD_MILTER_REJECT_MESSAGE,
+ sizeof (RSPAMD_MILTER_REJECT_MESSAGE) - 1);
+ }
- rspamd_milter_set_reply (session, rcode, xcode, reply);
- rspamd_milter_send_action (session, RSPAMD_MILTER_REJECT);
+ rspamd_milter_set_reply (session, rcode, xcode, reply);
+ rspamd_milter_send_action (session, RSPAMD_MILTER_REJECT);
+ }
break;
case METRIC_ACTION_SOFT_REJECT:
rcode = rspamd_fstring_new_init (RSPAMD_MILTER_RCODE_TEMPFAIL,
}
void
-rspamd_milter_init_library (const gchar *spam_header, void *sessions_cache)
+rspamd_milter_init_library (const gchar *spam_header, void *sessions_cache,
+ gboolean discard_on_reject)
{
if (milter_ctx) {
g_free (milter_ctx->spam_header);
}
milter_ctx->sessions_cache = sessions_cache;
+ milter_ctx->discard_on_reject = discard_on_reject;
}
rspamd_mempool_t *
gboolean has_self_scan;
/* It is not HTTP but milter proxy */
gboolean milter;
+ /* Discard messages instead of rejecting them */
+ gboolean discard_on_reject;
/* Milter spam header */
gchar *spam_header;
/* Sessions cache */
G_STRUCT_OFFSET (struct rspamd_proxy_ctx, milter),
0,
"Accept milter connections, not HTTP");
+ rspamd_rcl_register_worker_option (cfg,
+ type,
+ "discard_on_reject",
+ rspamd_rcl_parse_struct_boolean,
+ ctx,
+ G_STRUCT_OFFSET (struct rspamd_proxy_ctx, discard_on_reject),
+ 0,
+ "Tell MTA to discard rejected messages silently");
rspamd_rcl_register_worker_option (cfg,
type,
"spam_header",
ctx->ev_base);
}
- rspamd_milter_init_library (ctx->spam_header, ctx->sessions_cache);
+ rspamd_milter_init_library (ctx->spam_header, ctx->sessions_cache,
+ ctx->discard_on_reject);
event_base_loop (ctx->ev_base, 0);
rspamd_worker_block_signals ();