aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-04 14:17:09 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-10-04 14:17:09 +0100
commitc46f69723fe4b9a3436136863803b4192c0448c6 (patch)
tree64171f35aeb3e33e9b13fc95384cfb6f70732c03 /src/lua
parent4ae5dc6bf798912b865ee7a25faedcacbf5841a4 (diff)
downloadrspamd-c46f69723fe4b9a3436136863803b4192c0448c6.tar.gz
rspamd-c46f69723fe4b9a3436136863803b4192c0448c6.zip
[Feature] Store `for` in task:get_received_headers
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_task.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index db10abe01..8da6d3f16 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -250,6 +250,9 @@ LUA_FUNCTION_DEF (task, get_raw_headers);
* - `real_hostname` - hostname as resolved by MTA
* - `real_ip` - string representation of IP as resolved by PTR request of MTA
* - `by_hostname` - MTA hostname
+ * - `proto` - protocol, e.g. ESMTP or ESMTPS
+ * - `timestamp` - received timetamp
+ * - `for` - for value (unparsed mailbox)
*
* Please note that in some situations rspamd cannot parse all the fields of received headers.
* In that case you should check all strings for validity.
@@ -1499,7 +1502,7 @@ lua_task_get_received_headers (lua_State * L)
guint i, k = 1;
if (task) {
- lua_newtable (L);
+ lua_createtable (L, task->received->len, 0);
for (i = 0; i < task->received->len; i ++) {
rh = g_ptr_array_index (task->received, i);
@@ -1507,11 +1510,12 @@ lua_task_get_received_headers (lua_State * L)
if (G_UNLIKELY (rh->from_ip == NULL &&
rh->real_ip == NULL &&
rh->real_hostname == NULL &&
- rh->by_hostname == NULL && rh->timestamp == 0)) {
+ rh->by_hostname == NULL && rh->timestamp == 0 &&
+ rh->for_mbox == NULL)) {
continue;
}
- lua_newtable (L);
+ 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);
@@ -1555,6 +1559,7 @@ lua_task_get_received_headers (lua_State * L)
lua_settable (L, -3);
rspamd_lua_table_set (L, "by_hostname", rh->by_hostname);
+ rspamd_lua_table_set (L, "for", rh->for_mbox);
lua_rawseti (L, -2, k ++);
}
}