}
std::string addr;
- addr += eaddr.ip_only_to_str();
- addr += ":";
- addr += std::to_string(eaddr.get_port());
+ addr += eaddr.ip_n_port_to_str();
/* If this will overrun cci_mons, stop here */
if (monaddrs.length() + 1 + addr.length() + 1 > sizeof(cci->cci_mons))
break;
}
return host_ip ? host_ip : "";
}
+
+std::string entity_addr_t::ip_n_port_to_str() const
+{
+ std::string addr;
+ addr += ip_only_to_str();
+ if (is_ipv6()) {
+ addr = '[' + addr + ']';
+ }
+ addr += ':';
+ addr += std::to_string(get_port());
+ return addr;
+}
+
}
std::string ip_only_to_str() const;
+ std::string ip_n_port_to_str() const;
std::string get_legacy_str() const {
std::ostringstream ss;