]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Add a `tcp` parameter to `gettag()` since it's now called for TCP
authorRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 12 Oct 2016 15:57:52 +0000 (17:57 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 5 May 2017 10:28:37 +0000 (12:28 +0200)
docs/markdown/recursor/scripting.md
pdns/lua-recursor4.cc
pdns/lua-recursor4.hh
pdns/pdns_recursor.cc

index ddc2f4cfb708fcfbd099918079d7aceed7af7820..dfd7a5747961686a6c3ea04855474c8c1afadf66 100644 (file)
@@ -153,7 +153,7 @@ end
 This hook does not get the full DNSQuestion object, since filling out the fields
 would require packet parsing, which is what we are trying to prevent with `ipfilter`.
 
-### `function gettag(remote, ednssubnet, local, qname, qtype, ednsoptions)`
+### `function gettag(remote, ednssubnet, local, qname, qtype, ednsoptions, tcp)`
 The `gettag` function is invoked when the Recursor attempts to discover in which
 packetcache an answer is available.
 
@@ -175,6 +175,9 @@ through the entire Lua script.
 and the content accessible as a NULL-safe string object via `getContent()`.
 This table is empty unless the `gettag-needs-edns-options` parameter is set.
 
+The `tcp` value (added in 4.1) is a boolean indicating whether the query was
+received over `UDP` (false) or `TCP` (true).
+
 ### `function prerpz(dq)`
 
 This hook is called before any filtering policy have been applied, making it
index 6445db8c6ecd52575803fdd1508153a7470c9d0e..bb78ae7935282e526eb6f127e54468badcec9172 100644 (file)
@@ -587,10 +587,10 @@ bool RecursorLua4::ipfilter(const ComboAddress& remote, const ComboAddress& loca
   return false; // don't block
 }
 
-unsigned int RecursorLua4::gettag(const ComboAddress& remote, const Netmask& ednssubnet, const ComboAddress& local, const DNSName& qname, uint16_t qtype, std::vector<std::string>* policyTags, LuaContext::LuaObject& data, const std::map<uint16_t, EDNSOptionView>& ednsOptions)
+unsigned int RecursorLua4::gettag(const ComboAddress& remote, const Netmask& ednssubnet, const ComboAddress& local, const DNSName& qname, uint16_t qtype, std::vector<std::string>* policyTags, LuaContext::LuaObject& data, const std::map<uint16_t, EDNSOptionView>& ednsOptions, bool tcp)
 {
   if(d_gettag) {
-    auto ret = d_gettag(remote, ednssubnet, local, qname, qtype, ednsOptions);
+    auto ret = d_gettag(remote, ednssubnet, local, qname, qtype, ednsOptions, tcp);
 
     if (policyTags) {
       const auto& tags = std::get<1>(ret);
index 7305b559d5ee97cdd81dc425b05f6d86a1091d12..227c1d16e4b18d43ba80587cda2b1a4d1478e4d9 100644 (file)
@@ -101,7 +101,7 @@ public:
     DNSName followupName;
   };
 
-  unsigned int gettag(const ComboAddress& remote, const Netmask& ednssubnet, const ComboAddress& local, const DNSName& qname, uint16_t qtype, std::vector<std::string>* policyTags, LuaContext::LuaObject& data, const std::map<uint16_t, EDNSOptionView>&);
+  unsigned int gettag(const ComboAddress& remote, const Netmask& ednssubnet, const ComboAddress& local, const DNSName& qname, uint16_t qtype, std::vector<std::string>* policyTags, LuaContext::LuaObject& data, const std::map<uint16_t, EDNSOptionView>&, bool tcp);
 
   bool prerpz(DNSQuestion& dq, int& ret);
   bool preresolve(DNSQuestion& dq, int& ret);
@@ -121,7 +121,7 @@ public:
             d_postresolve);
   }
 
-  typedef std::function<std::tuple<unsigned int,boost::optional<std::unordered_map<int,string> >,boost::optional<LuaContext::LuaObject> >(ComboAddress, Netmask, ComboAddress, DNSName, uint16_t, const std::map<uint16_t, EDNSOptionView>&)> gettag_t;
+  typedef std::function<std::tuple<unsigned int,boost::optional<std::unordered_map<int,string> >,boost::optional<LuaContext::LuaObject> >(ComboAddress, Netmask, ComboAddress, DNSName, uint16_t, const std::map<uint16_t, EDNSOptionView>&, bool)> gettag_t;
   gettag_t d_gettag; // public so you can query if we have this hooked
 
 private:
index 8db27972925ab477fbb8865ecdbf185a62f92d1f..e6d53b41fffe310571e8e60f3dc49ffa82d32573 100644 (file)
@@ -1432,7 +1432,7 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var)
 
           if(t_pdl->get() && (*t_pdl)->d_gettag) {
             try {
-              dc->d_tag = (*t_pdl)->gettag(conn->d_remote, dc->d_ednssubnet.source, dest, qname, qtype, &dc->d_policyTags, dc->d_data, ednsOptions);
+              dc->d_tag = (*t_pdl)->gettag(conn->d_remote, dc->d_ednssubnet.source, dest, qname, qtype, &dc->d_policyTags, dc->d_data, ednsOptions, true);
             }
             catch(std::exception& e)  {
               if(g_logCommonErrors)
@@ -1605,7 +1605,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr
 
         if(t_pdl->get() && (*t_pdl)->d_gettag) {
           try {
-            ctag=(*t_pdl)->gettag(fromaddr, ednssubnet.source, destaddr, qname, qtype, &policyTags, data, ednsOptions);
+            ctag=(*t_pdl)->gettag(fromaddr, ednssubnet.source, destaddr, qname, qtype, &policyTags, data, ednsOptions, false);
           }
           catch(std::exception& e)  {
             if(g_logCommonErrors)