aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/surbl.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-26 16:15:15 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-08-26 16:15:15 +0100
commit94371677d39be71fd511fd7b99ea199093399bd7 (patch)
tree2ae3794db581e717df14fe6b652973c1ffab16eb /src/plugins/surbl.c
parentdf6923330928633ef44b1a54ff4b6ef7402f88ca (diff)
downloadrspamd-94371677d39be71fd511fd7b99ea199093399bd7.tar.gz
rspamd-94371677d39be71fd511fd7b99ea199093399bd7.zip
[Feature] Add monitored object for surbl plugin
Diffstat (limited to 'src/plugins/surbl.c')
-rw-r--r--src/plugins/surbl.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c
index 020a9a891..34016f361 100644
--- a/src/plugins/surbl.c
+++ b/src/plugins/surbl.c
@@ -472,11 +472,18 @@ surbl_module_config (struct rspamd_config *cfg)
const gchar *redir_val, *ip_val;
guint32 bit;
gint cb_id, nrules = 0;
+ ucl_object_t *monitored_opts;
if (!rspamd_config_is_module_enabled (cfg, "surbl")) {
return TRUE;
}
+ monitored_opts = ucl_object_typed_new (UCL_OBJECT);
+ ucl_object_insert_key (monitored_opts, ucl_object_fromstring ("facebook"),
+ "prefix", 0, false);
+ ucl_object_insert_key (monitored_opts, ucl_object_fromstring ("nxdomain"),
+ "rcode", 0, false);
+
if ((value =
rspamd_config_get_module_opt (cfg, "surbl", "redirector")) != NULL) {
surbl_module_ctx->redirectors = rspamd_upstreams_create (cfg->ups_ctx);
@@ -743,6 +750,11 @@ surbl_module_config (struct rspamd_config *cfg)
cb_id);
nrules ++;
}
+
+ new_suffix->m = rspamd_monitored_create (cfg->monitored_ctx,
+ new_suffix->suffix, RSPAMD_MONITORED_DNS,
+ RSPAMD_MONITORED_DEFAULT, monitored_opts);
+
surbl_module_ctx->suffixes = g_list_prepend (
surbl_module_ctx->suffixes,
new_suffix);
@@ -772,6 +784,7 @@ surbl_module_config (struct rspamd_config *cfg)
msg_info_config ("init internal surbls module, %d uribl rules loaded",
nrules);
+ ucl_object_unref (monitored_opts);
return TRUE;
}
@@ -1433,6 +1446,12 @@ surbl_test_url (struct rspamd_task *task, void *user_data)
struct html_image *img;
struct rspamd_url *url;
+ if (!rspamd_monitored_alive (suffix->m)) {
+ msg_info_task ("disable surbl %s as it is reported to be offline",
+ suffix->suffix);
+ return;
+ }
+
param.task = task;
param.suffix = suffix;
param.tree = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);