From: Peter van Dijk Date: Wed, 2 Jan 2013 09:30:44 +0000 (+0000) Subject: use the right binding code for TCP vs UDP, thanks Sander Hoentjen. Closes #644 and... X-Git-Tag: auth-3.2-rc4~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eabdf7e0405bc12b93f9f3cb8a9e3e41f20452d3;p=thirdparty%2Fpdns.git use the right binding code for TCP vs UDP, thanks Sander Hoentjen. Closes #644 and possibly #643 git-svn-id: svn://svn.powerdns.com/pdns/trunk/pdns@3014 d19b8d6e-7fed-0310-83ef-9ca221ded41b --- diff --git a/pdns/resolver.cc b/pdns/resolver.cc index 9cc3b8487c..6ffb3a11ed 100644 --- a/pdns/resolver.cc +++ b/pdns/resolver.cc @@ -55,7 +55,8 @@ int makeQuerySocket(const ComboAddress& local, bool udpOrTCP) unixDie("Creating local resolver socket for "+ourLocal.toString() + ((local.sin4.sin_family == AF_INET6) ? ", does your OS miss IPv6?" : "")); } - if(!udpOrTCP) { + if(udpOrTCP) { + // udp, try hard to bind an unpredictable port int tries=10; while(--tries) { ourLocal.sin4.sin_port = htons(10000+(dns_random(10000))); @@ -63,12 +64,16 @@ int makeQuerySocket(const ComboAddress& local, bool udpOrTCP) if (::bind(sock, (struct sockaddr *)&ourLocal, ourLocal.getSocklen()) >= 0) break; } + // cerr<<"bound udp port "<