]> git.ipfire.org Git - thirdparty/pdns.git/blobdiff - pdns/lua-auth4.cc
auth: switch circleci mssql image
[thirdparty/pdns.git] / pdns / lua-auth4.cc
index db9bb0ab37ba48fd9ae07370abc66a5c031a1fa4..dae104b14032b784aa4c6f6782cf235bccbf7312 100644 (file)
@@ -1,3 +1,7 @@
+#include "config.h"
+#if defined(HAVE_LUA)
+#include "ext/luawrapper/include/LuaContext.hpp"
+#endif
 #include "lua-auth4.hh"
 #include "stubresolver.hh"
 #include <fstream>
@@ -6,6 +10,11 @@
 #include "namespaces.hh"
 #include "ednssubnet.hh"
 #include <unordered_set>
+#include "sstuff.hh"
+#include <thread>
+#include <mutex>
+
+#include "ueberbackend.hh"
 
 AuthLua4::AuthLua4() { prepareContext(); }
 
@@ -13,6 +22,7 @@ AuthLua4::AuthLua4() { prepareContext(); }
 
 bool AuthLua4::updatePolicy(const DNSName &qname, QType qtype, const DNSName &zonename, DNSPacket *packet) { return false; }
 bool AuthLua4::axfrfilter(const ComboAddress& remote, const DNSName& zone, const DNSResourceRecord& in, vector<DNSResourceRecord>& out) { return false; }
+LuaContext* AuthLua4::getLua() { return 0; }
 DNSPacket *AuthLua4::prequery(DNSPacket *q) { return NULL; }
 
 AuthLua4::~AuthLua4() { }
@@ -27,12 +37,12 @@ void AuthLua4::postLoad()
 
 #else
 
-#undef L
-#include "ext/luawrapper/include/LuaContext.hpp"
+LuaContext* AuthLua4::getLua()
+{
+  return d_lw.get();
+}
 
 void AuthLua4::postPrepareContext() {
-  stubParseResolveConf();
-
   d_lw->writeFunction("resolve", [](const std::string& qname, uint16_t qtype) {
       std::vector<DNSZoneRecord> ret;
       std::unordered_map<int, DNSResourceRecord> luaResult;
@@ -102,7 +112,6 @@ void AuthLua4::postLoad() {
   d_update_policy = d_lw->readVariable<boost::optional<luacall_update_policy_t>>("updatepolicy").get_value_or(0);
   d_axfr_filter = d_lw->readVariable<boost::optional<luacall_axfr_filter_t>>("axfrfilter").get_value_or(0);
   d_prequery = d_lw->readVariable<boost::optional<luacall_prequery_t>>("prequery").get_value_or(0);
-
 }
 
 bool AuthLua4::axfrfilter(const ComboAddress& remote, const DNSName& zone, const DNSResourceRecord& in, vector<DNSResourceRecord>& out) {
@@ -113,10 +122,17 @@ bool AuthLua4::axfrfilter(const ComboAddress& remote, const DNSName& zone, const
 
   ret = d_axfr_filter(remote, zone, in);
   rcode = std::get<0>(ret);
-  if (rcode < 0)
+  if (rcode < 0) {
+    // no modification, handle normally
     return false;
-  else if (rcode == 1)
+  }
+  else if (rcode == 0) {
+    // replace the matching record by the filtered record(s)
+  }
+  else if (rcode == 1) {
+    // append the filtered record(s) after the matching record
     out.push_back(in);
+  }
   else
     throw PDNSException("Cannot understand return code "+std::to_string(rcode)+" in axfr filter response");
 
@@ -172,4 +188,5 @@ DNSPacket *AuthLua4::prequery(DNSPacket *q) {
 
 AuthLua4::~AuthLua4() { }
 
+
 #endif