]> granicus.if.org Git - pdns/commitdiff
dnsdist: Don't use square brackets for IPv6 in Carbon metrics
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 3 Aug 2017 14:29:56 +0000 (16:29 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 3 Aug 2017 14:29:56 +0000 (16:29 +0200)
pdns/dnsdist-carbon.cc
pdns/iputils.hh

index 63e780d8259faff856d464cd797118e5f6dc9d55..caae0bb941d49adfce8ba8b263a95b63cbe45fd8 100644 (file)
@@ -84,7 +84,7 @@ try
         }
         const auto states = g_dstates.getCopy();
         for(const auto& state : states) {
-          string serverName = state->getName();
+          string serverName = state->name.empty() ? (state->remote.toString() + ":" + std::to_string(state->remote.getPort())) : state->getName();
           boost::replace_all(serverName, ".", "_");
           const string base = "dnsdist." + hostname + ".main.servers." + serverName + ".";
           str<<base<<"queries" << ' ' << state->queries.load() << " " << now << "\r\n";
@@ -97,7 +97,7 @@ try
           if (front->udpFD == -1 && front->tcpFD == -1)
             continue;
 
-          string frontName = front->local.toStringWithPort() + (front->udpFD >= 0 ? "_udp" : "_tcp");
+          string frontName = front->local.toString() + ":" + std::to_string(front->local.getPort()) +  (front->udpFD >= 0 ? "_udp" : "_tcp");
           boost::replace_all(frontName, ".", "_");
           const string base = "dnsdist." + hostname + ".main.frontends." + frontName + ".";
           str<<base<<"queries" << ' ' << front->queries.load() << " " << now << "\r\n";
index 30849cd6b302558d966ddedd101e1ca155e80ca7..bf6ba4c9ff071447e7cf12de835e648ad4e9bdd0 100644 (file)
@@ -276,6 +276,12 @@ union ComboAddress {
   }
 
   void truncate(unsigned int bits) noexcept;
+
+  uint16_t getPort() const
+  {
+    return ntohs(sin4.sin_port);
+  }
+
 };
 
 /** This exception is thrown by the Netmask class and by extension by the NetmaskGroup class */