From: Kees Monshouwer Date: Thu, 10 Feb 2022 23:13:19 +0000 (+0100) Subject: auth: fix proxy protocol query statistics X-Git-Tag: rec-4.7.0-beta1~66^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=208abc4cd8d13d683e3703f533140d350304eef1;p=thirdparty%2Fpdns.git auth: fix proxy protocol query statistics --- diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 8ff7bcb215..34a41320e7 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -487,6 +487,7 @@ try bool logDNSQueries = ::arg().mustDo("log-dns-queries"); shared_ptr NS; std::string buffer; + ComboAddress accountremote; // If we have SO_REUSEPORT then create a new port for all receiver threads // other than the first one. @@ -517,7 +518,11 @@ try numreceived++; - if(question.d_remote.getSocklen()==sizeof(sockaddr_in)) + accountremote = question.d_remote; + if (question.d_inner_remote) + accountremote = *question.d_inner_remote; + + if (accountremote.sin4.sin_family == AF_INET) numreceived4++; else numreceived6++; @@ -547,6 +552,7 @@ try if(logDNSQueries) g_log<<": packetcache HIT"< packet; - ComboAddress remote; + ComboAddress remote, accountremote; socklen_t remotelen=sizeof(remote); size_t transactions = 0; time_t start = 0; @@ -296,6 +296,10 @@ void TCPNameserver::doConnection(int fd) } inner_remote = psource; inner_tcp = tcp; + accountremote = psource; + } + else { + accountremote = remote; } for(;;) { @@ -334,8 +338,8 @@ void TCPNameserver::doConnection(int fd) } getQuestion(fd, mesg.get(), pktlen, remote, remainingTime); - S.inc("tcp-queries"); - if(remote.sin4.sin_family == AF_INET6) + S.inc("tcp-queries"); + if (accountremote.sin4.sin_family == AF_INET6) S.inc("tcp6-queries"); else S.inc("tcp4-queries"); @@ -376,6 +380,7 @@ void TCPNameserver::doConnection(int fd) if(logDNSQueries) g_log<<": packetcache HIT"<setRemote(&packet->d_remote); + cached->d_inner_remote = packet->d_inner_remote; cached->d.id=packet->d.id; cached->d.rd=packet->d.rd; // copy in recursion desired bit cached->commitD(); // commit d to the packet inlined