aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_common.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2012-08-13 20:40:50 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2012-08-13 20:40:50 +0400
commitcd85daafe383de85701d726461e3e464f7f70249 (patch)
tree5216e42fc3ae75d08ac653870b3e82f7f482ea6c /src/lua/lua_common.c
parentac13c4d304d190ead195f12a2db74ae08a91ed6b (diff)
downloadrspamd-cd85daafe383de85701d726461e3e464f7f70249.tar.gz
rspamd-cd85daafe383de85701d726461e3e464f7f70249.zip
* Add DNS resolver lua bindings.
Make lua http library working without task object. Fix a problem with resolver in lua_worker. Added some utility functions to lua api.
Diffstat (limited to 'src/lua/lua_common.c')
-rw-r--r--src/lua/lua_common.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lua/lua_common.c b/src/lua/lua_common.c
index 3f66c3fcd..cb114bb34 100644
--- a/src/lua/lua_common.c
+++ b/src/lua/lua_common.c
@@ -444,6 +444,7 @@ init_lua (struct config_file *cfg)
(void)lua_add_actions_global (L);
(void)luaopen_session (L);
(void)luaopen_io_dispatcher (L);
+ (void)luaopen_dns_resolver (L);
cfg->lua_state = L;
memory_pool_add_destructor (cfg->cfg_pool, (pool_destruct_func)lua_close, L);
@@ -789,3 +790,24 @@ lua_dumpstack (lua_State *L)
}
msg_info (buf);
}
+
+gpointer
+lua_check_class (lua_State *L, gint index, const gchar *name)
+{
+ gpointer p;
+
+ if (lua_type (L, index) == LUA_TUSERDATA) {
+ p = lua_touserdata (L, index);
+ if (p) {
+ if (lua_getmetatable (L, index)) {
+ lua_getfield (L, LUA_REGISTRYINDEX, name); /* get correct metatable */
+ if (lua_rawequal (L, -1, -2)) { /* does it have the correct mt? */
+ lua_pop (L, 2); /* remove both metatables */
+ return p;
+ }
+ lua_pop (L, 2);
+ }
+ }
+ }
+ return NULL;
+}