void DNSPacket::clearRecords()
{
d_rrs.clear();
+ d_dedup.clear();
}
void DNSPacket::addRecord(const DNSZoneRecord &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;
+
+ std::string ser;
if(d_compress) {
- for(auto i=d_rrs.begin();i!=d_rrs.end();++i) {
- if(rr.dr == i->dr) // XXX SUPER SLOW
+ ser=const_cast<DNSZoneRecord&>(rr).dr.d_content->serialize(rr.dr.d_name);
+ if(d_dedup.count({rr.dr.d_name, ser})) { // might be a dup
+ for(auto i=d_rrs.begin();i!=d_rrs.end();++i) {
+ if(rr.dr == i->dr) // XXX SUPER SLOW
return;
+ }
}
}
+ if(d_compress)
+ d_dedup.insert({rr.dr.d_name, ser});
- // cerr<<"added to d_rrs"<<endl;
d_rrs.push_back(rr);
}
-
-
vector<DNSZoneRecord*> DNSPacket::getAPRecords()
{
vector<DNSZoneRecord*> arrs;
#include <sys/types.h>
#include "iputils.hh"
#include "ednssubnet.hh"
-
+#include <unordered_set>
#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/time.h>
string d_tsigprevious;
vector<DNSZoneRecord> d_rrs; // 8
+ std::unordered_set<pair<DNSName, std::string>, boost::hash< std::pair<DNSName, std::string> > > d_dedup;
string d_rawpacket; // this is where everything lives 8
EDNSSubnetOpts d_eso;