]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: count substituted remote in case of proxy protocol
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 17 Jun 2024 09:22:47 +0000 (11:22 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 17 Jun 2024 09:22:47 +0000 (11:22 +0200)
Other remote counts are already doing that

pdns/recursordist/pdns_recursor.cc
pdns/recursordist/rec-tcp.cc

index 5e0c98ee5ae1c522d82dca213878152206f54b15..a04aaa5ce83c9808e782daa3cf1916f32236470d 100644 (file)
@@ -2550,7 +2550,7 @@ static void handleNewUDPQuestion(int fileDesc, FDMultiplexer::funcparam_t& /* va
         }
       }
       if (t_remotes) {
-        t_remotes->push_back(fromaddr);
+        t_remotes->push_back(source);
       }
 
       if (t_allowFrom && !t_allowFrom->match(&mappedSource)) {
index 4d1a055fff6f3ec54caf309c2149ef2e5e4787b8..661be32fbe1af46dec96737595573c262d77b801 100644 (file)
@@ -565,6 +565,9 @@ static void handleRunningTCPQuestion(int fileDesc, FDMultiplexer::funcparam_t& v
           ++iter->second.stats.netmaskMatches;
         }
       }
+      if (t_remotes) {
+        t_remotes->push_back(conn->d_source);
+      }
       if (t_allowFrom && !t_allowFrom->match(&conn->d_mappedSource)) {
         if (!g_quiet) {
           SLOG(g_log << Logger::Error << "[" << g_multiTasker->getTid() << "] dropping TCP query from " << conn->d_mappedSource.toString() << ", address not matched by allow-from" << endl,
@@ -693,10 +696,6 @@ void handleNewTCPQuestion(int fileDesc, [[maybe_unused]] FDMultiplexer::funcpara
       return;
     }
 
-    if (t_remotes) {
-      t_remotes->push_back(addr);
-    }
-
     ComboAddress destaddr;
     socklen_t len = sizeof(destaddr);
     getsockname(newsock, reinterpret_cast<sockaddr*>(&destaddr), &len); // if this fails, we're ok with it NOLINT(cppcoreguidelines-pro-type-reinterpret-cast)