static gboolean
spf_check_element (struct spf_resolved *rec, struct spf_addr *addr,
- struct rspamd_task *task)
+ struct rspamd_task *task, gboolean cached)
{
gboolean res = FALSE;
const guint8 *s, *d;
if (res) {
spf_result = rspamd_mempool_alloc (task->task_pool,
- strlen (addr->spf_string) + 2);
+ strlen (addr->spf_string) + 5);
switch (addr->mech) {
case SPF_FAIL:
break;
}
- rspamd_strlcpy (spf_result + 1, addr->spf_string,
+ gint r = rspamd_strlcpy (spf_result + 1, addr->spf_string,
strlen (addr->spf_string) + 1);
+ if (cached) {
+ rspamd_strlcpy (spf_result + r + 1, ":c", 3);
+ }
+
rspamd_task_insert_result (task,
spf_symbol,
1,
}
static void
-spf_check_list (struct spf_resolved *rec, struct rspamd_task *task)
+spf_check_list (struct spf_resolved *rec, struct rspamd_task *task, gboolean cached)
{
guint i;
struct spf_addr *addr;
for (i = 0; i < rec->elts->len; i ++) {
addr = &g_array_index (rec->elts, struct spf_addr, i);
- if (spf_check_element (rec, addr, task)) {
+ if (spf_check_element (rec, addr, task, cached)) {
break;
}
}
rspamd_lru_hash_insert (spf_module_ctx->spf_hash,
record->domain, spf_record_ref (l),
task->tv.tv_sec, record->ttl);
+
+ msg_info_task ("stored record for %s in LRU cache for %d seconds, "
+ "%d/%d elements in the cache",
+ record->domain,
+ record->ttl,
+ rspamd_lru_hash_size (spf_module_ctx->spf_hash),
+ rspamd_lru_hash_capacity (spf_module_ctx->spf_hash));
}
}
spf_record_ref (l);
- spf_check_list (l, task);
+ spf_check_list (l, task, FALSE);
spf_record_unref (l);
spf_record_unref (record);
rspamd_lru_hash_lookup (spf_module_ctx->spf_hash, domain,
task->tv.tv_sec)) != NULL) {
spf_record_ref (l);
- spf_check_list (l, task);
+ spf_check_list (l, task, TRUE);
spf_record_unref (l);
}
else {