d_zones.resize(zone+1);
}
+void DNSFilterEngine::clear(int zone)
+{
+ assureZones(zone);
+ auto& z = d_zones[zone];
+ z.qpolAddr.clear();
+ z.postpolAddr.clear();
+ z.propolName.clear();
+ z.qpolName.clear();
+}
+
void DNSFilterEngine::addClientTrigger(const Netmask& nm, Policy pol, int zone)
{
assureZones(zone);
#include "dnsrecords.hh"
#include "dnssecinfra.hh"
-vector<pair<vector<DNSRecord>, vector<DNSRecord> > > getIXFRDeltas(const ComboAddress& master, const DNSName& zone, const DNSRecord& oursr, const TSIGTriplet& tt)
+
+// if you the remove,add pairs always remove a SOA and add a new one. If you get an empty remove, it means you got an AXFR!
+vector<pair<vector<DNSRecord>, vector<DNSRecord> > > getIXFRDeltas(const ComboAddress& master, const DNSName& zone, const DNSRecord& oursr, const TSIGTriplet& tt)
{
vector<pair<vector<DNSRecord>, vector<DNSRecord> > > ret;
vector<uint8_t> packet;
done:;
for(unsigned int pos = 1;pos < records.size();) {
auto sr = std::dynamic_pointer_cast<SOARecordContent>(records[pos].d_content);
+ vector<DNSRecord> remove, add;
+ if(!sr) { // this is an actual AXFR!
+ return {{remove, records}};
+ }
if(sr->d_st.serial == masterSOA->d_st.serial)
break;
- vector<DNSRecord> remove, add;
+
remove.push_back(records[pos]); // this adds the SOA
for(pos++; pos < records.size() && records[pos].d_type != QType::SOA; ++pos) {
remove.push_back(records[pos]);
cout<<"Got "<<deltas.size()<<" deltas, applying.."<<endl;
for(const auto& delta : deltas) {
+
const auto& remove = delta.first;
const auto& add = delta.second;
newserial=std::dynamic_pointer_cast<SOARecordContent>(rr.d_content)->d_st.serial;
}
}
+
cout<<"This delta ("<<ourSerial<<" - "<<newserial<<") has "<<remove.size()<<" removals, "<<add.size()<<" additions"<<endl;
+ ofstream report(directory +"/delta."+std::to_string(ourSerial)+"-"+std::to_string(newserial));
+ if(remove.empty()) {
+ cout<<"This delta is a whole new zone"<<endl;
+ report<<"- everything, whole new zone update follow"<<endl;
+ records.clear();
+ }
+
bool stop=false;
- ofstream report(directory +"/delta."+std::to_string(ourSerial)+"-"+std::to_string(newserial));
+
for(const auto& rr : remove) {
report<<'-'<< (rr.d_name+zone) <<" IN "<<DNSRecordContent::NumberToType(rr.d_type)<<" "<<rr.d_content->getZoneRepresentation()<<endl;
auto range = records.equal_range(tie(rr.d_name, rr.d_type, rr.d_class, rr.d_content));
report.flush();
}
records.erase(range.first, range.second);
-
}
for(const auto& rr : add) {
for(const auto& delta : deltas) {
const auto& remove = delta.first;
const auto& add = delta.second;
-
+ if(remove.empty()) {
+ L<<Logger::Warning<<"IXFR update is a whole new zone"<<endl;
+ luaconfsCopy.dfe.clear(0);
+ }
for(const auto& rr : remove) { // should always contain the SOA
totremove++;
if(rr.d_type == QType::SOA) {