MCPcopy Create free account
hub / github.com/LUX-Core/lux / ToStringIP

Method ToStringIP

src/netbase.cpp:843–863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

841}
842
843std::string CNetAddr::ToStringIP() const
844{
845 if (IsTor())
846 return EncodeBase32(&ip[6], 10) + ".onion";
847 CService serv(*this, 0);
848 struct sockaddr_storage sockaddr;
849 socklen_t socklen = sizeof(sockaddr);
850 if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) {
851 char name[1025] = "";
852 if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name, sizeof(name), NULL, 0, NI_NUMERICHOST))
853 return std::string(name);
854 }
855 if (IsIPv4())
856 return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0));
857 else
858 return strprintf("%x:%x:%x:%x:%x:%x:%x:%x",
859 GetByte(15) << 8 | GetByte(14), GetByte(13) << 8 | GetByte(12),
860 GetByte(11) << 8 | GetByte(10), GetByte(9) << 8 | GetByte(8),
861 GetByte(7) << 8 | GetByte(6), GetByte(5) << 8 | GetByte(4),
862 GetByte(3) << 8 | GetByte(2), GetByte(1) << 8 | GetByte(0));
863}
864
865std::string CNetAddr::ToString() const
866{

Callers 3

ConnectSocketFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
getProxySettingsMethod · 0.80

Calls 3

EncodeBase32Function · 0.85
GetByteFunction · 0.85
GetSockAddrMethod · 0.80

Tested by 1

BOOST_AUTO_TEST_CASEFunction · 0.64