]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
reinstate shuffling in the new DNSZoneRecord world 4467/head
authorbert hubert <bert.hubert@powerdns.com>
Tue, 13 Sep 2016 13:56:44 +0000 (15:56 +0200)
committerbert hubert <bert.hubert@powerdns.com>
Tue, 13 Sep 2016 13:56:44 +0000 (15:56 +0200)
pdns/dnspacket.cc
pdns/misc.cc
pdns/misc.hh
pdns/speedtest.cc

index 36dae058f13e885bc20e0f10982543c67ca60932..b61ef798f925880567ed255f850f77ac612fa851 100644 (file)
@@ -256,10 +256,6 @@ bool DNSPacket::isEmpty()
   return (d_rrs.empty());
 }
 
-static void shuffle(vector<DNSZoneRecord>& rrs)
-{
-}
-
 /** Must be called before attempting to access getData(). This function stuffs all resource
  *  records found in rrs into the data buffer. It also frees resource records queued for us.
  */
index 435434cccabc392a405f2400e42b88cfad9f42de..038500276cc0286ddc1f9f37a8ffb84f4f17811c 100644 (file)
@@ -533,25 +533,25 @@ string makeHexDump(const string& str)
 }
 
 // shuffle, maintaining some semblance of order
-void shuffle(vector<DNSResourceRecord>& rrs)
+void shuffle(vector<DNSZoneRecord>& rrs)
 {
-  vector<DNSResourceRecord>::iterator first, second;
+  vector<DNSZoneRecord>::iterator first, second;
   for(first=rrs.begin();first!=rrs.end();++first)
-    if(first->d_place==DNSResourceRecord::ANSWER && first->qtype.getCode() != QType::CNAME) // CNAME must come first
+    if(first->dr.d_place==DNSResourceRecord::ANSWER && first->dr.d_type != QType::CNAME) // CNAME must come first
       break;
   for(second=first;second!=rrs.end();++second)
-    if(second->d_place!=DNSResourceRecord::ANSWER)
+    if(second->dr.d_place!=DNSResourceRecord::ANSWER)
       break;
 
-  if(second-first>1)
+  if(second-first > 1)
     random_shuffle(first,second);
 
   // now shuffle the additional records
   for(first=second;first!=rrs.end();++first)
-    if(first->d_place==DNSResourceRecord::ADDITIONAL && first->qtype.getCode() != QType::CNAME) // CNAME must come first
+    if(first->dr.d_place==DNSResourceRecord::ADDITIONAL && first->dr.d_type != QType::CNAME) // CNAME must come first
       break;
   for(second=first;second!=rrs.end();++second)
-    if(second->d_place!=DNSResourceRecord::ADDITIONAL)
+    if(second->dr.d_place!=DNSResourceRecord::ADDITIONAL)
       break;
 
   if(second-first>1)
index 5cb60a2705f20f7f7529a5aadec2ee10b70e5e85..225d8e981404ce6a798eb4f05e6193524ae0fab9 100644 (file)
@@ -33,6 +33,7 @@
 #include <boost/tuple/tuple_comparison.hpp>
 #include <boost/multi_index/key_extractors.hpp>
 #include <boost/multi_index/sequenced_index.hpp>
+
 using namespace ::boost::multi_index;
 
 #include "dns.hh"
@@ -305,7 +306,8 @@ inline void unixDie(const string &why)
 
 string makeHexDump(const string& str);
 void shuffle(vector<DNSRecord>& rrs);
-void shuffle(vector<DNSResourceRecord>& rrs);
+class DNSZoneRecord;
+void shuffle(vector<DNSZoneRecord>& rrs);
 
 void orderAndShuffle(vector<DNSRecord>& rrs);
 
index 465f2c30246d40a5b8fe0ee3b0562bffca7c797f..d42872156046ed031bc7a5266183e1d93c5370d1 100644 (file)
@@ -295,7 +295,7 @@ vector<uint8_t> makeBigDNSPacketReferral()
 
   vector<uint8_t> packet;
   DNSPacketWriter pw(packet, DNSName("www.google.com"), QType::A);
-  shuffle(records);
+  //  shuffle(records);
   for(const auto& rec : records) {
     pw.startRecord(rec.qname, rec.qtype.getCode(), rec.ttl, 1, rec.d_place);
     auto drc = DNSRecordContent::mastermake(rec.qtype.getCode(), 1, rec.content);