From 58580573843858068db69a378b6e9363889b1f6d Mon Sep 17 00:00:00 2001 From: practicalswift Date: Thu, 1 Apr 2021 08:02:21 +0000 Subject: [PATCH] net: Add IPv4ToString (we already have IPv6ToString) --- src/netaddress.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/netaddress.cpp b/src/netaddress.cpp index 69edc15c66..b2a7a29d06 100644 --- a/src/netaddress.cpp +++ b/src/netaddress.cpp @@ -551,6 +551,11 @@ enum Network CNetAddr::GetNetwork() const return m_net; } +static std::string IPv4ToString(Span a) +{ + return strprintf("%u.%u.%u.%u", a[0], a[1], a[2], a[3]); +} + static std::string IPv6ToString(Span a) { assert(a.size() == ADDR_IPV6_SIZE); @@ -582,7 +587,7 @@ std::string CNetAddr::ToStringIP() const return std::string(name); } if (m_net == NET_IPV4) { - return strprintf("%u.%u.%u.%u", m_addr[0], m_addr[1], m_addr[2], m_addr[3]); + return IPv4ToString(m_addr); } return IPv6ToString(m_addr); }