From 33ecb315908cd8bc037e622e270e5decc7088cf5 Mon Sep 17 00:00:00 2001 From: Bert Hubert Date: Wed, 1 Aug 2007 19:51:30 +0000 Subject: [PATCH] further work git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@1077 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- pdns/nproxy.cc | 71 +++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 6 deletions(-) diff --git a/pdns/nproxy.cc b/pdns/nproxy.cc index 143dfb9ee..a4a569219 100644 --- a/pdns/nproxy.cc +++ b/pdns/nproxy.cc @@ -25,15 +25,20 @@ int g_pdnssocket; struct NotificationInFlight { ComboAddress source; - time_t sentAt; + time_t resentTime; string domain; + uint16_t origID, resentID; + int origSocket; }; +map g_nifs; + void handleOutsideUDPPacket(int fd, boost::any&) try { char buffer[1500]; struct NotificationInFlight nif; + nif.origSocket = fd; socklen_t socklen=sizeof(nif.source); @@ -46,8 +51,10 @@ try string packet(buffer, res); MOADNSParser mdp(packet); + nif.domain = mdp.d_qname; + nif.origID = mdp.d_header.id; - cerr<<"Packet for: "< outpacket; DNSPacketWriter pw(outpacket, mdp.d_qname, mdp.d_qtype, 1, Opcode::Notify); - pw.getHeader()->id = random(); + + static uint16_t s_idpool; + pw.getHeader()->id = nif.resentID = s_idpool++; + + if(send(g_pdnssocket, &outpacket[0], outpacket.size(), 0) < 0) { + throw runtime_error("Unable to send notify to PowerDNS: "+stringerror()); + } + nif.resentTime=time(0); + g_nifs[nif.resentID] = nif; + +} +catch(exception &e) +{ + cerr<<"Error parsing incoming packet: "< outpacket; + DNSPacketWriter pw(outpacket, mdp.d_qname, mdp.d_qtype, 1, Opcode::Notify); + + static uint16_t s_idpool; + pw.getHeader()->id = nif.resentID = s_idpool++; if(send(g_pdnssocket, &outpacket[0], outpacket.size(), 0) < 0) { throw runtime_error("Unable to send notify to PowerDNS: "+stringerror()); @@ -68,6 +123,8 @@ catch(exception &e) cerr<<"Error parsing incoming packet: "<().c_str()) < 0) throw runtime_error("while chrooting to "+g_vm["chroot"].as()); -- 2.40.0