MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / ToStringIP

Method ToStringIP

src/netaddress.cpp:253–275  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251}
252
253std::string CNetAddr::ToStringIP() const
254{
255 if (IsTor())
256 return EncodeBase32(&ip[6], 10) + ".onion";
257 if (IsInternal())
258 return EncodeBase32(ip + sizeof(g_internal_prefix), sizeof(ip) - sizeof(g_internal_prefix)) + ".internal";
259 CService serv(*this, 0);
260 struct sockaddr_storage sockaddr;
261 socklen_t socklen = sizeof(sockaddr);
262 if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) {
263 char name[1025] = "";
264 if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name, sizeof(name), nullptr, 0, NI_NUMERICHOST))
265 return std::string(name);
266 }
267 if (IsIPv4())
268 return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0));
269 else
270 return strprintf("%x:%x:%x:%x:%x:%x:%x:%x",
271 GetByte(15) << 8 | GetByte(14), GetByte(13) << 8 | GetByte(12),
272 GetByte(11) << 8 | GetByte(10), GetByte(9) << 8 | GetByte(8),
273 GetByte(7) << 8 | GetByte(6), GetByte(5) << 8 | GetByte(4),
274 GetByte(3) << 8 | GetByte(2), GetByte(1) << 8 | GetByte(0));
275}
276
277std::string CNetAddr::ToString() const
278{

Callers 4

ConnectNodeMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
getProxySettingsMethod · 0.80

Calls 2

EncodeBase32Function · 0.85
GetSockAddrMethod · 0.80

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64