+#include "config.h"
+#if defined(HAVE_LUA)
+#include "ext/luawrapper/include/LuaContext.hpp"
+#endif
#include "lua-auth4.hh"
#include "stubresolver.hh"
#include <fstream>
#include "namespaces.hh"
#include "ednssubnet.hh"
#include <unordered_set>
+#include "sstuff.hh"
+#include <thread>
+#include <mutex>
+
+#include "ueberbackend.hh"
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() { }
#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;
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) {
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");
AuthLua4::~AuthLua4() { }
+
#endif