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/plugins | |
parent | aef19db4a81bcc40db2047c1c540f09f07fc9fd1 (diff) | |
download | rspamd-9fb4a7f6e61d361b46eaae0c6b8dbe2805905e36.tar.gz rspamd-9fb4a7f6e61d361b46eaae0c6b8dbe2805905e36.zip |
Rework symbols weights.
Diffstat (limited to 'src/plugins')
-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 |
6 files changed, 80 insertions, 44 deletions
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 ( |