Changeset View
Changeset View
Standalone View
Standalone View
src/netaddress.cpp
Show First 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | if (!IsRoutable()) { | ||||
return NET_UNROUTABLE; | return NET_UNROUTABLE; | ||||
} | } | ||||
if (IsIPv4()) { | if (IsIPv4()) { | ||||
return NET_IPV4; | return NET_IPV4; | ||||
} | } | ||||
if (IsTor()) { | if (IsTor()) { | ||||
return NET_TOR; | return NET_ONION; | ||||
} | } | ||||
return NET_IPV6; | return NET_IPV6; | ||||
} | } | ||||
std::string CNetAddr::ToStringIP() const { | std::string CNetAddr::ToStringIP() const { | ||||
if (IsTor()) { | if (IsTor()) { | ||||
return EncodeBase32(&ip[6], 10) + ".onion"; | return EncodeBase32(&ip[6], 10) + ".onion"; | ||||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | std::vector<uint8_t> CNetAddr::GetGroup() const { | ||||
} else if (IsRFC4380()) { | } else if (IsRFC4380()) { | ||||
// for Teredo-tunnelled IPv6 addresses, use the encapsulated IPv4 | // for Teredo-tunnelled IPv6 addresses, use the encapsulated IPv4 | ||||
// address | // address | ||||
vchRet.push_back(NET_IPV4); | vchRet.push_back(NET_IPV4); | ||||
vchRet.push_back(GetByte(3) ^ 0xFF); | vchRet.push_back(GetByte(3) ^ 0xFF); | ||||
vchRet.push_back(GetByte(2) ^ 0xFF); | vchRet.push_back(GetByte(2) ^ 0xFF); | ||||
return vchRet; | return vchRet; | ||||
} else if (IsTor()) { | } else if (IsTor()) { | ||||
nClass = NET_TOR; | nClass = NET_ONION; | ||||
nStartByte = 6; | nStartByte = 6; | ||||
nBits = 4; | nBits = 4; | ||||
} else if (GetByte(15) == 0x20 && GetByte(14) == 0x01 && | } else if (GetByte(15) == 0x20 && GetByte(14) == 0x01 && | ||||
GetByte(13) == 0x04 && GetByte(12) == 0x70) { | GetByte(13) == 0x04 && GetByte(12) == 0x70) { | ||||
// for he.net, use /36 groups | // for he.net, use /36 groups | ||||
nBits = 36; | nBits = 36; | ||||
} else { | } else { | ||||
// for the rest of the IPv6 network, use /32 groups | // for the rest of the IPv6 network, use /32 groups | ||||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | switch (theirNet) { | ||||
case NET_TEREDO: | case NET_TEREDO: | ||||
return REACH_TEREDO; | return REACH_TEREDO; | ||||
case NET_IPV4: | case NET_IPV4: | ||||
return REACH_IPV4; | return REACH_IPV4; | ||||
// only prefer giving our IPv6 address if it's not tunnelled | // only prefer giving our IPv6 address if it's not tunnelled | ||||
case NET_IPV6: | case NET_IPV6: | ||||
return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; | return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; | ||||
} | } | ||||
case NET_TOR: | case NET_ONION: | ||||
switch (ourNet) { | switch (ourNet) { | ||||
default: | default: | ||||
return REACH_DEFAULT; | return REACH_DEFAULT; | ||||
// Tor users can connect to IPv4 as well | // Tor users can connect to IPv4 as well | ||||
case NET_IPV4: | case NET_IPV4: | ||||
return REACH_IPV4; | return REACH_IPV4; | ||||
case NET_TOR: | case NET_ONION: | ||||
return REACH_PRIVATE; | return REACH_PRIVATE; | ||||
} | } | ||||
case NET_TEREDO: | case NET_TEREDO: | ||||
switch (ourNet) { | switch (ourNet) { | ||||
default: | default: | ||||
return REACH_DEFAULT; | return REACH_DEFAULT; | ||||
case NET_TEREDO: | case NET_TEREDO: | ||||
return REACH_TEREDO; | return REACH_TEREDO; | ||||
Show All 10 Lines | switch (theirNet) { | ||||
return REACH_DEFAULT; | return REACH_DEFAULT; | ||||
case NET_TEREDO: | case NET_TEREDO: | ||||
return REACH_TEREDO; | return REACH_TEREDO; | ||||
case NET_IPV6: | case NET_IPV6: | ||||
return REACH_IPV6_WEAK; | return REACH_IPV6_WEAK; | ||||
case NET_IPV4: | case NET_IPV4: | ||||
return REACH_IPV4; | return REACH_IPV4; | ||||
// either from Tor, or don't care about our address | // either from Tor, or don't care about our address | ||||
case NET_TOR: | case NET_ONION: | ||||
return REACH_PRIVATE; | return REACH_PRIVATE; | ||||
} | } | ||||
} | } | ||||
} | } | ||||
CService::CService() : port(0) {} | CService::CService() : port(0) {} | ||||
CService::CService(const CNetAddr &cip, unsigned short portIn) | CService::CService(const CNetAddr &cip, unsigned short portIn) | ||||
▲ Show 20 Lines • Show All 260 Lines • Show Last 20 Lines |