]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Check enabled/disabled logic for the proxy upstreams/mirrors
authorVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 30 Mar 2022 20:06:43 +0000 (21:06 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Wed, 30 Mar 2022 20:06:43 +0000 (21:06 +0100)
src/libserver/cfg_file.h
src/libserver/cfg_utils.c
src/rspamd_proxy.c

index 6f88c6b636c318d235dc34a9c606402fc50355bb..7532639a7e718895fbd47657d5f0b7161490c439 100644 (file)
@@ -723,7 +723,7 @@ gboolean rspamd_config_is_module_enabled (struct rspamd_config *cfg,
  * @param obj
  * @return TRUE if there is no explicit disable in the object found
  */
-gboolean rspamd_config_is_enabled_from_ucl (struct rspamd_config *cfg,
+gboolean rspamd_config_is_enabled_from_ucl (rspamd_mempool_t *pool,
                const ucl_object_t *obj);
 
 /*
index 49653c22c55ff93a3ec1d6b16ab224228e2f4599..9a96f363c6ba06094076352dffaaab256e4112df 100644 (file)
@@ -1779,7 +1779,7 @@ rspamd_config_add_symbol_group (struct rspamd_config *cfg,
 }
 
 gboolean
-rspamd_config_is_enabled_from_ucl (struct rspamd_config *cfg,
+rspamd_config_is_enabled_from_ucl (rspamd_mempool_t *pool,
                const ucl_object_t *obj)
 {
        {
@@ -1801,7 +1801,7 @@ rspamd_config_is_enabled_from_ucl (struct rspamd_config *cfg,
                                }
                                else if (ret == -1) {
 
-                                       msg_info_config ("wrong value for the `enabled` key");
+                                       msg_info_pool_check ("wrong value for the `enabled` key");
                                        return FALSE;
                                }
                                /* Default return is TRUE here */
@@ -1828,7 +1828,7 @@ rspamd_config_is_enabled_from_ucl (struct rspamd_config *cfg,
                                }
                                else if (ret == -1) {
 
-                                       msg_info_config ("wrong value for the `disabled` key");
+                                       msg_info_pool_check ("wrong value for the `disabled` key");
                                        return FALSE;
                                }
 
@@ -1904,7 +1904,7 @@ rspamd_config_is_module_enabled (struct rspamd_config *cfg,
                }
        }
        else {
-               enabled = rspamd_config_is_enabled_from_ucl (cfg, conf);
+               enabled = rspamd_config_is_enabled_from_ucl (cfg->cfg_pool, conf);
 
                if (!enabled) {
                        rspamd_plugins_table_push_elt (L,
index 10f95e0bf483fafb91e5b1f7e0c4dc4252afaa71..bdf3e1a14e10ddbea53238a1ed0b4438a127bb18 100644 (file)
@@ -334,6 +334,15 @@ rspamd_proxy_parse_upstream (rspamd_mempool_t *pool,
                return FALSE;
        }
 
+       if (!rspamd_config_is_enabled_from_ucl (pool, obj)) {
+               /* Upstream is valid but disabled */
+               msg_info_pool_check("upstream %s is disabled",
+                               ucl_object_lookup (obj, "name") ?
+                                       ucl_object_tostring(ucl_object_lookup (obj, "name")) :
+                                       ucl_object_key (obj));
+               return TRUE;
+       }
+
        up = rspamd_mempool_alloc0 (pool, sizeof (*up));
 
        elt = ucl_object_lookup (obj, "name");