]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
snap
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Thu, 14 May 2015 08:07:53 +0000 (10:07 +0200)
committermind04 <mind04@monshouwer.org>
Mon, 29 Jun 2015 18:37:11 +0000 (20:37 +0200)
pdns/dnspacket.cc
pdns/dnsparser.hh
pdns/dnsrecords.cc
pdns/dnsrecords.hh
pdns/dnswriter.cc
pdns/dnswriter.hh
pdns/rcpgenerator.cc
pdns/rcpgenerator.hh
pdns/resolver.cc
pdns/tcpreceiver.cc

index 73151cee2a50e1bd62f77517efa47b5445fc03e4..cf91f4a032c41d9503cda1dd1e0434441ef3d619 100644 (file)
@@ -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());
index 4e57b0810f6344ec18d151d43111996dca99196f..ad38a6d3ab63cc42653162d8949561b03489e611 100644 (file)
@@ -119,7 +119,7 @@ public:
   }
 
 
-  void xfrName(string &label, bool compress=false)
+  void xfrName(DNSName &label, bool compress=false)
   {
     label=getName();
   }
index 8284a1900e92dacc63b0df03da17d47915021011..58ace38c4d0780c75584694534de3387c017d8d2 100644 (file)
@@ -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;
index c5b99531f34ae7a1d9972646b57611055d3016ce..c66445e8f21ac429f3449941b027f237a0e161cd 100644 (file)
 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<class Convertor> 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;
 };
 
 
index 81efaa14a32eff3f12730ad226eb856d4026078b..e1a2e56056446c2b2eba7072e2b7f0cb439a2a58 100644 (file)
@@ -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;
index 579a23c7688f0e35a4b41c9fc1eec3c6e412f6e4..75726a7dde52a302c75bdf5b2c17e210933e5aff 100644 (file)
@@ -5,6 +5,7 @@
 #include <vector>
 #include <map>
 #include "dns.hh"
+#include "dnsname.hh"
 #include "namespaces.hh"
 #include <arpa/inet.h>
 /** 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);
index 447d2d04487fe7b8f50c11477d288a0a79d746ba..8d6f6448b1e00d5807eaa53040357776ad446cc7 100644 (file)
@@ -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<<itmp;
 
-  sscanf(tmp.c_str(), "%04d%02d%02d" "%02d%02d%02d", 
+  sscanf(tmp.str().c_str(), "%04d%02d%02d" "%02d%02d%02d", 
          &tm.tm_year, &tm.tm_mon, &tm.tm_mday, 
          &tm.tm_hour, &tm.tm_min, &tm.tm_sec);
 
@@ -184,11 +188,11 @@ void RecordTextReader::xfr8BitInt(uint8_t &val)
 }
 
 // this code should leave all the escapes around 
-void RecordTextReader::xfrName(string& val, bool) 
+void RecordTextReader::xfrName(DNSName& val, bool) 
 {
   skipSpaces();
-  val.clear();
-  val.reserve(d_end - d_pos);
+  string sval;
+  sval.reserve(d_end - d_pos);
 
   const char* strptr=d_string.c_str();
   string::size_type begin_pos = d_pos;
@@ -198,18 +202,19 @@ void RecordTextReader::xfrName(string& val, bool)
       
     d_pos++;
   }
-  val.append(strptr+begin_pos, strptr+d_pos);      
+  sval.append(strptr+begin_pos, strptr+d_pos);      
 
-  if(val.empty())
-    val=d_zone;
+  if(sval.empty())
+    sval=d_zone;
   else if(!d_zone.empty()) {
-    char last=val[val.size()-1];
+    char last=sval[sval.size()-1];
    
     if(last =='.')
-      val.resize(val.size()-1);
+      sval.resize(sval.size()-1);
     else if(last != '.' && !isdigit(last)) // don't add zone to IP address
-      val+="."+d_zone;
+      sval+="."+d_zone;
   }
+  val = DNSName(sval);
 }
 
 static bool isbase64(char c, bool acceptspace)
@@ -498,12 +503,12 @@ void RecordTextWriter::xfr8BitInt(const uint8_t& val)
 }
 
 // should not mess with the escapes
-void RecordTextWriter::xfrName(const string& val, bool)
+void RecordTextWriter::xfrName(const DNSName& val, bool)
 {
   if(!d_string.empty())
     d_string.append(1,' ');
   
-  d_string+=val;
+  d_string+=val.toString();
 }
 
 void RecordTextWriter::xfrBlobNoSpaces(const string& val, int size)
index bd61b061c9f5cc7fd359a4c55ef5837381b5390e..2c14eca6e7808d8e8a7f3beb97f743c272725c8c 100644 (file)
@@ -28,6 +28,7 @@
 #include <stdexcept>
 
 #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);
index 6f8778d17160130edfdd1b71d2fc04ff374e0afd..74b2e02b8a45af922fd82d34e8e1d140cdb84aca 100644 (file)
@@ -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) {
index 31ce721cd6042a459a8bdb77239ff040a1487829..e3bf7ad000fd83c844aec93ba7ec95810bd9a3b7 100644 (file)
@@ -625,7 +625,7 @@ int TCPNameserver::doAXFR(const string &target, shared_ptr<DNSPacket> 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<DNSPacket> 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);