]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth: fix proxy protocol query statistics 11314/head
authorKees Monshouwer <mind04@monshouwer.org>
Thu, 10 Feb 2022 23:13:19 +0000 (00:13 +0100)
committermind04 <mind04@monshouwer.org>
Fri, 11 Feb 2022 12:54:40 +0000 (13:54 +0100)
pdns/common_startup.cc
pdns/tcpreceiver.cc

index 8ff7bcb21559a88a4ec7a0c781e946f73324ae37..34a41320e7bc2105f4567623d534a6a971c22930 100644 (file)
@@ -487,6 +487,7 @@ try
   bool logDNSQueries = ::arg().mustDo("log-dns-queries");
   shared_ptr<UDPNameserver> 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"<<endl;
           cached.setRemote(&question.d_remote);  // inlined
+          cached.d_inner_remote = question.d_inner_remote;
           cached.setSocket(question.getSocket());                               // inlined
           cached.d_anyLocal = question.d_anyLocal;
           cached.setMaxReplyLen(question.getMaxReplyLen());
index 28f542648f800ba05808fe9dca9fec399ffb0c18..530ed90b4b487e4c9955c9542001195d0c255cf3 100644 (file)
@@ -221,7 +221,7 @@ void TCPNameserver::doConnection(int fd)
 {
   setThreadName("pdns/tcpConnect");
   std::unique_ptr<DNSPacket> 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"<<endl;
           cached->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