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~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=68f3eb4de80fc7c5c4e36df67dc5906057b16abf;p=pdns fix up 0.0.0.0 binding with delayed packets --- 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 {