From: bert hubert Date: Fri, 24 May 2013 09:20:13 +0000 (+0200) Subject: fix up so we at least compile against lua5.2 for our internal testing functions,... X-Git-Tag: auth-3.3-rc1~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fae4167e56d12c091e364b683b8c9eb707ef5c56;p=pdns 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. --- diff --git a/pdns/lua-auth.cc b/pdns/lua-auth.cc index a11e2199e..effcdf062 100644 --- a/pdns/lua-auth.cc +++ b/pdns/lua-auth.cc @@ -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) {