]> granicus.if.org Git - pdns/commitdiff
dnsdist: Pass the qname as a `DNSName` to `DNSProtoBufMessage::addRR()`
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 31 Jul 2017 09:43:12 +0000 (11:43 +0200)
committerNick Saika <nsaika@globalcyberalliance.org>
Wed, 2 Aug 2017 15:40:56 +0000 (11:40 -0400)
It's OK for the Lua binding to accept a string, but the internal functions
should really use a `DNSName`.

pdns/dnsdist-lua2.cc
pdns/protobuf.cc
pdns/protobuf.hh

index 0c7639205eea1f1ca038de83ee2a24a08aab6b3f..9bdc77b83ff706f7f2f208511d8aa7ce3882cc5d 100644 (file)
@@ -833,24 +833,24 @@ void moreLua(bool client)
 
     g_lua.registerFunction<void(DNSDistProtoBufMessage::*)(std::string)>("setTag", [](DNSDistProtoBufMessage& message, const std::string& strValue) {
       message.addTag(strValue);
-     });
+    });
 
     g_lua.registerFunction<void(DNSDistProtoBufMessage::*)(vector<pair<int, string>>)>("setTagArray", [](DNSDistProtoBufMessage& message, const vector<pair<int, string>>&tags) {
       for (const auto& tag : tags) {
         message.addTag(tag.second);
       }
-     });
+    });
 
     g_lua.registerFunction<void(DNSDistProtoBufMessage::*)(boost::optional <time_t> sec, boost::optional <uint32_t> uSec)>("setProtobufResponseType",
                                         [](DNSDistProtoBufMessage& message, boost::optional <time_t> sec, boost::optional <uint32_t> uSec) {
-        message.setType(DNSProtoBufMessage::Response);
-        message.setQueryTime(sec?*sec:0, uSec?*uSec:0);
-     });
+      message.setType(DNSProtoBufMessage::Response);
+      message.setQueryTime(sec?*sec:0, uSec?*uSec:0);
+    });
 
     g_lua.registerFunction<void(DNSDistProtoBufMessage::*)(const std::string& strQueryName, uint16_t uType, uint16_t uClass, uint32_t uTTL, const std::string& strBlob)>("addResponseRR", [](DNSDistProtoBufMessage& message,
                                                             const std::string& strQueryName, uint16_t uType, uint16_t uClass, uint32_t uTTL, const std::string& strBlob) {
-        message.addRR(strQueryName, uType, uClass, uTTL, strBlob);
-     });
+      message.addRR(DNSName(strQueryName), uType, uClass, uTTL, strBlob);
+    });
 
     g_lua.registerFunction<void(DNSDistProtoBufMessage::*)(const Netmask&)>("setEDNSSubnet", [](DNSDistProtoBufMessage& message, const Netmask& subnet) { message.setEDNSSubnet(subnet); });
     g_lua.registerFunction<void(DNSDistProtoBufMessage::*)(const DNSName&, uint16_t, uint16_t)>("setQuestion", [](DNSDistProtoBufMessage& message, const DNSName& qname, uint16_t qtype, uint16_t qclass) { message.setQuestion(qname, qtype, qclass); });
index 6cf8e826a8935c9cd446b90ceb887360537933f5..f3bf4c63d48e9eb0c4e87ad8f013f9d079994e4c 100644 (file)
@@ -110,7 +110,7 @@ void DNSProtoBufMessage::addTag(const std::string& strValue)
 #endif /* HAVE_PROTOBUF */
 }
 
-void DNSProtoBufMessage::addRR(const std::string& strName, uint16_t uType, uint16_t uClass, uint32_t uTTL, const std::string& strBlob)
+void DNSProtoBufMessage::addRR(const DNSName& qname, uint16_t uType, uint16_t uClass, uint32_t uTTL, const std::string& strBlob)
 {
 #ifdef HAVE_PROTOBUF
 
@@ -119,7 +119,7 @@ void DNSProtoBufMessage::addRR(const std::string& strName, uint16_t uType, uint1
     return;
   PBDNSMessage_DNSResponse_DNSRR* rr = response->add_rrs();
   if (rr) {
-    rr->set_name(strName.c_str());
+    rr->set_name(qname.toString());
     rr->set_type(uType);
     rr->set_class_(uClass);
     rr->set_ttl(uTTL);
index 0d32a2f90f33bbe4741de907f8fbf74c58d56282..0783cf9036ffbbf77946bbfd456c5252967fdb45 100644 (file)
@@ -71,7 +71,7 @@ public:
   void setRequestorId(const std::string& requestorId);
   std::string toDebugString() const;
   void addTag(const std::string& strValue);
-  void addRR(const std::string& strName, uint16_t utype, uint16_t uClass, uint32_t uTTl, const std::string& strBlob);
+  void addRR(const DNSName& qame, uint16_t utype, uint16_t uClass, uint32_t uTTl, const std::string& strBlob);
 
 #ifdef HAVE_PROTOBUF
   DNSProtoBufMessage(DNSProtoBufMessage::DNSProtoBufMessageType type, const boost::uuids::uuid& uuid, const ComboAddress* requestor, const ComboAddress* responder, const DNSName& domain, int qtype, uint16_t qclass, uint16_t qid, bool isTCP, size_t bytes);