From: bert hubert Date: Fri, 5 Jun 2015 20:49:14 +0000 (+0200) Subject: fix up 0.0.0.0 binding with delayed packets X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~78^2~19^2^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f84afacfd79d61b829e33c53af65b47400441aa;p=thirdparty%2Fpdns.git fix up 0.0.0.0 binding with delayed packets --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 8fb6d84d19..c73620f2ef 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 {