diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-08-12 17:22:33 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-08-12 17:22:33 +0100 |
commit | 9fb4a7f6e61d361b46eaae0c6b8dbe2805905e36 (patch) | |
tree | f68c936404bf6c5ab1e4e780dacb952f6882695c /src | |
parent | aef19db4a81bcc40db2047c1c540f09f07fc9fd1 (diff) | |
download | rspamd-9fb4a7f6e61d361b46eaae0c6b8dbe2805905e36.tar.gz rspamd-9fb4a7f6e61d361b46eaae0c6b8dbe2805905e36.zip |
Rework symbols weights.
Diffstat (limited to 'src')
-rw-r--r-- | src/libserver/cfg_rcl.c | 2 | ||||
-rw-r--r-- | src/libserver/cfg_utils.c | 2 | ||||
-rw-r--r-- | src/lua/lua_cfg_file.c | 2 | ||||
-rw-r--r-- | src/lua/lua_config.c | 18 | ||||
-rw-r--r-- | src/plugins/chartable.c | 8 | ||||
-rw-r--r-- | src/plugins/dkim_check.c | 20 | ||||
-rw-r--r-- | src/plugins/fuzzy_check.c | 20 | ||||
-rw-r--r-- | src/plugins/regexp.c | 14 | ||||
-rw-r--r-- | src/plugins/spf.c | 28 | ||||
-rw-r--r-- | src/plugins/surbl.c | 34 |
10 files changed, 93 insertions, 55 deletions
diff --git a/src/libserver/cfg_rcl.c b/src/libserver/cfg_rcl.c index af7d5ef60..de7b6f1d1 100644 --- a/src/libserver/cfg_rcl.c +++ b/src/libserver/cfg_rcl.c @@ -1165,7 +1165,7 @@ rspamd_rcl_composite_handler (rspamd_mempool_t *pool, composite); if (new) { - rspamd_symbols_cache_add_symbol (cfg->cache, composite_name, 1, 0, + rspamd_symbols_cache_add_symbol (cfg->cache, composite_name, 0, NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1); } diff --git a/src/libserver/cfg_utils.c b/src/libserver/cfg_utils.c index a864cf154..f9017d594 100644 --- a/src/libserver/cfg_utils.c +++ b/src/libserver/cfg_utils.c @@ -701,7 +701,7 @@ symbols_classifiers_callback (gpointer key, gpointer value, gpointer ud) struct rspamd_config *cfg = ud; /* Actually, statistics should act like any ordinary symbol */ - rspamd_symbols_cache_add_symbol (cfg->cache, key, 1.0, 0, NULL, NULL, + rspamd_symbols_cache_add_symbol (cfg->cache, key, 0, NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1); } diff --git a/src/lua/lua_cfg_file.c b/src/lua/lua_cfg_file.c index 563fbb77b..a8e8dfbb8 100644 --- a/src/lua/lua_cfg_file.c +++ b/src/lua/lua_cfg_file.c @@ -213,7 +213,7 @@ rspamd_lua_post_load_config (struct rspamd_config *cfg) else { g_hash_table_insert (cfg->composite_symbols, sym, expr); rspamd_symbols_cache_add_symbol (cfg->cache, sym, - 1, 0, NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1); + 0, NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1); } } } diff --git a/src/lua/lua_config.c b/src/lua/lua_config.c index a1033543d..ea84f5532 100644 --- a/src/lua/lua_config.c +++ b/src/lua/lua_config.c @@ -920,7 +920,6 @@ rspamd_register_symbol_fromlua (lua_State *L, ret = rspamd_symbols_cache_add_symbol (cfg->cache, name, - weight, priority, lua_metric_symbol_callback, cd, @@ -1012,16 +1011,18 @@ lua_config_register_symbols (lua_State *L) while (lua_next (L, -2)) { lua_pushvalue (L, -2); sym = luaL_checkstring (L, -2); - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, sym, - weight, ret); + rspamd_symbols_cache_add_symbol (cfg->cache, sym, + 0, NULL, NULL, + SYMBOL_TYPE_VIRTUAL, ret); lua_pop (L, 2); } lua_pop (L, 1); } else if (lua_type (L, i) == LUA_TSTRING) { sym = luaL_checkstring (L, i); - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, sym, - weight, ret); + rspamd_symbols_cache_add_symbol (cfg->cache, sym, + 0, NULL, NULL, + SYMBOL_TYPE_VIRTUAL, ret); } } } @@ -1048,8 +1049,9 @@ lua_config_register_virtual_symbol (lua_State * L) } if (name) { - ret = rspamd_symbols_cache_add_symbol_virtual (cfg->cache, name, - weight, parent); + ret = rspamd_symbols_cache_add_symbol (cfg->cache, name, + 0, NULL, NULL, + SYMBOL_TYPE_VIRTUAL, parent); } } @@ -1257,7 +1259,7 @@ lua_config_add_composite (lua_State * L) if (new) { rspamd_symbols_cache_add_symbol (cfg->cache, name, - 1, 0, NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1); + 0, NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1); } ret = TRUE; diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c index c0c68f71a..1cb1c7ed7 100644 --- a/src/plugins/chartable.c +++ b/src/plugins/chartable.c @@ -104,11 +104,13 @@ chartable_module_config (struct rspamd_config *cfg) chartable_module_ctx->threshold = DEFAULT_THRESHOLD; } - rspamd_symbols_cache_add_symbol_normal (cfg->cache, + rspamd_symbols_cache_add_symbol (cfg->cache, chartable_module_ctx->symbol, - 1, + 0, chartable_symbol_callback, - NULL); + NULL, + SYMBOL_TYPE_NORMAL, + -1); return res; } diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c index e30b9858c..396641591 100644 --- a/src/plugins/dkim_check.c +++ b/src/plugins/dkim_check.c @@ -228,18 +228,24 @@ dkim_module_config (struct rspamd_config *cfg) "trusted_only option is set and no trusted domains are defined; disabling dkim module completely as it is useless in this case"); } else { - cb_id = rspamd_symbols_cache_add_symbol_normal (cfg->cache, + cb_id = rspamd_symbols_cache_add_symbol (cfg->cache, dkim_module_ctx->symbol_reject, - 1, + 0, dkim_symbol_callback, - NULL); - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, + NULL, + SYMBOL_TYPE_NORMAL|SYMBOL_TYPE_FINE, + -1); + rspamd_symbols_cache_add_symbol (cfg->cache, dkim_module_ctx->symbol_tempfail, - 1, + 0, + NULL, NULL, + SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_FINE, cb_id); - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, + rspamd_symbols_cache_add_symbol (cfg->cache, dkim_module_ctx->symbol_allow, - 1, + 0, + NULL, NULL, + SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_FINE, cb_id); dkim_module_ctx->dkim_hash = rspamd_lru_hash_new ( diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index 783b9393f..7d240fcec 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -176,8 +176,11 @@ parse_flags (struct fuzzy_rule *rule, /* Add flag to hash table */ g_hash_table_insert (rule->mappings, GINT_TO_POINTER (map->fuzzy_flag), map); - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, - map->symbol, 1.0, cb_id); + rspamd_symbols_cache_add_symbol (cfg->cache, + map->symbol, 0, + NULL, NULL, + SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_FINE, + cb_id); } else { msg_err ("fuzzy_map parameter has no flag definition"); @@ -386,8 +389,11 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, gint cb_id fuzzy_module_ctx->fuzzy_rules, rule); if (rule->symbol != fuzzy_module_ctx->default_symbol) { - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, rule->symbol, - 1.0, cb_id); + rspamd_symbols_cache_add_symbol (cfg->cache, rule->symbol, + 0, + NULL, NULL, + SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_FINE, + cb_id); } } @@ -487,8 +493,10 @@ fuzzy_check_module_config (struct rspamd_config *cfg) if ((value = rspamd_config_get_module_opt (cfg, "fuzzy_check", "rule")) != NULL) { - cb_id = rspamd_symbols_cache_add_symbol_callback (cfg->cache, - 1.0, fuzzy_symbol_callback, NULL); + cb_id = rspamd_symbols_cache_add_symbol (cfg->cache, + "FUZZY_CALLBACK", 0, fuzzy_symbol_callback, NULL, + SYMBOL_TYPE_CALLBACK|SYMBOL_TYPE_FINE, + -1); LL_FOREACH (value, cur) { fuzzy_parse_rule (cfg, cur, cb_id); diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index ed677ce98..489a64364 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -146,11 +146,12 @@ regexp_module_config (struct rspamd_config *cfg) res = FALSE; } else { - rspamd_symbols_cache_add_symbol_normal (cfg->cache, + rspamd_symbols_cache_add_symbol (cfg->cache, cur_item->symbol, - 1, + 0, process_regexp_item, - cur_item); + cur_item, + SYMBOL_TYPE_NORMAL, -1); } } else if (value->type == UCL_USERDATA) { @@ -158,11 +159,12 @@ regexp_module_config (struct rspamd_config *cfg) sizeof (struct regexp_module_item)); cur_item->symbol = ucl_object_key (value); cur_item->lua_function = ucl_object_toclosure (value); - rspamd_symbols_cache_add_symbol_normal (cfg->cache, + rspamd_symbols_cache_add_symbol (cfg->cache, cur_item->symbol, - 1, + 0, process_regexp_item, - cur_item); + cur_item, + SYMBOL_TYPE_NORMAL, -1); } else { msg_warn ("unknown type of attribute %s for regexp module", diff --git a/src/plugins/spf.c b/src/plugins/spf.c index caff118e4..51673bcba 100644 --- a/src/plugins/spf.c +++ b/src/plugins/spf.c @@ -167,17 +167,27 @@ spf_module_config (struct rspamd_config *cfg) } } - cb_id = rspamd_symbols_cache_add_symbol_normal (cfg->cache, + cb_id = rspamd_symbols_cache_add_symbol (cfg->cache, spf_module_ctx->symbol_fail, - 1, + 0, spf_symbol_callback, - NULL); - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, - spf_module_ctx->symbol_softfail, 1, cb_id); - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, - spf_module_ctx->symbol_neutral, 1, cb_id); - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, - spf_module_ctx->symbol_allow, 1, cb_id); + NULL, + SYMBOL_TYPE_NORMAL|SYMBOL_TYPE_FINE, -1); + rspamd_symbols_cache_add_symbol (cfg->cache, + spf_module_ctx->symbol_softfail, 0, + NULL, NULL, + SYMBOL_TYPE_VIRTUAL, + cb_id); + rspamd_symbols_cache_add_symbol (cfg->cache, + spf_module_ctx->symbol_neutral, 0, + NULL, NULL, + SYMBOL_TYPE_VIRTUAL, + cb_id); + rspamd_symbols_cache_add_symbol (cfg->cache, + spf_module_ctx->symbol_allow, 0, + NULL, NULL, + SYMBOL_TYPE_VIRTUAL, + cb_id); spf_module_ctx->spf_hash = rspamd_lru_hash_new ( cache_size, diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 997115d6d..5a4b0a86d 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -315,21 +315,24 @@ register_bit_symbols (struct rspamd_config *cfg, struct suffix_item *suffix, while (g_hash_table_iter_next (&it, &k, &v)) { bit = v; - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, bit->symbol, - 1, parent_id); + rspamd_symbols_cache_add_symbol (cfg->cache, bit->symbol, + 0, NULL, NULL, + SYMBOL_TYPE_VIRTUAL, parent_id); msg_debug ("bit: %d", bit->bit); } } else if (suffix->bits != NULL) { for (i = 0; i < suffix->bits->len; i++) { bit = &g_array_index (suffix->bits, struct surbl_bit_item, i); - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, bit->symbol, - 1, parent_id); + rspamd_symbols_cache_add_symbol (cfg->cache, bit->symbol, + 0, NULL, NULL, + SYMBOL_TYPE_VIRTUAL, parent_id); } } else { - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, suffix->symbol, - 1, parent_id); + rspamd_symbols_cache_add_symbol (cfg->cache, suffix->symbol, + 0, NULL, NULL, + SYMBOL_TYPE_VIRTUAL, parent_id); } } @@ -371,7 +374,7 @@ surbl_module_config (struct rspamd_config *cfg) surbl_module_ctx->redirector_symbol = ucl_obj_tostring (value); rspamd_symbols_cache_add_symbol (cfg->cache, surbl_module_ctx->redirector_symbol, - 1.0, 0, NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1); + 0, NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1); } else { surbl_module_ctx->redirector_symbol = NULL; @@ -486,10 +489,13 @@ surbl_module_config (struct rspamd_config *cfg) } } - cb_id = rspamd_symbols_cache_add_symbol_callback (cfg->cache, - 1, - surbl_test_url, - new_suffix); + cb_id = rspamd_symbols_cache_add_symbol (cfg->cache, + "SURBL_CALLBACK", + 0, + surbl_test_url, + new_suffix, + SYMBOL_TYPE_CALLBACK, + -1); new_suffix->callback_id = cb_id; has_subsymbols = FALSE; @@ -572,9 +578,11 @@ surbl_module_config (struct rspamd_config *cfg) if (!has_subsymbols) { /* Register just a symbol itself */ - rspamd_symbols_cache_add_symbol_virtual (cfg->cache, + rspamd_symbols_cache_add_symbol (cfg->cache, new_suffix->symbol, - 1, + 0, + NULL, NULL, + SYMBOL_TYPE_VIRTUAL, cb_id); } surbl_module_ctx->suffixes = g_list_prepend ( |