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

This commit is contained in:
practicalswift 2021-04-01 08:01:33 +00:00
parent 5858057384
commit 58580a827d

View file

@ -576,6 +576,7 @@ std::string CNetAddr::ToStringIP() const
{
switch (m_net) {
case NET_IPV4:
return IPv4ToString(m_addr);
case NET_IPV6: {
CService serv(*this, 0);
struct sockaddr_storage sockaddr;
@ -586,9 +587,6 @@ std::string CNetAddr::ToStringIP() const
sizeof(name), nullptr, 0, NI_NUMERICHOST))
return std::string(name);
}
if (m_net == NET_IPV4) {
return IPv4ToString(m_addr);
}
return IPv6ToString(m_addr);
}
case NET_ONION: