--[[[
-- @function lua_util.disable_module(modname, how)
--- Disables a plugin or disables redis for a plugin.
+-- Disables a plugin or disables a plugin.
-- @param {string} modname name of plugin to disable
-- @param {string} how 'redis' to disable redis, 'config' to disable startup
--]]
rspamd_plugins_state.disabled_redis[modname] = {}
elseif how == 'config' then
rspamd_plugins_state.disabled_unconfigured[modname] = {}
+ elseif how == 'experimental' then
+ rspamd_plugins_state.disabled_experimental[modname] = {}
else
rspamd_plugins_state.disabled_failed[modname] = {}
end
exports.disable_module = disable_module
+--[[[
+-- @function lua_util.disable_module(modname)
+-- Checks experimental plugins state and disable if needed
+-- @param {string} modname name of plugin to check
+-- @return {boolean} true if plugin should be enabled, false otherwise
+--]]
+local function check_experimental(modname)
+ if rspamd_config:experimental_enabled() then
+ return true
+ else
+ disable_module(modname, 'experimental')
+ end
+
+ return false
+end
+
+exports.check_experimental = check_experimental
--[[[
-- @function lua_util.parse_time_interval(str)
return function(args, _)
print_plugins_table(rspamd_plugins_state.enabled, "enabled")
print_plugins_table(rspamd_plugins_state.disabled_explicitly,
- "disabled (explicitly)")
+ "disabled (explicitly)")
print_plugins_table(rspamd_plugins_state.disabled_unconfigured,
- "disabled (unconfigured)")
+ "disabled (unconfigured)")
print_plugins_table(rspamd_plugins_state.disabled_redis,
- "disabled (no Redis)")
+ "disabled (no Redis)")
+ print_plugins_table(rspamd_plugins_state.disabled_experimental,
+ "disabled (experimental)")
print_plugins_table(rspamd_plugins_state.disabled_failed,
- "disabled (failed)")
+ "disabled (failed)")
end
\ No newline at end of file
gboolean vectorized_hyperscan; /**< use vectorized hyperscan matching */
gboolean enable_shutdown_workaround; /**< enable workaround for legacy SA clients (exim) */
gboolean ignore_received; /**< Ignore data from the first received header */
- gboolean enable_sessions_cache; /**< Enable session cache for debug */
+ gboolean enable_sessions_cache; /**< Enable session cache for debug */
+ gboolean enable_experimental; /**< Enable experimental plugins */
gsize max_diff; /**< maximum diff size for text parts */
gsize max_cores_size; /**< maximum size occupied by rspamd core files */
G_STRUCT_OFFSET (struct rspamd_config, check_all_filters),
0,
"Always check all filters");
+ rspamd_rcl_add_default_handler (sub,
+ "enable_experimental",
+ rspamd_rcl_parse_struct_boolean,
+ G_STRUCT_OFFSET (struct rspamd_config, check_all_filters),
+ 0,
+ "Enable experimental plugins");
rspamd_rcl_add_default_handler (sub,
"all_filters",
rspamd_rcl_parse_struct_boolean,
* disabled_redis = {},
* disabled_explicitly = {},
* disabled_failed = {},
+ * disabled_experimental = {},
* }
*/
#define ADD_TABLE(name) do { \
ADD_TABLE (disabled_redis);
ADD_TABLE (disabled_explicitly);
ADD_TABLE (disabled_failed);
+ ADD_TABLE (disabled_experimental);
#undef ADD_TABLE
lua_setglobal (L, rspamd_modules_state_global);
*/
LUA_FUNCTION_DEF (config, has_torch);
+/***
+ * @method rspamd_config:experimental_enabled()
+ * Returns true if experimental plugins are enabled
+ * @return {boolean} true if experimental plugins are enabled
+ */
+LUA_FUNCTION_DEF (config, experimental_enabled);
+
static const struct luaL_reg configlib_m[] = {
LUA_INTERFACE_DEF (config, get_module_opt),
LUA_INTERFACE_DEF (config, get_mempool),
LUA_INTERFACE_DEF (config, set_peak_cb),
LUA_INTERFACE_DEF (config, get_cpu_flags),
LUA_INTERFACE_DEF (config, has_torch),
+ LUA_INTERFACE_DEF (config, experimental_enabled),
{"__tostring", rspamd_lua_class_tostring},
{"__newindex", lua_config_newindex},
{NULL, NULL}
return 1;
}
+static gint
+lua_config_experimental_enabled (lua_State *L)
+{
+ struct rspamd_config *cfg = lua_check_config (L, 1);
+
+ if (cfg != NULL) {
+ lua_pushboolean (L, cfg->enable_experimental);
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 1;
+}
+
+
static gint
lua_monitored_alive (lua_State *L)
{
local rspamd_logger = require "rspamd_logger"
local rspamd_fann = require "rspamd_fann"
local rspamd_util = require "rspamd_util"
+local lua_util = require "lua_util"
local fun = require "fun"
+local N = 'fann_classifier'
local redis_params
local classifier_config = {
ham_learned = 0
}
+if not lua_util.check_experimental(N) then
+ return
+end
+
redis_params = rspamd_parse_redis_server('fann_classifier')
local function maybe_load_fann(task, continue_cb, call_if_fail)
end
end
+if not lua_util.check_experimental(N) then
+ return
+end
+
local opts = rspamd_config:get_all_opt(N)
if not opts then return end
redis_params = rspamd_parse_redis_server(N)
end
end
+if not lua_util.check_experimental(N) then
+ return
+end
+
local opts = rspamd_config:get_all_opt(N)
if not opts then return end
redis_params = rspamd_parse_redis_server(N)