From 208abc4cd8d13d683e3703f533140d350304eef1 Mon Sep 17 00:00:00 2001 From: Kees Monshouwer Date: Fri, 11 Feb 2022 00:13:19 +0100 Subject: [PATCH] auth: fix proxy protocol query statistics --- pdns/common_startup.cc | 8 +++++++- pdns/tcpreceiver.cc | 11 ++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) 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 -- 2.47.2