aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-21 17:38:59 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-07-21 17:40:07 +0100
commitac08fb2c7a6dbc516fca2c904d79049a2d37d3c4 (patch)
tree79924b87162ff0c333e4109f98a13369455a380e /src/lua
parent77144b15cac31a0fdec85e830fce569c5b0d8daf (diff)
downloadrspamd-ac08fb2c7a6dbc516fca2c904d79049a2d37d3c4.tar.gz
rspamd-ac08fb2c7a6dbc516fca2c904d79049a2d37d3c4.zip
[Feature] Allow to pass extradata from rspamd to rmilter
Diffstat (limited to 'src/lua')
-rw-r--r--src/lua/lua_task.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c
index d18eaa4ea..e11c3e5c1 100644
--- a/src/lua/lua_task.c
+++ b/src/lua/lua_task.c
@@ -534,11 +534,23 @@ LUA_FUNCTION_DEF (task, get_settings);
/***
* @method task:get_settings_id()
* Get numeric hash of settings id if specified for this task. 0 is returned otherwise.
- * @param {any} obj any lua object that corresponds to the settings format
+ * @return {number} settings-id hash
*/
LUA_FUNCTION_DEF (task, get_settings_id);
/***
+ * @method task:set_rmilter_reply(obj)
+ * Set special reply for rmilter
+ * @param {any} obj any lua object that corresponds to the settings format
+ * @example
+task:set_rmilter_reply({
+ add_headers = {{'X-Lua', 'test'}},
+ remove_headers = {'DKIM-Signature},
+})
+ */
+LUA_FUNCTION_DEF (task, set_rmilter_reply);
+
+/***
* @method task:process_re(params)
* Processes the specified regexp and returns number of captures (cached or new)
* Params is the table with the follwoing fields (mandatory fields are marked with `*`):
@@ -716,6 +728,7 @@ static const struct luaL_reg tasklib_m[] = {
LUA_INTERFACE_DEF (task, set_flag),
LUA_INTERFACE_DEF (task, get_flags),
LUA_INTERFACE_DEF (task, has_flag),
+ LUA_INTERFACE_DEF (task, set_rmilter_reply),
{"__tostring", rspamd_lua_class_tostring},
{NULL, NULL}
};
@@ -2843,6 +2856,25 @@ lua_task_set_settings (lua_State *L)
}
static gint
+lua_task_set_rmilter_reply (lua_State *L)
+{
+ struct rspamd_task *task = lua_check_task (L, 1);
+ ucl_object_t *reply;
+
+ reply = ucl_object_lua_import (L, 2);
+
+ if (reply != NULL && task != NULL) {
+ rspamd_mempool_set_variable (task->task_pool, "rmilter-reply",
+ reply, (rspamd_mempool_destruct_t)ucl_object_unref);
+ }
+ else {
+ return luaL_error (L, "invalid arguments");
+ }
+
+ return 0;
+}
+
+static gint
lua_task_get_settings (lua_State *L)
{
struct rspamd_task *task = lua_check_task (L, 1);