Skip to content

Commit fae4167

Browse files
committed
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.
1 parent d81a3e1 commit fae4167

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pdns/lua-auth.cc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ static int ldp_getRemote(lua_State *L) {
160160
return 1;
161161
}
162162

163+
// these functions are used for PowerDNS recursor regresseion testing against auth. The Lua 5.2 implementation is most likely broken.
164+
#if LUA_VERSION_NUM < 502
163165
static const struct luaL_reg ldp_methods [] = {
164166
{"setRcode", ldp_setRcode},
165167
{"getQuestion", ldp_getQuestion},
@@ -180,6 +182,28 @@ void AuthLua::registerLuaDNSPacket(void) {
180182

181183
lua_pop(d_lua, 1);
182184
}
185+
#else
186+
static const struct luaL_Reg ldp_methods [] = {
187+
{"setRcode", ldp_setRcode},
188+
{"getQuestion", ldp_getQuestion},
189+
{"addRecords", ldp_addRecords},
190+
{"getRemote", ldp_getRemote},
191+
{NULL, NULL}
192+
};
193+
194+
void AuthLua::registerLuaDNSPacket(void) {
195+
196+
luaL_newmetatable(d_lua, "LuaDNSPacket");
197+
198+
lua_pushstring(d_lua, "__index");
199+
lua_pushvalue(d_lua, -2); /* pushes the metatable */
200+
lua_settable(d_lua, -3); /* metatable.__index = metatable */
201+
202+
luaL_newlib(d_lua, ldp_methods);
203+
204+
lua_pop(d_lua, 1);
205+
}
206+
#endif
183207

184208
DNSPacket* AuthLua::prequery(DNSPacket *p)
185209
{

0 commit comments

Comments
 (0)