]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
luabackend: edns-subnet support 3082/head
authorMagicBear <mb@bilibili.com>
Tue, 22 Dec 2015 15:10:33 +0000 (23:10 +0800)
committerMagicBear <mb@bilibili.com>
Tue, 22 Dec 2015 15:10:33 +0000 (23:10 +0800)
modules/luabackend/lua_functions.cc
modules/luabackend/luabackend.hh
modules/luabackend/minimal.cc

index a8d3f8dbc9c63e04637e452df5bf74aa2d10f1d9..816bcac6dce4aaf8aa1d0523cf9ea08666eac1ed 100644 (file)
@@ -111,8 +111,9 @@ int l_dnspacket (lua_State *lua) {
     lua_pushstring(lua, lb->dnspacket->getRemote().c_str());
     lua_pushnumber(lua, lb->dnspacket->getRemotePort());
     lua_pushstring(lua, lb->dnspacket->getLocal().c_str());
+    lua_pushstring(lua, lb->dnspacket->getRealRemote().toString().c_str());
 
-    return 3;
+    return 4;
 }
 
 int l_logger (lua_State *lua) {
@@ -307,6 +308,22 @@ bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, uint1
   return ret;
 }
 
+bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, uint8_t& value) {
+  lua_pushstring(lua, key.c_str()); 
+  lua_gettable(lua, -2);  
+
+  bool ret = false;
+  
+  if(!lua_isnil(lua, -1)) {
+    value = (uint8_t)lua_tonumber(lua, -1);
+    ret = true;
+  }
+  
+  lua_pop(lua, 1);
+  
+  return ret;
+}
+
 bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, int& value) {
   lua_pushstring(lua, key.c_str());
   lua_gettable(lua, -2);
index 0a90553e3cde40a99e272a24c0681d19d04bc759..1b2a3804512b1e2edcbaa46f19da709073f80c5b 100644 (file)
@@ -160,6 +160,7 @@ private:
 #endif
     bool getValueFromTable(lua_State *lua, const std::string& key, uint32_t& value);
     bool getValueFromTable(lua_State *lua, const std::string& key, uint16_t& value);
+    bool getValueFromTable(lua_State *lua, const std::string& key, uint8_t& value);
     bool getValueFromTable(lua_State *lua, const std::string& key, int& value);
     bool getValueFromTable(lua_State *lua, const std::string& key, bool& value);
 
index a2a1abb5111c4214a87676e12724d1f4735cb86a..ec0991377660f8add02a51f80f1b0f3d74ec8053 100644 (file)
@@ -157,6 +157,7 @@ bool LUABackend::get(DNSResourceRecord &rr) {
         rr.ttl = ::arg().asNum( "default-ttl" );
 
     getValueFromTable(lua, "content", rr.content);
+    getValueFromTable(lua, "scopeMask", rr.scopeMask);
 
     lua_pop(lua, 1 );