diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2021-04-01 08:02:21 +0000 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2021-04-01 08:00:48 +0000 |
commit | 58580573843858068db69a378b6e9363889b1f6d (patch) | |
tree | c3afeeb2915ae88e2970f4fab9c55022b8b0ffeb /src/netaddress.cpp | |
parent | 2b2ab9ab7895cd6356e5dc4db17aa9ce475d495e (diff) |
net: Add IPv4ToString (we already have IPv6ToString)
Diffstat (limited to 'src/netaddress.cpp')
-rw-r--r-- | src/netaddress.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
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<const uint8_t> a) +{ + return strprintf("%u.%u.%u.%u", a[0], a[1], a[2], a[3]); +} + static std::string IPv6ToString(Span<const uint8_t> 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); } |