net: Avoid calling getnameinfo when formatting IPv6 addresses in CNetAddr::ToStringIP

pull/826/head
practicalswift 4 years ago
parent c10f27fdb2
commit 54548bae80

@ -615,15 +615,6 @@ std::string CNetAddr::ToStringIP() const
case NET_IPV4: case NET_IPV4:
return IPv4ToString(m_addr); return IPv4ToString(m_addr);
case NET_IPV6: { case NET_IPV6: {
CService serv(*this, 0);
struct sockaddr_storage sockaddr;
socklen_t socklen = sizeof(sockaddr);
if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) {
char name[1025] = "";
if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name,
sizeof(name), nullptr, 0, NI_NUMERICHOST))
return std::string(name);
}
return IPv6ToString(m_addr); return IPv6ToString(m_addr);
} }
case NET_ONION: case NET_ONION:

Loading…
Cancel
Save