]> granicus.if.org Git - pdns/commitdiff
fix up 0.0.0.0 binding with delayed packets
authorbert hubert <bert.hubert@netherlabs.nl>
Fri, 5 Jun 2015 20:49:14 +0000 (22:49 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Tue, 9 Jun 2015 11:14:27 +0000 (13:14 +0200)
pdns/dnsdist.cc

index 8fb6d84d19e6d863014a2fdeeca5aff42f83bf45..c73620f2efd7ed100552d93953d4220cb03119f0 100644 (file)
@@ -123,9 +123,13 @@ struct DelayedPacket
   int fd;
   string packet;
   ComboAddress destination;
+  ComboAddress origDest;
   void operator()()
   {
-    sendto(fd, packet.c_str(), packet.size(), 0, (struct sockaddr*)&destination, destination.getSocklen());
+    if(origDest.sin4.sin_family == 0)
+      sendto(fd, packet.c_str(), packet.size(), 0, (struct sockaddr*)&destination, destination.getSocklen());
+    else
+      sendfromto(fd, packet.c_str(), packet.size(), 0, origDest, destination);
   }
 };
 
@@ -160,7 +164,7 @@ void* responderThread(std::shared_ptr<DownstreamState> state)
     g_stats.responses++;
 
     if(ids->delayMsec) {
-      DelayedPacket dp{ids->origFD, string(packet,len), ids->origRemote};
+      DelayedPacket dp{ids->origFD, string(packet,len), ids->origRemote, ids->origDest};
       g_delay.submit(dp, ids->delayMsec);
     }
     else {