commit d231f3d: [Minor] Check enabled/disabled logic for the proxy upstreams/mirrors

Vsevolod Stakhov vsevolod at rspamd.com
Wed Mar 30 20:14:04 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-03-30 21:06:43 +0100
URL: https://github.com/rspamd/rspamd/commit/d231f3d467434e412160fa2d45dad8377a4f780e

[Minor] Check enabled/disabled logic for the proxy upstreams/mirrors

---
 src/libserver/cfg_file.h  | 2 +-
 src/libserver/cfg_utils.c | 8 ++++----
 src/rspamd_proxy.c        | 9 +++++++++
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index 6f88c6b63..7532639a7 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -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);
 
 /*
diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c
index 49653c22c..9a96f363c 100644
--- a/src/libserver/cfg_utils.c
+++ b/src/libserver/cfg_utils.c
@@ -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,
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c
index 10f95e0bf..bdf3e1a14 100644
--- a/src/rspamd_proxy.c
+++ b/src/rspamd_proxy.c
@@ -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");


More information about the Commits mailing list