]> granicus.if.org Git - pdns/commitdiff
this commit DISABLES LABEL COMPRESSION. tinydns works, few test failures, mostly...
authorPeter van Dijk <peter.van.dijk@netherlabs.nl>
Mon, 1 Jun 2015 14:27:10 +0000 (16:27 +0200)
committermind04 <mind04@monshouwer.org>
Tue, 30 Jun 2015 06:12:43 +0000 (08:12 +0200)
modules/tinydnsbackend/tinydnsbackend.cc
pdns/dnslabeltext.rl
pdns/dnspacket.cc
pdns/dnswriter.cc
pdns/dnswriter.hh
pdns/packethandler.cc

index 642e1a24048e843c96cf35a8851fad75be209437..6837437a1c9184c0966239aa4d929a1dc091044f 100644 (file)
@@ -157,7 +157,7 @@ void TinyDNSBackend::getAllDomains(vector<DomainInfo> *domains, bool include_dis
 
 bool TinyDNSBackend::list(const DNSName &target, int domain_id, bool include_disabled) {
        d_isAxfr=true;
-       string key = simpleCompress(target.toString()); // FIXME bug: no lowercase here? or do we promise lowercase from core now?
+       string key = target.toDNSString(); // FIXME bug: no lowercase here? or promise that from core?
        d_cdbReader=new CDB(getArg("dbfile"));
        return d_cdbReader->searchSuffix(key);
 }
@@ -252,8 +252,8 @@ bool TinyDNSBackend::get(DNSResourceRecord &rr)
                                key.insert(0, 1, '\052');
                                key.insert(0, 1, '\001');
                        }
-                       rr.qname.clear(); 
-                       rr.qname=key;
+                       // rr.qname.clear(); 
+                       rr.qname=DNSName(key.c_str(), key.size(), 0, false);
                        rr.domain_id=-1;
                        // 11:13.21 <@ahu> IT IS ALWAYS AUTH --- well not really because we are just a backend :-)
                        // We could actually do NSEC3-NARROW DNSSEC according to Habbie, if we do, we need to change something ehre. 
@@ -282,7 +282,7 @@ bool TinyDNSBackend::get(DNSResourceRecord &rr)
 
                                DNSRecordContent *drc = DNSRecordContent::mastermake(dr, pr);
                                rr.content = drc->getZoneRepresentation();
-                               // cerr<<"CONTENT: "<<rr.content<<endl;
+                               cerr<<"CONTENT: "<<rr.content<<endl;
                                delete drc;
                        }
                        catch (...) {
index ce3f0ecc7fc6cdae107541e3e1be190ef9d3d5f9..2f628376fd102d1aeff8845c8a11b9726974f20d 100644 (file)
@@ -19,7 +19,7 @@ void appendSplit(vector<string>& ret, string& segment, char c)
 
 vector<string> segmentDNSText(const string& input )
 {
-  cerr<<"segmentDNSText("<<input<<")"<<endl; 
+  // cerr<<"segmentDNSText("<<input<<")"<<endl; 
 %%{
         machine dnstext;
         write data;
@@ -83,7 +83,7 @@ vector<string> segmentDNSText(const string& input )
 
 deque<string> segmentDNSName(const string& input )
 {
-  cerr<<"segmentDNSName("<<input<<")"<<endl; 
+  // cerr<<"segmentDNSName("<<input<<")"<<endl; 
 %%{
         machine dnsname;
         write data;
index 39edec33c449f23207919b46ea30505203ddf36d..6ba951c8ead853d030d8b315cb62d34c26e20961 100644 (file)
@@ -167,12 +167,13 @@ void DNSPacket::addRecord(const DNSResourceRecord &rr)
 {
   // this removes duplicates from the packet in case we are not compressing
   // for AXFR, no such checking is performed!
+  cerr<<"addrecord, content=["<<rr.content<<"]"<<endl;
   if(d_compress)
     for(vector<DNSResourceRecord>::const_iterator i=d_rrs.begin();i!=d_rrs.end();++i) 
       if(rr.qname==i->qname && rr.qtype==i->qtype && rr.content==i->content) {
           return;
       }
-
+  cerr<<"added to d_rrs"<<endl;
   d_rrs.push_back(rr);
 }
 
@@ -302,6 +303,7 @@ void DNSPacket::wrapup()
     try {
       uint8_t maxScopeMask=0;
       for(pos=d_rrs.begin(); pos < d_rrs.end(); ++pos) {
+        cerr<<"during wrapup, content=["<<pos->content<<"]"<<endl;
         maxScopeMask = max(maxScopeMask, pos->scopeMask);
 
         if(!pos->content.empty() && pos->qtype.getCode()==QType::TXT && pos->content[0]!='"') {
index eef1c993c5f39a9fdc1c224274c99227b6efcfdc..13f4c56e27ea6ff0857a63a5391ff2fd0a8050e4 100644 (file)
@@ -200,8 +200,10 @@ void DNSPacketWriter::xfrName(const DNSName& name, bool compress)
 {
   // string label = d_lowerCase ? toLower(Label) : Label;
   // FIXME: we ignore d_lowerCase for now
+  cerr<<"xfrName writing ["<<name.toString()<<"]"<<endl;
   std::vector<std::string> parts = name.getRawLabels();
   // labelparts_t parts;
+  cerr<<"labelcount: "<<parts.size()<<endl;
 
   if(d_canonic)
     compress=false;
@@ -221,6 +223,7 @@ void DNSPacketWriter::xfrName(const DNSName& name, bool compress)
   unsigned int startPos;
 
   for(auto &label: parts) {
+    cerr<<"xfrName labelpart ["<<label<<"]"<<endl;
     // if(deDot)
     //   chopped.assign(label.c_str() + i->first, labellen - i->first -1);
     // else
@@ -229,16 +232,17 @@ void DNSPacketWriter::xfrName(const DNSName& name, bool compress)
     lmap_t::iterator li=d_labelmap.end();
     // see if we've written out this domain before
     // cerr<<"Searching for compression pointer to '"<<chopped<<"', "<<d_labelmap.size()<<" cmp-records"<<endl;
-    if(compress && (li=find(d_labelmap, label))!=d_labelmap.end()) {
-      // cerr<<"\tFound a compression pointer to '"<<chopped<<"': "<<li->second<<endl;
-      if (d_record.size() - startRecordSize + label.size() > 253) // chopped does not include a length octet for the first label and the root label
-        throw MOADNSException("DNSPacketWriter::xfrName() found overly large (compressed) name");
-      uint16_t offset=li->second;
-      offset|=0xc000;
-      d_record.push_back((char)(offset >> 8));
-      d_record.push_back((char)(offset & 0xff));
-      goto out;                                 // skip trailing 0 in case of compression
-    }
+    // if(compress && (li=find(d_labelmap, label))!=d_labelmap.end()) {
+    //   cerr<<"doing compression, my label=["<<label<<"] found match ["<<li->first<<"]"<<endl;
+    //   // cerr<<"\tFound a compression pointer to '"<<chopped<<"': "<<li->second<<endl;
+    //   if (d_record.size() - startRecordSize + label.size() > 253) // chopped does not include a length octet for the first label and the root label
+    //     throw MOADNSException("DNSPacketWriter::xfrName() found overly large (compressed) name");
+    //   uint16_t offset=li->second;
+    //   offset|=0xc000;
+    //   d_record.push_back((char)(offset >> 8));
+    //   d_record.push_back((char)(offset & 0xff));
+    //   goto out;                                 // skip trailing 0 in case of compression
+    // }
 
     if(li==d_labelmap.end() && pos< 16384) {
       //      cerr<<"\tStoring a compression pointer to '"<<chopped<<"': "<<pos<<endl;
@@ -263,6 +267,7 @@ void DNSPacketWriter::xfrName(const DNSName& name, bool compress)
     // }
     // else {
       char labelsize=label.size();
+      cerr<<"labelsize = "<<int(labelsize)<<" for label ["<<label<<"]"<<endl;
       d_record.push_back(labelsize);
       unsigned int len=d_record.size();
       d_record.resize(len + labelsize);
index 7b092194ea051e4804185cbb559bab9842abd245..e7dbc9a1b054c64093f430d3560e601d8d665f05 100644 (file)
@@ -46,7 +46,7 @@ public:
   
   /** Start a new DNS record within this packet for namq, qtype, ttl, class and in the requested place. Note that packets can only be written in natural order - 
       ANSWER, AUTHORITY, ADDITIONAL */
-  void startRecord(const DNSName& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=QClass::IN, Place place=ANSWER, bool compress=true);
+  void startRecord(const DNSName& name, uint16_t qtype, uint32_t ttl=3600, uint16_t qclass=QClass::IN, Place place=ANSWER, bool compress=false);
 
   /** Shorthand way to add an Opt-record, for example for EDNS0 purposes */
   typedef vector<pair<uint16_t,std::string> > optvect_t;
index 549f4f026ec790b14a1e97325013182629d50238..09781f1702456cc1bbd2fef21b061dc16cba0d7c 100644 (file)
@@ -1245,6 +1245,7 @@ DNSPacket *PacketHandler::questionOrRecurse(DNSPacket *p, bool *shouldRecurse)
     weDone = weRedirected = weHaveUnauth =  false;
     
     while(B.get(rr)) {
+      cerr<<"got content: ["<<rr.content<<"]"<<endl;
       if (p->qtype.getCode() == QType::ANY && !p->d_dnssecOk && (rr.qtype.getCode() == QType:: DNSKEY || rr.qtype.getCode() == QType::NSEC3PARAM))
         continue; // Don't send dnssec info to non validating resolvers.
       if (rr.qtype.getCode() == QType::RRSIG) // RRSIGS are added later any way.