aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorAndrew Lewis <nerf@judo.za.org>2016-10-11 17:21:51 +0200
committerAndrew Lewis <nerf@judo.za.org>2016-10-11 17:21:51 +0200
commit237e498ff32ddf6653c0a3723aed5e5ae19efa8a (patch)
tree1aacdcff3f1c0bfe78381273665293afd638d52b /src/lua
parent12ced82ec451134b1d32b07966670646cc63894b (diff)
downloadrspamd-237e498ff32ddf6653c0a3723aed5e5ae19efa8a.tar.gz
rspamd-237e498ff32ddf6653c0a3723aed5e5ae19efa8a.zip
[Feature] Allow getting task UID from Lua
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_task.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index a3354acb6..89875d51c 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -266,6 +266,11 @@ LUA_FUNCTION_DEF (task, get_received_headers);
*/
LUA_FUNCTION_DEF (task, get_queue_id);
/***
+ * @method task:get_uid()
+ * Returns ID of the task being processed.
+ */
+LUA_FUNCTION_DEF (task, get_uid);
+/***
* @method task:get_resolver()
* Returns ready to use rspamd_resolver object suitable for making asynchronous DNS requests.
* @return {rspamd_resolver} resolver object associated with the task's session
@@ -704,6 +709,7 @@ static const struct luaL_reg tasklib_m[] = {
LUA_INTERFACE_DEF (task, get_raw_headers),
LUA_INTERFACE_DEF (task, get_received_headers),
LUA_INTERFACE_DEF (task, get_queue_id),
+ LUA_INTERFACE_DEF (task, get_uid),
LUA_INTERFACE_DEF (task, get_resolver),
LUA_INTERFACE_DEF (task, inc_dns_req),
LUA_INTERFACE_DEF (task, get_dns_req),
@@ -1599,6 +1605,21 @@ lua_task_get_queue_id (lua_State *L)
}
static gint
+lua_task_get_uid (lua_State *L)
+{
+ struct rspamd_task *task = lua_check_task (L, 1);
+
+ if (task) {
+ lua_pushstring (L, task->task_pool->tag.uid);
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 1;
+}
+
+static gint
lua_task_get_resolver (lua_State *L)
{
struct rspamd_task *task = lua_check_task (L, 1);