}
/* Process metrics symbols */
- while (call_symbol_callback (task, task->cfg->cache, &item)) {
+ while (rspamd_symbols_cache_process_symbol (task, task->cfg->cache, &item)) {
/* Check reject actions */
cur = task->cfg->metrics_list;
while (cur) {
composite);
if (new) {
- register_virtual_symbol (cfg->cache, composite_name, 1);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, composite_name, 1);
}
return TRUE;
{
struct rspamd_config *cfg = ud;
- register_virtual_symbol (cfg->cache, key, 1.0);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, key, 1.0);
}
void
}
void
-register_symbol_common (struct symbols_cache *cache,
+rspamd_symbols_cache_add_symbol (struct symbols_cache *cache,
const gchar *name,
double weight,
gint priority,
}
void
-register_symbol (struct symbols_cache *cache, const gchar *name, double weight,
+rspamd_symbols_cache_add_symbol_normal (struct symbols_cache *cache, const gchar *name, double weight,
symbol_func_t func, gpointer user_data)
{
- register_symbol_common (cache,
+ rspamd_symbols_cache_add_symbol (cache,
name,
weight,
0,
}
void
-register_virtual_symbol (struct symbols_cache *cache,
+rspamd_symbols_cache_add_symbol_virtual (struct symbols_cache *cache,
const gchar *name,
double weight)
{
- register_symbol_common (cache,
+ rspamd_symbols_cache_add_symbol (cache,
name,
weight,
0,
}
void
-register_callback_symbol (struct symbols_cache *cache,
+rspamd_symbols_cache_add_symbol_callback (struct symbols_cache *cache,
const gchar *name,
double weight,
symbol_func_t func,
gpointer user_data)
{
- register_symbol_common (cache,
+ rspamd_symbols_cache_add_symbol (cache,
name,
weight,
0,
}
void
-register_callback_symbol_priority (struct symbols_cache *cache,
+rspamd_symbols_cache_add_symbol_callback_prio (struct symbols_cache *cache,
const gchar *name,
double weight,
gint priority,
symbol_func_t func,
gpointer user_data)
{
- register_symbol_common (cache,
+ rspamd_symbols_cache_add_symbol (cache,
name,
weight,
priority,
}
gboolean
-init_symbols_cache (struct symbols_cache* cache,
+rspamd_symbols_cache_init (struct symbols_cache* cache,
struct rspamd_config *cfg)
{
gboolean res;
}
gboolean
-validate_cache (struct symbols_cache *cache,
+rspamd_symbols_cache_validate (struct symbols_cache *cache,
struct rspamd_config *cfg,
gboolean strict)
{
}
gboolean
-call_symbol_callback (struct rspamd_task * task,
+rspamd_symbols_cache_process_symbol (struct rspamd_task * task,
struct symbols_cache * cache,
gpointer *save)
{
/**
* Load symbols cache from file, must be called _after_ init_symbols_cache
*/
-gboolean init_symbols_cache (struct symbols_cache* cache,
+gboolean rspamd_symbols_cache_init (struct symbols_cache* cache,
struct rspamd_config *cfg);
/**
* @param func pointer to handler
* @param user_data pointer to user_data
*/
-void register_symbol (struct symbols_cache *cache,
+void rspamd_symbols_cache_add_symbol_normal (struct symbols_cache *cache,
const gchar *name,
double weight,
symbol_func_t func,
* Register virtual symbol
* @param name name of symbol
*/
-void register_virtual_symbol (struct symbols_cache *cache,
+void rspamd_symbols_cache_add_symbol_virtual (struct symbols_cache *cache,
const gchar *name,
double weight);
* @param func pointer to handler
* @param user_data pointer to user_data
*/
-void register_callback_symbol (struct symbols_cache *cache,
+void rspamd_symbols_cache_add_symbol_callback (struct symbols_cache *cache,
const gchar *name,
double weight,
symbol_func_t func,
* @param func pointer to handler
* @param user_data pointer to user_data
*/
-void register_callback_symbol_priority (struct symbols_cache *cache,
+void rspamd_symbols_cache_add_symbol_callback_prio (struct symbols_cache *cache,
const gchar *name,
double weight,
gint priority,
* @param user_data
* @param type
*/
-void
-register_symbol_common (struct symbols_cache *cache,
+void rspamd_symbols_cache_add_symbol (struct symbols_cache *cache,
const gchar *name,
double weight,
gint priority,
* @param cache symbols cache
* @param saved_item pointer to currently saved item
*/
-gboolean call_symbol_callback (struct rspamd_task *task,
+gboolean rspamd_symbols_cache_process_symbol (struct rspamd_task *task,
struct symbols_cache *cache,
gpointer *save);
-/**
- * Remove all dynamic rules from cache
- * @param cache symbols cache
- */
-void remove_dynamic_rules (struct symbols_cache *cache);
-
/**
* Validate cache items agains theirs weights defined in metrics
* @param cache symbols cache
* @param cfg configuration
* @param strict do strict checks - symbols MUST be described in metrics
*/
-gboolean validate_cache (struct symbols_cache *cache,
+gboolean rspamd_symbols_cache_validate (struct symbols_cache *cache,
struct rspamd_config *cfg,
gboolean strict);
}
else {
g_hash_table_insert (cfg->composite_symbols, sym, expr);
- register_virtual_symbol (cfg->cache, sym, 1);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, sym, 1);
}
}
}
cd->L = L;
cd->symbol = rspamd_mempool_strdup (cfg->cfg_pool, name);
- register_symbol_common (cfg->cache,
+ rspamd_symbols_cache_add_symbol (cfg->cache,
name,
weight,
priority,
lua_pushvalue (L, -2);
sym = rspamd_mempool_strdup (cfg->cfg_pool,
luaL_checkstring (L, -2));
- register_virtual_symbol (cfg->cache, sym, weight);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, sym, weight);
lua_pop (L, 2);
}
lua_pop (L, 1);
else if (lua_type (L, i) == LUA_TSTRING) {
sym = rspamd_mempool_strdup (cfg->cfg_pool,
luaL_checkstring (L, i));
- register_virtual_symbol (cfg->cache, sym, weight);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, sym, weight);
}
}
}
name = rspamd_mempool_strdup (cfg->cfg_pool, luaL_checkstring (L, 2));
weight = luaL_checknumber (L, 3);
if (name) {
- register_virtual_symbol (cfg->cache, name, weight);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, name, weight);
}
}
return 0;
composite);
if (new) {
- register_virtual_symbol (cfg->cache, name, 1);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, name, 1);
}
ret = TRUE;
}
else {
rspamd_config_post_load (cfg);
- init_symbols_cache (cfg->cache, cfg);
+ rspamd_symbols_cache_init (cfg->cache, cfg);
pcfg = lua_newuserdata (L, sizeof (struct rspamd_config *));
rspamd_lua_setclass (L, "rspamd{config}", -1);
*pcfg = cfg;
}
else {
rspamd_config_post_load (cfg);
- init_symbols_cache (cfg->cache, cfg);
+ rspamd_symbols_cache_init (cfg->cache, cfg);
pcfg = lua_newuserdata (L, sizeof (struct rspamd_config *));
rspamd_lua_setclass (L, "rspamd{config}", -1);
*pcfg = cfg;
}
rspamd_init_filters (rspamd->cfg, TRUE);
- init_symbols_cache (rspamd->cfg->cache, rspamd->cfg);
+ rspamd_symbols_cache_init (rspamd->cfg->cache, rspamd->cfg);
msg_info ("config has been reread successfully");
}
}
/* Insert classifiers symbols */
(void)rspamd_config_insert_classify_symbols (rspamd_main->cfg);
- if (!validate_cache (rspamd_main->cfg->cache, rspamd_main->cfg,
+ if (!rspamd_symbols_cache_validate (rspamd_main->cfg->cache, rspamd_main->cfg,
FALSE)) {
res = FALSE;
}
setproctitle ("main process");
/* Init config cache */
- init_symbols_cache (rspamd_main->cfg->cache, rspamd_main->cfg);
+ rspamd_symbols_cache_init (rspamd_main->cfg->cache, rspamd_main->cfg);
/* Validate cache */
- (void)validate_cache (rspamd_main->cfg->cache, rspamd_main->cfg, FALSE);
+ (void)rspamd_symbols_cache_validate (rspamd_main->cfg->cache, rspamd_main->cfg, FALSE);
/* Flush log */
rspamd_log_flush (rspamd_main->logger);
chartable_module_ctx->threshold = DEFAULT_THRESHOLD;
}
- register_symbol (cfg->cache,
+ rspamd_symbols_cache_add_symbol_normal (cfg->cache,
chartable_module_ctx->symbol,
1,
chartable_symbol_callback,
"trusted_only option is set and no trusted domains are defined; disabling dkim module completely as it is useless in this case");
}
else {
- register_symbol (cfg->cache,
+ rspamd_symbols_cache_add_symbol_normal (cfg->cache,
dkim_module_ctx->symbol_reject,
1,
dkim_symbol_callback,
NULL);
- register_virtual_symbol (cfg->cache,
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache,
dkim_module_ctx->symbol_tempfail,
1);
- register_virtual_symbol (cfg->cache,
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache,
dkim_module_ctx->symbol_allow,
1);
/* Add flag to hash table */
g_hash_table_insert (rule->mappings,
GINT_TO_POINTER (map->fuzzy_flag), map);
- register_virtual_symbol (cfg->cache, map->symbol, 1.0);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, map->symbol, 1.0);
}
else {
msg_err ("fuzzy_map parameter has no flag definition");
fuzzy_module_ctx->fuzzy_rules,
rule);
if (rule->symbol != fuzzy_module_ctx->default_symbol) {
- register_virtual_symbol (cfg->cache, rule->symbol, 1.0);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, rule->symbol, 1.0);
}
}
}
if (fuzzy_module_ctx->fuzzy_rules != NULL) {
- register_callback_symbol (cfg->cache, fuzzy_module_ctx->default_symbol,
+ rspamd_symbols_cache_add_symbol_callback (cfg->cache, fuzzy_module_ctx->default_symbol,
1.0, fuzzy_symbol_callback, NULL);
}
else {
res = FALSE;
}
else {
- register_symbol (cfg->cache,
+ rspamd_symbols_cache_add_symbol_normal (cfg->cache,
cur_item->symbol,
1,
process_regexp_item,
sizeof (struct regexp_module_item));
cur_item->symbol = ucl_object_key (value);
cur_item->lua_function = ucl_object_toclosure (value);
- register_symbol (cfg->cache,
+ rspamd_symbols_cache_add_symbol_normal (cfg->cache,
cur_item->symbol,
1,
process_regexp_item,
}
}
- register_symbol (cfg->cache,
+ rspamd_symbols_cache_add_symbol_normal (cfg->cache,
spf_module_ctx->symbol_fail,
1,
spf_symbol_callback,
NULL);
- register_virtual_symbol (cfg->cache, spf_module_ctx->symbol_softfail, 1);
- register_virtual_symbol (cfg->cache, spf_module_ctx->symbol_neutral, 1);
- register_virtual_symbol (cfg->cache, spf_module_ctx->symbol_allow, 1);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, spf_module_ctx->symbol_softfail, 1);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, spf_module_ctx->symbol_neutral, 1);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, spf_module_ctx->symbol_allow, 1);
spf_module_ctx->spf_hash = rspamd_lru_hash_new (
cache_size,
while (g_hash_table_iter_next (&it, &k, &v)) {
bit = v;
- register_virtual_symbol (cfg->cache, bit->symbol, 1);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, bit->symbol, 1);
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);
- register_virtual_symbol (cfg->cache, bit->symbol, 1);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, bit->symbol, 1);
}
}
else {
- register_virtual_symbol (cfg->cache, suffix->symbol, 1);
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache, suffix->symbol, 1);
}
}
rspamd_config_get_module_opt (cfg, "surbl",
"redirector_symbol")) != NULL) {
surbl_module_ctx->redirector_symbol = ucl_obj_tostring (value);
- register_virtual_symbol (cfg->cache,
+ rspamd_symbols_cache_add_symbol_virtual (cfg->cache,
surbl_module_ctx->redirector_symbol,
1.0);
}
surbl_module_ctx->suffixes = g_list_prepend (
surbl_module_ctx->suffixes,
new_suffix);
- register_callback_symbol (cfg->cache,
+ rspamd_symbols_cache_add_symbol_callback (cfg->cache,
new_suffix->symbol,
1,
surbl_test_url,