]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Use toStringWithPort instead of manual addr/port concat 9222/head
authorMischan Toosarani-Hausberger <migosch@gmail.com>
Thu, 11 Jun 2020 16:25:03 +0000 (18:25 +0200)
committerMischan Toosarani-Hausberger <migosch@gmail.com>
Thu, 11 Jun 2020 16:43:26 +0000 (18:43 +0200)
Doing manual string concatenation like

address + ":" + port

leads to incorrectly rendered front-end labels in the metrics endpoint
when using IPv6 addresses. The same concatenation pattern was used in
the carbon-dump.

pdns/dnsdist-carbon.cc
pdns/dnsdist-web.cc

index 6f8bc64a554b1dad88ab7e4d93767c47cf5a3b3f..53475dfa9e60823920bdc088113fd1becd457443 100644 (file)
@@ -86,7 +86,7 @@ try
         }
         auto states = g_dstates.getLocal();
         for(const auto& state : *states) {
-          string serverName = state->getName().empty() ? (state->remote.toString() + ":" + std::to_string(state->remote.getPort())) : state->getName();
+          string serverName = state->getName().empty() ? state->remote.toStringWithPort() : state->getName();
           boost::replace_all(serverName, ".", "_");
           const string base = namespace_name + "." + hostname + "." + instance_name + ".servers." + serverName + ".";
           str<<base<<"queries" << ' ' << state->queries.load() << " " << now << "\r\n";
@@ -110,7 +110,7 @@ try
           if (front->udpFD == -1 && front->tcpFD == -1)
             continue;
 
-          string frontName = front->local.toString() + ":" + std::to_string(front->local.getPort()) +  (front->udpFD >= 0 ? "_udp" : "_tcp");
+          string frontName = front->local.toStringWithPort() + (front->udpFD >= 0 ? "_udp" : "_tcp");
           boost::replace_all(frontName, ".", "_");
           auto dupPair = frontendDuplicates.insert({frontName, 1});
           if (!dupPair.second) {
index 4766403924aa92b3274eab188bc4cbcf1fac2c4e..08b85edafdea09da4e8cf0fa20078388c7fde85b 100644 (file)
@@ -629,7 +629,7 @@ static void connectionThread(int sock, ComboAddress remote)
           if (front->udpFD == -1 && front->tcpFD == -1)
             continue;
 
-          const string frontName = front->local.toString() + ":" + std::to_string(front->local.getPort());
+          const string frontName = front->local.toStringWithPort();
           const string proto = front->getType();
           const string fullName = frontName + "_" + proto;
           uint64_t threadNumber = 0;