From 68f3eb4de80fc7c5c4e36df67dc5906057b16abf Mon Sep 17 00:00:00 2001 From: bert hubert Date: Fri, 5 Jun 2015 22:49:14 +0200 Subject: [PATCH] fix up 0.0.0.0 binding with delayed packets --- pdns/dnsdist.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 8fb6d84d1..c73620f2e 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -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 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 { -- 2.50.0