From: bert hubert Date: Thu, 22 Oct 2015 14:14:54 +0000 (+0200) Subject: interim X-Git-Tag: dnsdist-1.0.0-alpha1~252^2~6^2~19^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=afae4a71733c2b5333f2b54acace6ffeef64dd4b;p=pdns interim --- diff --git a/pdns/ixplore.cc b/pdns/ixplore.cc index f4f6cafc7..c4fea2c76 100644 --- a/pdns/ixplore.cc +++ b/pdns/ixplore.cc @@ -17,6 +17,103 @@ StatBag S; +uint32_t getSerial(const ComboAddress& master, const DNSName& zone, shared_ptr& sr) +{ + vector packet; + DNSPacketWriter pw(packet, zone, QType::SOA); + + Socket s(master.sin4.sin_family, SOCK_DGRAM); + s.connect(master); + string msg((const char*)&packet[0], packet.size()); + s.writen(msg); + + string reply; + s.read(reply); + MOADNSParser mdp(reply); + for(const auto& r: mdp.d_answers) { + if(r.first.d_type == QType::SOA) { + sr = std::dynamic_pointer_cast(r.first.d_content); + cout<<"Current serial number: "<d_st.serial<d_st.serial; + } + } + return 0; +} + +vector, vector > > > getIXFRDeltas(const ComboAddress& master, const DNSName& zone, shared_ptr sr) +{ + vector, vector > > > ret; + vector packet; + DNSPacketWriter pw(packet, zone, QType::IXFR); + pw.getHeader()->qr=0; + pw.getHeader()->rd=0; + pw.startRecord(zone, QType::SOA, 3600, QClass::IN, DNSPacketWriter::AUTHORITY); + sr->toPacket(pw); + pw.commit(); + + + uint16_t len=htons(packet.size()); + string msg((const char*)&len, 2); + msg.append((const char*)&packet[0], packet.size()); + + Socket s(master.sin4.sin_family, SOCK_STREAM); + s.connect(master); + s.writen(msg); + + // CURRENT MASTER SOA + // REPEAT: + // SOA WHERE THIS DELTA STARTS + // RECORDS TO REMOVE + // SOA WHERE THIS DELTA GOES + // RECORDS TO ADD + // CURRENT MASTER SOA + shared_ptr masterSOA; + vector records; + for(;;) { + if(s.read((char*)&len, 2)!=2) + break; + len=ntohs(len); + cout<<"Got chunk of "<(r.first.d_content); + if(!masterSOA) { + masterSOA=sr; + } + else if(sr->d_st.serial == masterSOA->d_st.serial) + goto done; + + } + } + } + done:; + for(int pos = 1;pos < records.size();) { + auto sr = std::dynamic_pointer_cast(records[pos].d_content); + if(sr->d_st.serial == masterSOA->d_st.serial) + break; + + cout<<"Got delta going from "<d_st.serial<getZoneRepresentation()<(records[pos].d_content); + cout<<"This delta goes to "<d_st.serial<getZoneRepresentation()< packet; - DNSPacketWriter pw(packet, zone, QType::SOA); + ComboAddress master(argv[1], atoi(argv[2])); - Socket s(master.sin4.sin_family, SOCK_DGRAM); - s.connect(master); - string msg((const char*)&packet[0], packet.size()); - s.writen(msg); + shared_ptr sr; + uint32_t serial = getSerial(master, zone, sr); + sr->d_st.serial=1445514388; - string reply; - s.read(reply); - MOADNSParser mdp(reply); - for(const auto& r: mdp.d_answers) { - if(r.first.d_type == QType::SOA) { - auto sr = std::dynamic_pointer_cast(r.first.d_content); - cout<<"Current serial number: "<d_st.serial<