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

Method ToStringIP

src/netbase.cpp:866–886  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

864}
865
866std::string CNetAddr::ToStringIP() const
867{
868 if (IsTor())
869 return EncodeBase32(&ip[6], 10) + ".onion";
870 CService serv(*this, 0);
871 struct sockaddr_storage sockaddr;
872 socklen_t socklen = sizeof(sockaddr);
873 if (serv.GetSockAddr((struct sockaddr*)&sockaddr, &socklen)) {
874 char name[1025] = "";
875 if (!getnameinfo((const struct sockaddr*)&sockaddr, socklen, name, sizeof(name), NULL, 0, NI_NUMERICHOST))
876 return std::string(name);
877 }
878 if (IsIPv4())
879 return strprintf("%u.%u.%u.%u", GetByte(3), GetByte(2), GetByte(1), GetByte(0));
880 else
881 return strprintf("%x:%x:%x:%x:%x:%x:%x:%x",
882 GetByte(15) << 8 | GetByte(14), GetByte(13) << 8 | GetByte(12),
883 GetByte(11) << 8 | GetByte(10), GetByte(9) << 8 | GetByte(8),
884 GetByte(7) << 8 | GetByte(6), GetByte(5) << 8 | GetByte(4),
885 GetByte(3) << 8 | GetByte(2), GetByte(1) << 8 | GetByte(0));
886}
887
888std::string CNetAddr::ToString() const
889{

Callers 7

ConnectSocketFunction · 0.80
BOOST_FOREACHFunction · 0.80
AssignIPGroupSlotFunction · 0.80
CNodeMethod · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
BOOST_AUTO_TEST_CASEFunction · 0.80
getProxySettingsMethod · 0.80

Calls 2

EncodeBase32Function · 0.85
GetSockAddrMethod · 0.80

Tested by 2

BOOST_AUTO_TEST_CASEFunction · 0.64
BOOST_AUTO_TEST_CASEFunction · 0.64