summaryrefslogtreecommitdiffstats
path: root/src/spf.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2011-06-10 17:28:19 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2011-06-10 17:28:19 +0400
commit2b5a8d60da266be61d35b285bc14a8c5d71798e7 (patch)
treec0319c35813e6060d358b3f929e6b4422053caa7 /src/spf.c
parent8535693674a5e6d6b8a01c9fee43ef4d836c0909 (diff)
downloadrspamd-2b5a8d60da266be61d35b285bc14a8c5d71798e7.tar.gz
rspamd-2b5a8d60da266be61d35b285bc14a8c5d71798e7.zip
* Add LRU caching structure
* Add SPF records cache * Add ability to parse doubles to xmlrpc Several fixes to dns interface. Trie plugin now checks urls as well.
Diffstat (limited to 'src/spf.c')
-rw-r--r--src/spf.c38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/spf.c b/src/spf.c
index 7c0e82ec6..c6498f69b 100644
--- a/src/spf.c
+++ b/src/spf.c
@@ -1171,13 +1171,47 @@ spf_dns_callback (struct rspamd_dns_reply *reply, gpointer arg)
}
}
+gchar *
+get_spf_domain (struct worker_task *task)
+{
+ gchar *domain, *res = NULL;
+ GList *domains;
+
+ if (task->from && (domain = strchr (task->from, '@')) != NULL && *domain == '@') {
+ res = memory_pool_strdup (task->task_pool, domain + 1);
+ if ((domain = strchr (res, '>')) != NULL) {
+ *domain = '\0';
+ }
+ }
+ else {
+ /* Extract from header */
+ domains = message_get_header (task->task_pool, task->message, "From", FALSE);
+
+ if (domains != NULL) {
+ res = memory_pool_strdup (task->task_pool, domains->data);
+
+ if ((domain = strrchr (res, '@')) == NULL) {
+ g_list_free (domains);
+ return NULL;
+ }
+ res = memory_pool_strdup (task->task_pool, domain + 1);
+ g_list_free (domains);
+
+ if ((domain = strchr (res, '>')) != NULL) {
+ *domain = '\0';
+ }
+ }
+ }
+
+ return res;
+}
gboolean
resolve_spf (struct worker_task *task, spf_cb_t callback)
{
- struct spf_record *rec;
+ struct spf_record *rec;
gchar *domain;
- GList *domains;
+ GList *domains;
rec = memory_pool_alloc0 (task->task_pool, sizeof (struct spf_record));
rec->task = task;