]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Add test for new APIs and reformat 11074/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 8 Dec 2021 13:00:53 +0000 (14:00 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Wed, 8 Dec 2021 13:14:02 +0000 (14:14 +0100)
pdns/lua-recursor4-ffi.hh
pdns/lua-recursor4.cc
regression-tests.recursor-dnssec/test_Lua.py

index 95c93c0fc7a2a4088897e6de8fb70d786f301dd1..f5785bdf7b5d77cfc3562024acf03bf85257d036 100644 (file)
@@ -128,5 +128,3 @@ extern "C"
   const char* pdns_postresolve_ffi_handle_get_authip(pdns_postresolve_ffi_handle_t* ref) __attribute__((visibility("default")));
   void pdns_postresolve_ffi_handle_get_authip_raw(pdns_postresolve_ffi_handle_t* ref, const void** addr, size_t* addrSize) __attribute__((visibility("default")));
 }
-
-#undef PDNS_VISIBILITY
index 0d1a745df80ff49eeabccc210b2709880bcaa75e..b0731d4822e530f94e5cb365ad584ee2c23c1a9a 100644 (file)
@@ -1113,7 +1113,8 @@ bool pdns_postresolve_ffi_handle_get_record(pdns_postresolve_ffi_handle_t* ref,
       const auto& storage = r.d_name.getStorage();
       record->name = storage.data();
       record->name_len = storage.size();
-    } else {
+    }
+    else {
       std::string name = r.d_name.toStringNoDot();
       record->name_len = name.size();
       record->name = ref->insert(std::move(name))->c_str();
index 13081f051bd00c110ddb7890a085606d32a5eb2b..a0fb67a87dec3c941040715e436b5f1a79413b18 100644 (file)
@@ -832,13 +832,22 @@ function postresolve_ffi(ref)
   if qname  == "example" and qtype == pdns.SOA
   then
      local addr = ffi.string(ffi.C.pdns_postresolve_ffi_handle_get_authip(ref))
-     pdnslog("XXXX "..addr)
      if string.sub(addr, -3) ~= ".10" and string.sub(addr, -3) ~= ".18"
      then
        -- signal error by clearing all
        ffi.C.pdns_postresolve_ffi_handle_clear_records(ref)
      end
-     -- as a bonug check from which auth the data came
+     local qaddr = ffi.new("const char *[1]")
+     local qlen = ffi.new("size_t [1]")
+     ffi.C.pdns_postresolve_ffi_handle_get_qname_raw(ref, qaddr, qlen)
+     local q = ffi.string(qaddr[0], qlen[0])
+     if tohex(q) ~= "076578616D706C6500"
+     then
+       -- pdnslog("Error "..tohex(q))
+       -- signal error by clearing all
+       ffi.C.pdns_postresolve_ffi_handle_clear_records(ref)
+     end
+     -- as a bonus check from which auth the data came
      local addr = ffi.new("const void *[1]")
      local len = ffi.new("size_t [1]")
      ffi.C.pdns_postresolve_ffi_handle_get_authip_raw(ref, addr, len)
@@ -848,7 +857,6 @@ function postresolve_ffi(ref)
        -- signal error by clearing all
        ffi.C.pdns_postresolve_ffi_handle_clear_records(ref)
      end
-
      ffi.C.pdns_postresolve_ffi_handle_set_appliedpolicy_kind(ref, "pdns_policy_kind_noaction")
      return true
   end
@@ -899,6 +907,19 @@ function postresolve_ffi(ref)
      end
      i = i + 1
   end
+  -- loop again using raw
+  i = 0
+  while ffi.C.pdns_postresolve_ffi_handle_get_record(ref, i, record, true)
+  do
+     local content = ffi.string(record.content, record.content_len)
+     local name = ffi.string(record.name, record.name_len)
+     --pdnslog("R  "..tohex(name))
+     if tohex(name) ~= "0F706F73747265736F6C76655F666669076578616D706C6500"
+     then
+       ffi.C.pdns_postresolve_ffi_handle_clear_records(ref)
+     end
+     i = i + 1
+  end
   return true
 end
     """