]> source.dussan.org Git - rspamd.git/commitdiff
[Feature] Add task:get_dns_req method
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 11 Mar 2016 17:20:17 +0000 (17:20 +0000)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 11 Mar 2016 17:20:17 +0000 (17:20 +0000)
src/lua/lua_task.c

index b177f168cba3f3e26420e18c4618e0a3259e329a..e5214a321936eb229755dc0a6027f741f48f7ca3 100644 (file)
@@ -276,6 +276,12 @@ LUA_FUNCTION_DEF (task, get_resolver);
  * Increment number of DNS requests for the task. Is used just for logging purposes.
  */
 LUA_FUNCTION_DEF (task, inc_dns_req);
+/***
+ * @method task:get_dns_req()
+ * Get number of dns requests being sent in the task
+ * @return {number} number of DNS requests
+ */
+LUA_FUNCTION_DEF (task, get_dns_req);
 
 /***
  * @method task:has_recipients([type])
@@ -570,6 +576,7 @@ static const struct luaL_reg tasklib_m[] = {
        LUA_INTERFACE_DEF (task, get_queue_id),
        LUA_INTERFACE_DEF (task, get_resolver),
        LUA_INTERFACE_DEF (task, inc_dns_req),
+       LUA_INTERFACE_DEF (task, get_dns_req),
        LUA_INTERFACE_DEF (task, has_recipients),
        LUA_INTERFACE_DEF (task, get_recipients),
        LUA_INTERFACE_DEF (task, has_from),
@@ -1391,6 +1398,21 @@ lua_task_inc_dns_req (lua_State *L)
        return 0;
 }
 
+static gint
+lua_task_get_dns_req (lua_State *L)
+{
+       struct rspamd_task *task = lua_check_task (L, 1);
+
+       if (task != NULL) {
+               lua_pushnumber (L, task->dns_requests);
+       }
+       else {
+               return luaL_error (L, "invalid arguments");
+       }
+
+       return 1;
+}
+
 /*
  * Convert element at the specified position to the type
  * for get_from/get_recipients