From: Remi Gacogne Date: Mon, 31 Jul 2017 09:43:12 +0000 (+0200) Subject: dnsdist: Pass the qname as a `DNSName` to `DNSProtoBufMessage::addRR()` X-Git-Tag: dnsdist-1.2.0~39^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff09c374164c740f239b205f6876672c16264171;p=pdns dnsdist: Pass the qname as a `DNSName` to `DNSProtoBufMessage::addRR()` It's OK for the Lua binding to accept a string, but the internal functions should really use a `DNSName`. --- diff --git a/pdns/dnsdist-lua2.cc b/pdns/dnsdist-lua2.cc index 0c7639205..9bdc77b83 100644 --- a/pdns/dnsdist-lua2.cc +++ b/pdns/dnsdist-lua2.cc @@ -833,24 +833,24 @@ void moreLua(bool client) g_lua.registerFunction("setTag", [](DNSDistProtoBufMessage& message, const std::string& strValue) { message.addTag(strValue); - }); + }); g_lua.registerFunction>)>("setTagArray", [](DNSDistProtoBufMessage& message, const vector>&tags) { for (const auto& tag : tags) { message.addTag(tag.second); } - }); + }); g_lua.registerFunction sec, boost::optional uSec)>("setProtobufResponseType", [](DNSDistProtoBufMessage& message, boost::optional sec, boost::optional 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("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("setEDNSSubnet", [](DNSDistProtoBufMessage& message, const Netmask& subnet) { message.setEDNSSubnet(subnet); }); g_lua.registerFunction("setQuestion", [](DNSDistProtoBufMessage& message, const DNSName& qname, uint16_t qtype, uint16_t qclass) { message.setQuestion(qname, qtype, qclass); }); diff --git a/pdns/protobuf.cc b/pdns/protobuf.cc index 6cf8e826a..f3bf4c63d 100644 --- a/pdns/protobuf.cc +++ b/pdns/protobuf.cc @@ -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); diff --git a/pdns/protobuf.hh b/pdns/protobuf.hh index 0d32a2f90..0783cf903 100644 --- a/pdns/protobuf.hh +++ b/pdns/protobuf.hh @@ -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);