aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-03 12:47:33 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-03 12:47:33 +0000
commit63a9a0b5a875a2e33d61906eb62b0afa08e24d52 (patch)
tree9c7cf86d736dfab03d37c37d4e04e3141b47c57d /src
parentfaef7725273c49d379f0b1e237da944a93741097 (diff)
downloadrspamd-63a9a0b5a875a2e33d61906eb62b0afa08e24d52.tar.gz
rspamd-63a9a0b5a875a2e33d61906eb62b0afa08e24d52.zip
[Feature] Add concept of experimental modules
Diffstat (limited to 'src')
-rw-r--r--src/libserver/cfg_file.h3
-rw-r--r--src/libserver/cfg_rcl.c6
-rw-r--r--src/lua/lua_common.c2
-rw-r--r--src/lua/lua_config.c24
-rw-r--r--src/plugins/lua/fann_classifier.lua6
-rw-r--r--src/plugins/lua/url_reputation.lua4
-rw-r--r--src/plugins/lua/url_tags.lua4
7 files changed, 48 insertions, 1 deletions
diff --git a/src/libserver/cfg_file.h b/src/libserver/cfg_file.h
index fa04564f8..199c965f4 100644
--- a/src/libserver/cfg_file.h
+++ b/src/libserver/cfg_file.h
@@ -307,7 +307,8 @@ struct rspamd_config {
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 */
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c
index dbc0fc5a4..fd0930212 100644
--- a/src/libserver/cfg_rcl.c
+++ b/src/libserver/cfg_rcl.c
@@ -2006,6 +2006,12 @@ rspamd_rcl_config_init (struct rspamd_config *cfg)
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,
G_STRUCT_OFFSET (struct rspamd_config, check_all_filters),
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 942f5a9b6..f77fe6b6e 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -423,6 +423,7 @@ rspamd_lua_init ()
* disabled_redis = {},
* disabled_explicitly = {},
* disabled_failed = {},
+ * disabled_experimental = {},
* }
*/
#define ADD_TABLE(name) do { \
@@ -436,6 +437,7 @@ rspamd_lua_init ()
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);
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 935ee7806..5a6bac8bc 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -667,6 +667,13 @@ LUA_FUNCTION_DEF (config, get_cpu_flags);
*/
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),
@@ -722,6 +729,7 @@ static const struct luaL_reg configlib_m[] = {
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}
@@ -2950,6 +2958,22 @@ lua_config_has_torch (lua_State *L)
}
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)
{
struct rspamd_monitored *m = lua_check_monitored (L, 1);
diff --git a/src/plugins/lua/fann_classifier.lua b/src/plugins/lua/fann_classifier.lua
index f4133eb9e..f1e93ca2a 100644
--- a/src/plugins/lua/fann_classifier.lua
+++ b/src/plugins/lua/fann_classifier.lua
@@ -23,7 +23,9 @@ end
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 = {
@@ -39,6 +41,10 @@ local current_classify_ann = {
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)
diff --git a/src/plugins/lua/url_reputation.lua b/src/plugins/lua/url_reputation.lua
index 55f568e56..c3856f3b6 100644
--- a/src/plugins/lua/url_reputation.lua
+++ b/src/plugins/lua/url_reputation.lua
@@ -352,6 +352,10 @@ local function url_reputation_check(task)
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)
diff --git a/src/plugins/lua/url_tags.lua b/src/plugins/lua/url_tags.lua
index 1281cc2fc..e64aa926f 100644
--- a/src/plugins/lua/url_tags.lua
+++ b/src/plugins/lua/url_tags.lua
@@ -347,6 +347,10 @@ local function tags_restore(task)
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)