diff options
author | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-04-06 20:46:55 +0400 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rambler-co.ru> | 2012-04-06 20:46:55 +0400 |
commit | efe165bc3d0f8b225be40bb8bd0bfebf7e972f04 (patch) | |
tree | a0c0b28fe9fecb53dd73281bea3efc337209ae07 /src/lua | |
parent | e5d0c7f8f6cda246eddfcab82b056650be753fe7 (diff) | |
download | rspamd-efe165bc3d0f8b225be40bb8bd0bfebf7e972f04.tar.gz rspamd-efe165bc3d0f8b225be40bb8bd0bfebf7e972f04.zip |
* Add ratelimit plugin
Some polishing of lua task api.
Diffstat (limited to 'src/lua')
-rw-r--r-- | src/lua/lua_task.c | 24 | ||||
-rw-r--r-- | src/lua/lua_upstream.c | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index d205016e0..7ca1c58df 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -69,6 +69,7 @@ LUA_FUNCTION_DEF (task, get_helo); LUA_FUNCTION_DEF (task, get_images); LUA_FUNCTION_DEF (task, get_symbol); LUA_FUNCTION_DEF (task, get_date); +LUA_FUNCTION_DEF (task, get_timeval); LUA_FUNCTION_DEF (task, get_metric_score); LUA_FUNCTION_DEF (task, get_metric_action); LUA_FUNCTION_DEF (task, learn_statfile); @@ -100,6 +101,7 @@ static const struct luaL_reg tasklib_m[] = { LUA_INTERFACE_DEF (task, get_images), LUA_INTERFACE_DEF (task, get_symbol), LUA_INTERFACE_DEF (task, get_date), + LUA_INTERFACE_DEF (task, get_timeval), LUA_INTERFACE_DEF (task, get_metric_score), LUA_INTERFACE_DEF (task, get_metric_action), LUA_INTERFACE_DEF (task, learn_statfile), @@ -1169,6 +1171,28 @@ lua_task_get_date (lua_State *L) } static gint +lua_task_get_timeval (lua_State *L) +{ + struct worker_task *task = lua_check_task (L); + + if (task != NULL) { + lua_newtable (L); + lua_pushstring (L, "tv_sec"); + lua_pushnumber (L, (lua_Number)task->tv.tv_sec); + lua_settable (L, -3); + lua_pushstring (L, "tv_usec"); + lua_pushnumber (L, (lua_Number)task->tv.tv_usec); + lua_settable (L, -3); + } + else { + lua_pushnil (L); + } + + return 1; +} + + +static gint lua_task_learn_statfile (lua_State *L) { struct worker_task *task = lua_check_task (L); diff --git a/src/lua/lua_upstream.c b/src/lua/lua_upstream.c index 5c72f7949..f9e74e027 100644 --- a/src/lua/lua_upstream.c +++ b/src/lua/lua_upstream.c @@ -72,8 +72,8 @@ static const struct luaL_reg upstream_m[] = { LUA_INTERFACE_DEF (upstream, get_ip_string), LUA_INTERFACE_DEF (upstream, get_port), LUA_INTERFACE_DEF (upstream, get_priority), + LUA_INTERFACE_DEF (upstream, destroy), {"__tostring", lua_class_tostring}, - {"__gc", lua_upstream_destroy}, {NULL, NULL} }; static const struct luaL_reg upstream_f[] = { |