diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-29 12:22:46 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-29 12:22:46 +0000 |
commit | 4929e73f2baaa0dd29759a6705ac8dd1b06beb90 (patch) | |
tree | e5ea92f88a12cb3ad667ef92eda62b643f2adcc9 /src/plugins | |
parent | c16f6393333532ceeb65fdc7f62efbc14a987329 (diff) | |
download | rspamd-4929e73f2baaa0dd29759a6705ac8dd1b06beb90.tar.gz rspamd-4929e73f2baaa0dd29759a6705ac8dd1b06beb90.zip |
[Project] Another rework for symbols cache
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/chartable.c | 8 | ||||
-rw-r--r-- | src/plugins/dkim_check.c | 58 | ||||
-rw-r--r-- | src/plugins/fuzzy_check.c | 22 | ||||
-rw-r--r-- | src/plugins/regexp.c | 20 | ||||
-rw-r--r-- | src/plugins/spf.c | 28 | ||||
-rw-r--r-- | src/plugins/surbl.c | 30 |
6 files changed, 83 insertions, 83 deletions
diff --git a/src/plugins/chartable.c b/src/plugins/chartable.c index 208b78d49..ce80b2e66 100644 --- a/src/plugins/chartable.c +++ b/src/plugins/chartable.c @@ -150,14 +150,14 @@ chartable_module_config (struct rspamd_config *cfg) chartable_module_ctx->threshold = DEFAULT_THRESHOLD; } - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, chartable_module_ctx->symbol, 0, chartable_symbol_callback, NULL, SYMBOL_TYPE_NORMAL, -1); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, chartable_module_ctx->url_symbol, 0, chartable_url_symbol_callback, @@ -668,7 +668,7 @@ chartable_symbol_callback (struct rspamd_task *task, utext_close (&utxt); } - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); } static void @@ -739,5 +739,5 @@ chartable_url_symbol_callback (struct rspamd_task *task, } - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); } diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c index ae4b0f04d..72091fccb 100644 --- a/src/plugins/dkim_check.c +++ b/src/plugins/dkim_check.c @@ -504,50 +504,50 @@ dkim_module_config (struct rspamd_config *cfg) return TRUE; } - cb_id = rspamd_symbols_cache_add_symbol (cfg->cache, + cb_id = rspamd_symcache_add_symbol (cfg->cache, "DKIM_CHECK", 0, dkim_symbol_callback, NULL, SYMBOL_TYPE_CALLBACK, -1); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, dkim_module_ctx->symbol_reject, 0, NULL, NULL, - SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_FINE, + SYMBOL_TYPE_VIRTUAL | SYMBOL_TYPE_FINE, cb_id); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, dkim_module_ctx->symbol_na, 0, NULL, NULL, - SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_FINE, + SYMBOL_TYPE_VIRTUAL | SYMBOL_TYPE_FINE, cb_id); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, dkim_module_ctx->symbol_permfail, 0, NULL, NULL, - SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_FINE, + SYMBOL_TYPE_VIRTUAL | SYMBOL_TYPE_FINE, cb_id); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, dkim_module_ctx->symbol_tempfail, 0, NULL, NULL, - SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_FINE, + SYMBOL_TYPE_VIRTUAL | SYMBOL_TYPE_FINE, cb_id); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, dkim_module_ctx->symbol_allow, 0, NULL, NULL, - SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_FINE, + SYMBOL_TYPE_VIRTUAL | SYMBOL_TYPE_FINE, cb_id); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, "DKIM_TRACE", 0, NULL, NULL, - SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_NOSTAT, + SYMBOL_TYPE_VIRTUAL | SYMBOL_TYPE_NOSTAT, cb_id); rspamd_config_add_symbol (cfg, "DKIM_TRACE", @@ -585,12 +585,12 @@ dkim_module_config (struct rspamd_config *cfg) cfg->cfg_pool, dkim_module_ctx->sign_condition_ref); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, "DKIM_SIGN", 0, dkim_sign_callback, NULL, - SYMBOL_TYPE_CALLBACK|SYMBOL_TYPE_FINE, + SYMBOL_TYPE_CALLBACK | SYMBOL_TYPE_FINE, -1); msg_info_config ("init condition script for DKIM signing"); @@ -598,7 +598,7 @@ dkim_module_config (struct rspamd_config *cfg) * Allow dkim signing to be executed only after dkim check */ if (cb_id > 0) { - rspamd_symbols_cache_add_delayed_dependency (cfg->cache, + rspamd_symcache_add_delayed_dependency (cfg->cache, "DKIM_SIGN", dkim_module_ctx->symbol_reject); } @@ -1119,7 +1119,7 @@ dkim_symbol_callback (struct rspamd_task *task, || (!dkim_module_ctx->check_local && rspamd_inet_address_is_local (task->from_addr, TRUE))) { msg_info_task ("skip DKIM checks for local networks and authorized users"); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -1127,7 +1127,7 @@ dkim_symbol_callback (struct rspamd_task *task, if (rspamd_match_radix_map_addr (dkim_module_ctx->whitelist_ip, task->from_addr) != NULL) { msg_info_task ("skip DKIM checks for whitelisted address"); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -1300,7 +1300,7 @@ dkim_sign_callback (struct rspamd_task *task, msg_err_task ("invalid return value from sign condition: %e", err); g_error_free (err); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -1323,7 +1323,7 @@ dkim_sign_callback (struct rspamd_task *task, lua_settop (L, 0); luaL_error (L, "unknown key type: %s", key_type); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -1338,7 +1338,7 @@ dkim_sign_callback (struct rspamd_task *task, if (arc_idx == 0) { lua_settop (L, 0); luaL_error (L, "no arc idx specified"); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -1348,14 +1348,14 @@ dkim_sign_callback (struct rspamd_task *task, if (arc_cv == NULL) { lua_settop (L, 0); luaL_error (L, "no arc cv specified"); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } if (arc_idx == 0) { lua_settop (L, 0); luaL_error (L, "no arc idx specified"); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -1364,7 +1364,7 @@ dkim_sign_callback (struct rspamd_task *task, lua_settop (L, 0); luaL_error (L, "unknown sign type: %s", sign_type_str); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -1397,7 +1397,7 @@ dkim_sign_callback (struct rspamd_task *task, msg_err_task ("cannot load dkim key %s: %e", lru_key, err); g_error_free (err); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -1422,7 +1422,7 @@ dkim_sign_callback (struct rspamd_task *task, msg_err_task ("cannot load dkim key %s: %e", lru_key, err); g_error_free (err); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -1442,7 +1442,7 @@ dkim_sign_callback (struct rspamd_task *task, msg_err_task ("cannot create sign context: %e", err); g_error_free (err); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -1470,13 +1470,13 @@ dkim_sign_callback (struct rspamd_task *task, if (!sign) { msg_debug_task ("skip signing as dkim condition callback returned" " false"); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } } - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); } struct rspamd_dkim_lua_verify_cbdata { diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c index e61fa7ce3..1f16c5a48 100644 --- a/src/plugins/fuzzy_check.c +++ b/src/plugins/fuzzy_check.c @@ -248,10 +248,10 @@ 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 (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, map->symbol, 0, NULL, NULL, - SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_FINE, + SYMBOL_TYPE_VIRTUAL | SYMBOL_TYPE_FINE, cb_id); } else { @@ -686,10 +686,10 @@ fuzzy_parse_rule (struct rspamd_config *cfg, const ucl_object_t *obj, g_ptr_array_add (fuzzy_module_ctx->fuzzy_rules, rule); if (rule->symbol != fuzzy_module_ctx->default_symbol) { - rspamd_symbols_cache_add_symbol (cfg->cache, rule->symbol, + rspamd_symcache_add_symbol (cfg->cache, rule->symbol, 0, NULL, NULL, - SYMBOL_TYPE_VIRTUAL|SYMBOL_TYPE_FINE, + SYMBOL_TYPE_VIRTUAL | SYMBOL_TYPE_FINE, cb_id); } @@ -1090,10 +1090,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 (cfg->cache, - "FUZZY_CALLBACK", 0, fuzzy_symbol_callback, NULL, - SYMBOL_TYPE_CALLBACK|SYMBOL_TYPE_FINE, - -1); + cb_id = rspamd_symcache_add_symbol (cfg->cache, + "FUZZY_CALLBACK", 0, fuzzy_symbol_callback, NULL, + SYMBOL_TYPE_CALLBACK | SYMBOL_TYPE_FINE, + -1); /* * Here we can have 2 possibilities: @@ -2885,7 +2885,7 @@ register_fuzzy_client_call (struct rspamd_task *task, event_add (&session->timev, &session->tv); rspamd_session_add_event (task->s, fuzzy_io_fin, session, M); - session->item = rspamd_symbols_cache_get_cur_item (task); + session->item = rspamd_symcache_get_cur_item (task); if (session->item) { rspamd_symcache_item_async_inc (task, session->item, M); @@ -2907,7 +2907,7 @@ fuzzy_symbol_callback (struct rspamd_task *task, struct fuzzy_ctx *fuzzy_module_ctx = fuzzy_get_context (task->cfg); if (!fuzzy_module_ctx->enabled) { - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -2919,7 +2919,7 @@ fuzzy_symbol_callback (struct rspamd_task *task, msg_info_task ("<%s>, address %s is whitelisted, skip fuzzy check", task->message_id, rspamd_inet_address_to_string (task->from_addr)); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } diff --git a/src/plugins/regexp.c b/src/plugins/regexp.c index 0f7bb4ff8..b40c9c468 100644 --- a/src/plugins/regexp.c +++ b/src/plugins/regexp.c @@ -172,7 +172,7 @@ regexp_module_config (struct rspamd_config *cfg) res = FALSE; } else { - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, cur_item->symbol, 0, process_regexp_item, @@ -189,12 +189,12 @@ regexp_module_config (struct rspamd_config *cfg) cur_item->symbol = ucl_object_key (value); cur_item->lua_function = ucl_object_toclosure (value); - rspamd_symbols_cache_add_symbol (cfg->cache, - cur_item->symbol, - 0, - process_regexp_item, - cur_item, - SYMBOL_TYPE_NORMAL, -1); + rspamd_symcache_add_symbol (cfg->cache, + cur_item->symbol, + 0, + process_regexp_item, + cur_item, + SYMBOL_TYPE_NORMAL, -1); nlua ++; } else if (value->type == UCL_OBJECT) { @@ -245,7 +245,7 @@ regexp_module_config (struct rspamd_config *cfg) } if (cur_item && (is_lua || valid_expression)) { - id = rspamd_symbols_cache_add_symbol (cfg->cache, + id = rspamd_symcache_add_symbol (cfg->cache, cur_item->symbol, 0, process_regexp_item, @@ -259,7 +259,7 @@ regexp_module_config (struct rspamd_config *cfg) g_assert (cur_item->symbol != NULL); conddata = ucl_object_toclosure (elt); - rspamd_symbols_cache_add_condition_delayed (cfg->cache, + rspamd_symcache_add_condition_delayed (cfg->cache, cur_item->symbol, conddata->L, conddata->idx); } @@ -456,5 +456,5 @@ process_regexp_item (struct rspamd_task *task, rspamd_task_insert_result (task, item->symbol, res, NULL); } - rspamd_symbols_cache_finalize_item (task, symcache_item); + rspamd_symcache_finalize_item (task, symcache_item); } diff --git a/src/plugins/spf.c b/src/plugins/spf.c index 271fd1892..eedaf6c2e 100644 --- a/src/plugins/spf.c +++ b/src/plugins/spf.c @@ -299,38 +299,38 @@ spf_module_config (struct rspamd_config *cfg) &spf_module_ctx->whitelist_ip, NULL); } - cb_id = rspamd_symbols_cache_add_symbol (cfg->cache, - spf_module_ctx->symbol_fail, - 0, - spf_symbol_callback, - NULL, - SYMBOL_TYPE_NORMAL|SYMBOL_TYPE_FINE|SYMBOL_TYPE_EMPTY, -1); - rspamd_symbols_cache_add_symbol (cfg->cache, + cb_id = rspamd_symcache_add_symbol (cfg->cache, + spf_module_ctx->symbol_fail, + 0, + spf_symbol_callback, + NULL, + SYMBOL_TYPE_NORMAL | SYMBOL_TYPE_FINE | SYMBOL_TYPE_EMPTY, -1); + rspamd_symcache_add_symbol (cfg->cache, spf_module_ctx->symbol_softfail, 0, NULL, NULL, SYMBOL_TYPE_VIRTUAL, cb_id); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, spf_module_ctx->symbol_permfail, 0, NULL, NULL, SYMBOL_TYPE_VIRTUAL, cb_id); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, spf_module_ctx->symbol_na, 0, NULL, NULL, SYMBOL_TYPE_VIRTUAL, cb_id); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, spf_module_ctx->symbol_neutral, 0, NULL, NULL, SYMBOL_TYPE_VIRTUAL, cb_id); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, spf_module_ctx->symbol_allow, 0, NULL, NULL, SYMBOL_TYPE_VIRTUAL, cb_id); - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, spf_module_ctx->symbol_dnsfail, 0, NULL, NULL, SYMBOL_TYPE_VIRTUAL, @@ -596,7 +596,7 @@ spf_symbol_callback (struct rspamd_task *task, if (rspamd_match_radix_map_addr (spf_module_ctx->whitelist_ip, task->from_addr) != NULL) { - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -604,7 +604,7 @@ spf_symbol_callback (struct rspamd_task *task, || (!spf_module_ctx->check_local && rspamd_inet_address_is_local (task->from_addr, TRUE))) { msg_info_task ("skip SPF checks for local networks and authorized users"); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 4c3fbefa1..61cda5665 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -611,7 +611,7 @@ 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 (cfg->cache, bit->symbol, + rspamd_symcache_add_symbol (cfg->cache, bit->symbol, 0, NULL, NULL, SYMBOL_TYPE_VIRTUAL, parent_id); msg_debug_config ("bit: %d", bit->bit); @@ -620,13 +620,13 @@ register_bit_symbols (struct rspamd_config *cfg, struct suffix_item *suffix, 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 (cfg->cache, bit->symbol, + rspamd_symcache_add_symbol (cfg->cache, bit->symbol, 0, NULL, NULL, SYMBOL_TYPE_VIRTUAL, parent_id); } } else { - rspamd_symbols_cache_add_symbol (cfg->cache, suffix->symbol, + rspamd_symcache_add_symbol (cfg->cache, suffix->symbol, 0, NULL, NULL, SYMBOL_TYPE_VIRTUAL, parent_id); } @@ -762,9 +762,9 @@ surbl_module_parse_rule (const ucl_object_t* value, struct rspamd_config* cfg) continue; } - cb_id = rspamd_symbols_cache_add_symbol (cfg->cache, "SURBL_CALLBACK", + cb_id = rspamd_symcache_add_symbol (cfg->cache, "SURBL_CALLBACK", 0, surbl_test_url, new_suffix, SYMBOL_TYPE_CALLBACK, -1); - rspamd_symbols_cache_add_dependency (cfg->cache, cb_id, + rspamd_symcache_add_dependency (cfg->cache, cb_id, SURBL_REDIRECTOR_CALLBACK); nrules++; new_suffix->callback_id = cb_id; @@ -895,7 +895,7 @@ surbl_module_parse_rule (const ucl_object_t* value, struct rspamd_config* cfg) if (new_suffix->symbol) { /* Register just a symbol itself */ - rspamd_symbols_cache_add_symbol (cfg->cache, + rspamd_symcache_add_symbol (cfg->cache, new_suffix->symbol, 0, NULL, NULL, SYMBOL_TYPE_VIRTUAL, cb_id); nrules++; @@ -949,7 +949,7 @@ surbl_module_config (struct rspamd_config *cfg) lua_pop (L, 1); /* Remove global function */ - (void)rspamd_symbols_cache_add_symbol (cfg->cache, SURBL_REDIRECTOR_CALLBACK, + (void) rspamd_symcache_add_symbol (cfg->cache, SURBL_REDIRECTOR_CALLBACK, 0, surbl_test_redirector, NULL, SYMBOL_TYPE_CALLBACK, -1); @@ -973,9 +973,9 @@ surbl_module_config (struct rspamd_config *cfg) rspamd_config_get_module_opt (cfg, "surbl", "redirector_symbol")) != NULL) { surbl_module_ctx->redirector_symbol = ucl_obj_tostring (value); - rspamd_symbols_cache_add_symbol (cfg->cache, - surbl_module_ctx->redirector_symbol, - 0, NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1); + rspamd_symcache_add_symbol (cfg->cache, + surbl_module_ctx->redirector_symbol, + 0, NULL, NULL, SYMBOL_TYPE_COMPOSITE, -1); } else { surbl_module_ctx->redirector_symbol = NULL; @@ -1090,7 +1090,7 @@ surbl_module_config (struct rspamd_config *cfg) } if (cur_suffix->options & SURBL_OPTION_CHECKDKIM) { - rspamd_symbols_cache_add_dependency (cfg->cache, + rspamd_symcache_add_dependency (cfg->cache, cur_suffix->callback_id, "DKIM_TRACE"); } @@ -1715,7 +1715,7 @@ register_redirector_call (struct rspamd_url *url, struct rspamd_task *task, rspamd_session_add_event (task->s, free_redirector_session, param, M); - param->item = rspamd_symbols_cache_get_cur_item (task); + param->item = rspamd_symcache_get_cur_item (task); if (param->item) { rspamd_symcache_item_async_inc (param->task, param->item, M); @@ -1838,7 +1838,7 @@ surbl_tree_redirector_callback (gpointer key, gpointer value, void *data) *purl = url; rspamd_lua_setclass (L, "rspamd{url}", -1); lua_pushlightuserdata (L, nparam); - rspamd_symbols_cache_set_cur_item (task, param->item); + rspamd_symcache_set_cur_item (task, param->item); if (lua_pcall (L, 3, 0, 0) != 0) { msg_err_task ("cannot call for redirector script: %s", @@ -1904,7 +1904,7 @@ surbl_test_url (struct rspamd_task *task, if (!rspamd_monitored_alive (suffix->m)) { msg_info_surbl ("disable surbl %s as it is reported to be offline", suffix->suffix); - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } @@ -1984,7 +1984,7 @@ surbl_test_redirector (struct rspamd_task *task, struct surbl_ctx *surbl_module_ctx = surbl_get_context (task->cfg); if (!surbl_module_ctx->use_redirector || !surbl_module_ctx->redirector_tlds) { - rspamd_symbols_cache_finalize_item (task, item); + rspamd_symcache_finalize_item (task, item); return; } |