]> source.dussan.org Git - rspamd.git/commitdiff
Add ability to include domains in views.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 21 Jan 2011 17:00:35 +0000 (20:00 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 21 Jan 2011 17:00:35 +0000 (20:00 +0300)
src/view.c

index b24c26b2801cdfe6b3c6c515392ff878ff954832..24fbcf195731cdce107ffe53f4c816a89e478d21 100644 (file)
@@ -180,6 +180,7 @@ find_view_by_from (GList * views, struct worker_task *task)
        GList                          *cur, *cur_re;
        struct rspamd_view             *v;
        struct rspamd_regexp           *re;
+       gchar                          *from_domain;
 
        if (task->from == NULL) {
                return NULL;
@@ -188,7 +189,14 @@ find_view_by_from (GList * views, struct worker_task *task)
        cur = views;
        while (cur) {
                v = cur->data;
-               /* First try to lookup in hashtable */
+               /* First try to lookup in hashtable domain name */
+               if ((from_domain = strchr (task->from, '@')) != NULL) {
+                       from_domain ++;
+                       if (g_hash_table_lookup (v->from_hash, from_domain) != NULL) {
+                               msg_info ("found view for client from %s", task->from);
+                               return v;
+                       }
+               }
                if (g_hash_table_lookup (v->from_hash, task->from) != NULL) {
                        msg_info ("found view for client from %s", task->from);
                        return v;