From 4a51ff7291bd93c81bca6c70e46e0fca434b63a8 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Thu, 14 May 2015 10:07:53 +0200 Subject: [PATCH] snap --- pdns/dnspacket.cc | 2 +- pdns/dnsparser.hh | 2 +- pdns/dnsrecords.cc | 6 +++--- pdns/dnsrecords.hh | 5 +++-- pdns/dnswriter.cc | 2 +- pdns/dnswriter.hh | 3 ++- pdns/rcpgenerator.cc | 33 +++++++++++++++++++-------------- pdns/rcpgenerator.hh | 5 +++-- pdns/resolver.cc | 2 +- pdns/tcpreceiver.cc | 4 ++-- 10 files changed, 36 insertions(+), 28 deletions(-) diff --git a/pdns/dnspacket.cc b/pdns/dnspacket.cc index 73151cee2a..cf91f4a032 100644 --- a/pdns/dnspacket.cc +++ b/pdns/dnspacket.cc @@ -349,7 +349,7 @@ void DNSPacket::wrapup() } } - if(!d_trc.d_algoName.empty()) + if(d_trc.d_algoName.countLabels()) addTSIG(pw, &d_trc, d_tsigkeyname, d_tsigsecret, d_tsigprevious, d_tsigtimersonly); d_rawpacket.assign((char*)&packet[0], packet.size()); diff --git a/pdns/dnsparser.hh b/pdns/dnsparser.hh index 4e57b0810f..ad38a6d3ab 100644 --- a/pdns/dnsparser.hh +++ b/pdns/dnsparser.hh @@ -119,7 +119,7 @@ public: } - void xfrName(string &label, bool compress=false) + void xfrName(DNSName &label, bool compress=false) { label=getName(); } diff --git a/pdns/dnsrecords.cc b/pdns/dnsrecords.cc index 8284a1900e..58ace38c4d 100644 --- a/pdns/dnsrecords.cc +++ b/pdns/dnsrecords.cc @@ -159,7 +159,7 @@ boilerplate_conv(TSIG, QType::TSIG, if (size>0) conv.xfrBlobNoSpaces(d_otherData, size); ); -MXRecordContent::MXRecordContent(uint16_t preference, const string& mxname) : DNSRecordContent(QType::MX), d_preference(preference), d_mxname(mxname) +MXRecordContent::MXRecordContent(uint16_t preference, const DNSName& mxname) : DNSRecordContent(QType::MX), d_preference(preference), d_mxname(mxname) { } @@ -225,7 +225,7 @@ boilerplate_conv(NAPTR, QType::NAPTR, ) -SRVRecordContent::SRVRecordContent(uint16_t preference, uint16_t weight, uint16_t port, const string& target) +SRVRecordContent::SRVRecordContent(uint16_t preference, uint16_t weight, uint16_t port, const DNSName& target) : DNSRecordContent(QType::SRV), d_preference(preference), d_weight(weight), d_port(port), d_target(target) {} @@ -234,7 +234,7 @@ boilerplate_conv(SRV, QType::SRV, conv.xfrName(d_target); ) -SOARecordContent::SOARecordContent(const string& mname, const string& rname, const struct soatimes& st) +SOARecordContent::SOARecordContent(const DNSName& mname, const DNSName& rname, const struct soatimes& st) : DNSRecordContent(QType::SOA), d_mname(mname), d_rname(rname) { d_st=st; diff --git a/pdns/dnsrecords.hh b/pdns/dnsrecords.hh index c5b99531f3..c66445e8f2 100644 --- a/pdns/dnsrecords.hh +++ b/pdns/dnsrecords.hh @@ -46,13 +46,14 @@ class NAPTRRecordContent : public DNSRecordContent { public: - NAPTRRecordContent(uint16_t order, uint16_t preference, string flags, string services, string regexp, string replacement); + NAPTRRecordContent(uint16_t order, uint16_t preference, string flags, string services, string regexp, DNSName replacement); includeboilerplate(NAPTR); template void xfrRecordContent(Convertor& conv); private: uint16_t d_order, d_preference; - string d_flags, d_services, d_regexp, d_replacement; + string d_flags, d_services, d_regexp; + DNSName d_replacement; }; diff --git a/pdns/dnswriter.cc b/pdns/dnswriter.cc index 81efaa14a3..e1a2e56056 100644 --- a/pdns/dnswriter.cc +++ b/pdns/dnswriter.cc @@ -196,7 +196,7 @@ bool labeltokUnescape(labelparts_t& parts, const string& label) } // this is the absolute hottest function in the pdns recursor -void DNSPacketWriter::xfrName(const string& Label, bool compress) +void DNSPacketWriter::xfrName(const DNSName& Label, bool compress) { string label = d_lowerCase ? toLower(Label) : Label; labelparts_t parts; diff --git a/pdns/dnswriter.hh b/pdns/dnswriter.hh index 579a23c768..75726a7dde 100644 --- a/pdns/dnswriter.hh +++ b/pdns/dnswriter.hh @@ -5,6 +5,7 @@ #include #include #include "dns.hh" +#include "dnsname.hh" #include "namespaces.hh" #include /** this class can be used to write DNS packets. It knows about DNS in the sense that it makes @@ -86,7 +87,7 @@ public: void xfr8BitInt(uint8_t val); - void xfrName(const string& label, bool compress=false); + void xfrName(const DNSName& label, bool compress=false); void xfrText(const string& text, bool multi=false); void xfrBlob(const string& blob, int len=-1); void xfrBlobNoSpaces(const string& blob, int len=-1); diff --git a/pdns/rcpgenerator.cc b/pdns/rcpgenerator.cc index 447d2d0448..8d6f6448b1 100644 --- a/pdns/rcpgenerator.cc +++ b/pdns/rcpgenerator.cc @@ -78,10 +78,14 @@ void RecordTextReader::xfrTime(uint32_t &val) struct tm tm; memset(&tm, 0, sizeof(tm)); - string tmp; - xfrName(tmp); // ends on number, so this works + uint64_t itmp; + xfr64BitInt(itmp); // ends on number, so this works + + ostringstream tmp; + + tmp< #include "namespaces.hh" +#include "dnsname.hh" class RecordTextException : public runtime_error { @@ -51,7 +52,7 @@ public: void xfrIP6(std::string& val); void xfrTime(uint32_t& val); - void xfrName(string& val, bool compress=false); + void xfrName(DNSName& val, bool compress=false); void xfrText(string& val, bool multi=false); void xfrHexBlob(string& val, bool keepReading=false); void xfrBase32HexBlob(string& val); @@ -82,7 +83,7 @@ public: void xfrBase32HexBlob(const string& val); void xfrType(const uint16_t& val); - void xfrName(const string& val, bool compress=false); + void xfrName(const DNSName& val, bool compress=false); void xfrText(const string& val, bool multi=false); void xfrBlobNoSpaces(const string& val, int len=-1); void xfrBlob(const string& val, int len=-1); diff --git a/pdns/resolver.cc b/pdns/resolver.cc index 6f8778d171..74b2e02b8a 100644 --- a/pdns/resolver.cc +++ b/pdns/resolver.cc @@ -502,7 +502,7 @@ int AXFRRetriever::getChunk(Resolver::res_t &res) // Implementation is making su TSIGHashEnum algo; if (!getTSIGHashEnum(d_trc.d_algoName, algo)) { - throw ResolverException("Unsupported TSIG HMAC algorithm " + d_trc.d_algoName); + throw ResolverException("Unsupported TSIG HMAC algorithm " + d_trc.d_algoName.toString()); } if (algo == TSIG_GSS) { diff --git a/pdns/tcpreceiver.cc b/pdns/tcpreceiver.cc index 31ce721cd6..e3bf7ad000 100644 --- a/pdns/tcpreceiver.cc +++ b/pdns/tcpreceiver.cc @@ -625,7 +625,7 @@ int TCPNameserver::doAXFR(const string &target, shared_ptr q, int out if(!tsigkeyname.empty()) { string tsig64; - string algorithm=toLowerCanonic(trc.d_algoName); + string algorithm=trc.d_algoName.toString(); // FIXME: check if (algorithm == "hmac-md5.sig-alg.reg.int") algorithm = "hmac-md5"; if (algorithm != "gss-tsig") { @@ -1054,7 +1054,7 @@ int TCPNameserver::doIXFR(shared_ptr q, int outsock) if(!tsigkeyname.empty()) { string tsig64; - string algorithm=toLowerCanonic(trc.d_algoName); + string algorithm=trc.d_algoName.toString(); // FIXME: was toLowerCanonic, compare output if (algorithm == "hmac-md5.sig-alg.reg.int") algorithm = "hmac-md5"; Lock l(&s_plock); -- 2.47.2