Changeset 1509 for trunk/pdns/pdns/lua-pdns-recursor.cc
- Timestamp:
- 02/06/10 14:50:14 (3 years ago)
- Files:
-
- 1 modified
-
trunk/pdns/pdns/lua-pdns-recursor.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pdns/pdns/lua-pdns-recursor.cc
r1472 r1509 85 85 } 86 86 87 int getLocalAddressLua(lua_State* lua) 88 { 89 lua_getfield(lua, LUA_REGISTRYINDEX, "__PowerDNSLua"); 90 PowerDNSLua* pl = (PowerDNSLua*)lua_touserdata(lua, -1); 91 92 lua_pushstring(lua, pl->getLocal().toString().c_str()); 93 return 1; 94 } 95 87 96 int logLua(lua_State *lua) 88 97 { … … 118 127 lua_setglobal(d_lua, "pdnslog"); 119 128 129 lua_pushcfunction(d_lua, getLocalAddressLua); 130 lua_setglobal(d_lua, "getlocaladdress"); 131 120 132 lua_newtable(d_lua); 121 133 … … 127 139 lua_setfield(d_lua, -2, "NXDOMAIN"); 128 140 lua_setglobal(d_lua, "pdns"); 141 142 lua_pushlightuserdata(d_lua, (void*)this); 143 lua_setfield(d_lua, LUA_REGISTRYINDEX, "__PowerDNSLua"); 129 144 } 130 145 … … 177 192 return false; 178 193 } 194 195 d_local = local; 179 196 /* the first argument */ 180 197 lua_pushstring(d_lua, remote.toString().c_str() ); 181 lua_pushstring(d_lua, local.toString().c_str() );182 198 lua_pushstring(d_lua, query.c_str() ); 183 199 lua_pushnumber(d_lua, qtype.getCode() ); 184 200 185 if(lua_pcall(d_lua, 4, 2, 0)) { // error201 if(lua_pcall(d_lua, 3, 2, 0)) { // error 186 202 string error=string("lua error in '"+func+"': ")+lua_tostring(d_lua, -1); 187 203 lua_pop(d_lua, 1); … … 218 234 lua_gettable(d_lua, 2); 219 235 220 uint32_t tmpnum ;236 uint32_t tmpnum=0; 221 237 if(!getFromTable("qtype", tmpnum)) 222 238 rr.qtype=QType::A;