From 1c90f2e160037477192b9e4e9c480ce3a8a83a25 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 14 Jul 2016 18:12:52 +0100 Subject: [PATCH] [Fix] Further improvements to error messages in fuzzy check --- src/plugins/fuzzy_check.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 0dc803a6b..82800e714 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -102,6 +102,7 @@ struct fuzzy_ctx { guint32 min_width; guint32 io_timeout; guint32 retransmits; + gboolean enabled; }; struct fuzzy_client_session { @@ -828,6 +829,8 @@ fuzzy_check_module_config (struct rspamd_config *cfg) return TRUE; } + fuzzy_module_ctx->enabled = TRUE; + if ((value = rspamd_config_get_module_opt (cfg, "fuzzy_check", "symbol")) != NULL) { fuzzy_module_ctx->default_symbol = ucl_obj_tostring (value); @@ -2160,6 +2163,10 @@ fuzzy_symbol_callback (struct rspamd_task *task, void *unused) GList *cur; GPtrArray *commands; + if (!fuzzy_module_ctx->enabled) { + return; + } + /* Check whitelist */ if (fuzzy_module_ctx->whitelist) { if (radix_find_compressed_addr (fuzzy_module_ctx->whitelist, @@ -2189,6 +2196,10 @@ fuzzy_stat_command (struct rspamd_task *task) GList *cur; GPtrArray *commands; + if (!fuzzy_module_ctx->enabled) { + return; + } + cur = fuzzy_module_ctx->fuzzy_rules; while (cur) { rule = cur->data; @@ -2413,6 +2424,18 @@ fuzzy_controller_handler (struct rspamd_http_connection_entry *conn_ent, const rspamd_ftok_t *arg; glong value = 1, flag = 0; + if (!fuzzy_module_ctx->enabled) { + msg_err ("fuzzy_check module is not enabled"); + rspamd_controller_send_error (conn_ent, 500, "Module disabled"); + return 0; + } + + if (fuzzy_module_ctx->fuzzy_rules == NULL) { + msg_err ("fuzzy_check module has no rules defined"); + rspamd_controller_send_error (conn_ent, 500, "Module has no rules"); + return 0; + } + /* Get size */ arg = rspamd_http_message_find_header (msg, "Weight"); if (arg) { -- 2.39.5