]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Further improvements to error messages in fuzzy check
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jul 2016 17:12:52 +0000 (18:12 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 14 Jul 2016 17:12:52 +0000 (18:12 +0100)
src/plugins/fuzzy_check.c

index 0dc803a6b2227025fca144688e15b2e59f4d9f2e..82800e714442161dfff33f9e84729ee63c17d756 100644 (file)
@@ -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) {