]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Store all received headers in lua
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 9 Feb 2017 16:37:34 +0000 (16:37 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 9 Feb 2017 16:37:34 +0000 (16:37 +0000)
src/libmime/message.h
src/libmime/mime_headers.c
src/lua/lua_task.c

index 2e0bd6bd57f95bcf297519a66b68e04ec6b42a89..da816ad43cb476486f868229536b9c121aab25a5 100644 (file)
@@ -111,6 +111,7 @@ struct received_header {
        gchar *by_hostname;
        gchar *for_mbox;
        rspamd_inet_addr_t *addr;
+       struct rspamd_mime_header *hdr;
        time_t timestamp;
        enum rspamd_received_type type;
 };
index 35c13d1f3a460754fe15c9cb6bdc05e3f85f797e..bff84efcc470a0b6931bd88ee96fbb0c3511b315 100644 (file)
@@ -37,6 +37,7 @@ rspamd_mime_header_check_special (struct rspamd_task *task,
        case 0x88705DC4D9D61ABULL:      /* received */
                recv = rspamd_mempool_alloc0 (task->task_pool,
                                sizeof (struct received_header));
+               recv->hdr = rh;
                rspamd_smtp_recieved_parse (task, rh->decoded,
                                strlen (rh->decoded), recv);
                g_ptr_array_add (task->received, recv);
index c59ae33dc619d41b7a29c37707a433e75f4686dd..d7fabd213a8c7ee9e3dbe7aa6ddaa67399d40ee5 100644 (file)
@@ -1548,15 +1548,19 @@ lua_task_get_received_headers (lua_State * L)
                for (i = 0; i < task->received->len; i ++) {
                        rh = g_ptr_array_index (task->received, i);
 
+                       lua_createtable (L, 0, 9);
+                       rspamd_lua_table_set (L, "raw", rh->hdr->decoded);
+
                        if (G_UNLIKELY (rh->from_ip == NULL &&
                                        rh->real_ip == NULL &&
                                        rh->real_hostname == NULL &&
                                        rh->by_hostname == NULL && rh->timestamp == 0 &&
                                        rh->for_mbox == NULL)) {
+                               lua_rawseti (L, -2, k ++);
+
                                continue;
                        }
 
-                       lua_createtable (L, 0, 8);
                        rspamd_lua_table_set (L, "from_hostname", rh->from_hostname);
                        rspamd_lua_table_set (L, "from_ip", rh->from_ip);
                        rspamd_lua_table_set (L, "real_hostname", rh->real_hostname);
@@ -1592,6 +1596,7 @@ lua_task_get_received_headers (lua_State * L)
                                proto = "unknown";
                                break;
                        }
+
                        lua_pushstring (L, proto);
                        lua_settable (L, -3);