]> granicus.if.org Git - pdns/commitdiff
implement Lua gettag() which optionally tells you which part of the packet cache...
authorbert hubert <bert.hubert@netherlabs.nl>
Wed, 20 Jan 2016 14:50:42 +0000 (15:50 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Wed, 20 Jan 2016 20:51:37 +0000 (21:51 +0100)
pdns/lua-recursor4.cc
pdns/lua-recursor4.hh

index b701cf4ba2aea063afa4b01be7460810ed969c19..745b57b2183ecaf486fa52f75115690444b44554 100644 (file)
@@ -44,6 +44,11 @@ bool RecursorLua4::ipfilter(const ComboAddress& remote, const ComboAddress& loca
   return false;
 }
 
+int RecursorLua4::gettag(const ComboAddress& remote, const ComboAddress& local, const DNSName& qname, uint16_t qtype)
+{
+  return 0;
+}
+
 
 #else
 #undef L
@@ -321,7 +326,7 @@ RecursorLua4::RecursorLua4(const std::string& fname)
   d_preoutquery = d_lw->readVariable<boost::optional<luacall_t>>("preoutquery").get_value_or(0);
 
   d_ipfilter = d_lw->readVariable<boost::optional<ipfilter_t>>("ipfilter").get_value_or(0);
-
+  d_gettag = d_lw->readVariable<boost::optional<gettag_t>>("gettag").get_value_or(0);
 }
 
 bool RecursorLua4::preresolve(const ComboAddress& remote,const ComboAddress& local, const DNSName& query, const QType& qtype, vector<DNSRecord>& res, int& ret, bool* variable)
@@ -356,6 +361,13 @@ bool RecursorLua4::ipfilter(const ComboAddress& remote, const ComboAddress& loca
   return false; // don't block
 }
 
+int RecursorLua4::gettag(const ComboAddress& remote, const ComboAddress& local, const DNSName& qname, uint16_t qtype)
+{
+  if(d_gettag)
+    return d_gettag(remote, local, qname, qtype);
+  return 0;
+}
+
 bool RecursorLua4::genhook(luacall_t& func, const ComboAddress& remote,const ComboAddress& local, const DNSName& query, const QType& qtype, vector<DNSRecord>& res, int& ret, bool* variable)
 {
   if(!func)
index ee8b56c632286ffbf1c095eea7a2afc08af57b77..c62768cd2df79d2c76fac48ab0100280af1dc8b0 100644 (file)
@@ -19,6 +19,11 @@ public:
   bool preoutquery(const ComboAddress& ns, const ComboAddress& requestor, const DNSName& query, const QType& qtype, vector<DNSRecord>& res, int& ret);
   bool ipfilter(const ComboAddress& remote, const ComboAddress& local, const struct dnsheader&);
 
+  int gettag(const ComboAddress& remote, const ComboAddress& local, const DNSName& query, uint16_t qtype);
+
+  typedef std::function<int(ComboAddress,ComboAddress, DNSName, uint16_t)> gettag_t;
+  gettag_t d_gettag; // public so you can query if we have this hooked
+
 private:
   struct DNSQuestion
   {