}
server_stat->fuzzy_hashes --;
g_hash_table_remove (static_hash, node->h.hash_pipe);
- bloom_del (bf, node->h.hash_pipe);
+ rspamd_bloom_del (bf, node->h.hash_pipe);
g_slice_free1 (sizeof (struct rspamd_fuzzy_node), node);
}
else {
node = (struct rspamd_fuzzy_node *)cur->data;
head = hashes[node->h.block_size % BUCKETS];
g_queue_delete_link (head, cur);
- bloom_del (bf, node->h.hash_pipe);
+ rspamd_bloom_del (bf, node->h.hash_pipe);
if (node->time != INVALID_NODE_TIME) {
server_stat->fuzzy_hashes_expired ++;
}
g_queue_push_head (hashes[node->h.block_size % BUCKETS], node);
}
}
- bloom_add (bf, node->h.hash_pipe);
+ rspamd_bloom_add (bf, node->h.hash_pipe);
if (touch_stat) {
server_stat->fuzzy_hashes ++;
}
struct rspamd_fuzzy_node *h;
- if (!bloom_check (bf, cmd->hash)) {
+ if (!rspamd_bloom_check (bf, cmd->hash)) {
return 0;
}
{
struct rspamd_fuzzy_node *h;
- if (bloom_check (bf, cmd->hash)) {
+ if (rspamd_bloom_check (bf, cmd->hash)) {
if (update_hash (cmd, time, ctx)) {
return TRUE;
}
tmp = cur;
cur = g_list_next (cur);
g_queue_delete_link (hash, tmp);
- bloom_del (bf, s->hash_pipe);
+ rspamd_bloom_del (bf, s->hash_pipe);
msg_info ("fuzzy hash was successfully deleted");
server_stat->fuzzy_hashes --;
mods++;
fuzzy_hash_t s;
gboolean res = FALSE;
- if (!bloom_check (bf, cmd->hash)) {
+ if (!rspamd_bloom_check (bf, cmd->hash)) {
return FALSE;
}
rspamd_mutex_unlock (ctx->update_mtx);
}
-static gboolean
-parse_fuzzy_update_list (struct rspamd_fuzzy_storage_ctx *ctx)
-{
- gchar **strvec, **cur;
- struct in_addr ina;
- guint32 mask;
-
- strvec = g_strsplit_set (ctx->update_map, ",", 0);
- cur = strvec;
-
- while (*cur != NULL) {
- /* XXX: handle only ipv4 addresses */
- if (parse_ipmask_v4 (*cur, &ina, &mask)) {
- if (ctx->update_ips == NULL) {
- ctx->update_ips = radix_tree_create ();
- }
- radix32tree_add (ctx->update_ips, htonl (ina.s_addr), mask, 1);
- }
- cur ++;
- }
-
- return (ctx->update_ips != NULL);
-}
-
gpointer
init_fuzzy (struct config_file *cfg)
{
event_base_set (ctx->ev_base, &sev);
signal_add (&sev, NULL);
- /* Init bloom filter */
- bf = rspamd_bloom_create (2000000L, RSPAMD_DEFAULT_BLOOM_HASHES);
- /* Try to read hashes from file */
- if (!read_hashes_file (worker)) {
- msg_err ("cannot read hashes file, it can be created after save procedure");
- }
-
if (ctx->strict_hash) {
static_hash = g_hash_table_new_full (rspamd_str_hash, rspamd_str_equal,
NULL, rspamd_fuzzy_free_node);
frequent = g_queue_new ();
}
+ /* Init bloom filter */
+ bf = rspamd_bloom_create (2000000L, RSPAMD_DEFAULT_BLOOM_HASHES);
+ /* Try to read hashes from file */
+ if (!read_hashes_file (worker)) {
+ msg_err ("cannot read hashes file, it can be created after save procedure");
+ }
+
/* Timer event */
evtimer_set (&tev, sync_callback, worker);
event_base_set (ctx->ev_base, &tev);
if (ctx->update_map != NULL) {
if (!add_map (worker->srv->cfg, ctx->update_map, "Allow fuzzy updates from specified addresses",
read_radix_list, fin_radix_list, (void **)&ctx->update_ips)) {
- if (!parse_fuzzy_update_list (ctx)) {
+ if (!rspamd_parse_ip_list (ctx->update_map, &ctx->update_ips)) {
msg_warn ("cannot load or parse ip list from '%s'", ctx->update_map);
}
}