aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-03 17:05:49 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-03-03 17:05:49 +0000
commitb46282cc0f957e6a2549521175d965295cf7cbc2 (patch)
treebf3cc4bc36ea4a17fc2be3649ad9d36617a537d2
parentff3ae310006f00880f97d134c6a73ee12ca875c1 (diff)
downloadrspamd-b46282cc0f957e6a2549521175d965295cf7cbc2.tar.gz
rspamd-b46282cc0f957e6a2549521175d965295cf7cbc2.zip
[Feature] Allow to specify flags for metric symbols
-rw-r--r--src/lua/lua_config.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c
index 59ca08864..53ad93049 100644
--- a/src/lua/lua_config.c
+++ b/src/lua/lua_config.c
@@ -1277,7 +1277,7 @@ lua_config_set_metric_symbol (lua_State * L)
{
struct rspamd_config *cfg = lua_check_config (L, 1);
const gchar *metric_name = DEFAULT_METRIC, *description = NULL,
- *group = NULL, *name = NULL;
+ *group = NULL, *name = NULL, *flags_str = NULL;
double weight;
struct metric *metric;
gboolean one_shot = FALSE;
@@ -1290,9 +1290,9 @@ lua_config_set_metric_symbol (lua_State * L)
if (lua_type (L, 2) == LUA_TTABLE) {
if (!rspamd_lua_parse_table_arguments (L, 2, &err,
"*name=S;score=N;description=S;"
- "group=S;one_shot=B;metric=S;priority=N",
+ "group=S;one_shot=B;metric=S;priority=N;flags=S",
&name, &weight, &description,
- &group, &one_shot, &metric_name, &priority)) {
+ &group, &one_shot, &metric_name, &priority, &flags_str)) {
msg_err_config ("bad arguments: %e", err);
g_error_free (err);
@@ -1326,6 +1326,15 @@ lua_config_set_metric_symbol (lua_State * L)
flags |= RSPAMD_SYMBOL_FLAG_ONESHOT;
}
+ if (flags_str) {
+ if (strstr (flags_str, "one_shot") != NULL) {
+ flags |= RSPAMD_SYMBOL_FLAG_ONESHOT;
+ }
+ else if (strstr (flags_str, "ignore") != NULL) {
+ flags |= RSPAMD_SYMBOL_FLAG_IGNORE;
+ }
+ }
+
if (metric == NULL) {
msg_err_config ("metric named %s is not defined", metric_name);
}