]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix first IPv6 console connection being rejected
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 12 Mar 2024 13:59:25 +0000 (14:59 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 14 Mar 2024 08:48:10 +0000 (09:48 +0100)
If we don't set the family of the client IP address,
`ComboAddress::getSocklen()` will return the size of an IPv4 struct
and thus the first IPv6 client address will get truncated.
Subsequent connections will be fine because the family will have been
set to IPv6.

pdns/dnsdistdist/dnsdist-console.cc

index a175cae26156885b70bdba3c54fe1bc89d89c6fc..0828dcaa77b25e89d04d7c26d03995e4e4ff489e 100644 (file)
@@ -1034,6 +1034,11 @@ void controlThread(std::shared_ptr<Socket> acceptFD, ComboAddress local)
   try {
     setThreadName("dnsdist/control");
     ComboAddress client;
+    // make sure that the family matches the one from the listening IP,
+    // so that getSocklen() returns the correct size later, otherwise
+    // the first IPv6 console connection might get refused
+    client.sin4.sin_family = local.sin4.sin_family;
+
     int sock{-1};
     auto localACL = g_consoleACL.getLocal();
     infolog("Accepting control connections on %s", local.toStringWithPort());