From: Mischan Toosarani-Hausberger Date: Thu, 11 Jun 2020 16:25:03 +0000 (+0200) Subject: dnsdist: Use toStringWithPort instead of manual addr/port concat X-Git-Tag: rec-4.4.0-beta1~53^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ede22b612eaade1f607acff744d0d62ec69741c6;p=thirdparty%2Fpdns.git dnsdist: Use toStringWithPort instead of manual addr/port concat 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. --- diff --git a/pdns/dnsdist-carbon.cc b/pdns/dnsdist-carbon.cc index 6f8bc64a55..53475dfa9e 100644 --- a/pdns/dnsdist-carbon.cc +++ b/pdns/dnsdist-carbon.cc @@ -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<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) { diff --git a/pdns/dnsdist-web.cc b/pdns/dnsdist-web.cc index 4766403924..08b85edafd 100644 --- a/pdns/dnsdist-web.cc +++ b/pdns/dnsdist-web.cc @@ -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;