Permalink
Browse files

fix up so we at least compile against lua5.2 for our internal testing…

… functions, they probably don't work yet, but this will not impact production use.
  • Loading branch information...
1 parent d81a3e1 commit fae4167e56d12c091e364b683b8c9eb707ef5c56 @ahupowerdns ahupowerdns committed May 24, 2013
Showing with 24 additions and 0 deletions.
  1. +24 −0 pdns/lua-auth.cc
View
@@ -160,6 +160,8 @@ static int ldp_getRemote(lua_State *L) {
return 1;
}
+// these functions are used for PowerDNS recursor regresseion testing against auth. The Lua 5.2 implementation is most likely broken.
+#if LUA_VERSION_NUM < 502
static const struct luaL_reg ldp_methods [] = {
{"setRcode", ldp_setRcode},
{"getQuestion", ldp_getQuestion},
@@ -180,6 +182,28 @@ void AuthLua::registerLuaDNSPacket(void) {
lua_pop(d_lua, 1);
}
+#else
+static const struct luaL_Reg ldp_methods [] = {
+ {"setRcode", ldp_setRcode},
+ {"getQuestion", ldp_getQuestion},
+ {"addRecords", ldp_addRecords},
+ {"getRemote", ldp_getRemote},
+ {NULL, NULL}
+ };
+
+void AuthLua::registerLuaDNSPacket(void) {
+
+ luaL_newmetatable(d_lua, "LuaDNSPacket");
+
+ lua_pushstring(d_lua, "__index");
+ lua_pushvalue(d_lua, -2); /* pushes the metatable */
+ lua_settable(d_lua, -3); /* metatable.__index = metatable */
+
+ luaL_newlib(d_lua, ldp_methods);
+
+ lua_pop(d_lua, 1);
+}
+#endif
DNSPacket* AuthLua::prequery(DNSPacket *p)
{

0 comments on commit fae4167

Please sign in to comment.