aboutsummaryrefslogtreecommitdiff
path: root/src/netaddress.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/netaddress.cpp')
-rw-r--r--src/netaddress.cpp50
1 files changed, 7 insertions, 43 deletions
diff --git a/src/netaddress.cpp b/src/netaddress.cpp
index 71a3580615..85ae8fab36 100644
--- a/src/netaddress.cpp
+++ b/src/netaddress.cpp
@@ -179,7 +179,7 @@ bool CNetAddr::SetInternal(const std::string &name)
}
namespace torv3 {
-// https://gitweb.torproject.org/torspec.git/tree/rend-spec-v3.txt#n2135
+// https://gitweb.torproject.org/torspec.git/tree/rend-spec-v3.txt?id=7116c9cdaba248aae07a3f1d0e15d9dd102f62c5#n2175
static constexpr size_t CHECKSUM_LEN = 2;
static const unsigned char VERSION[] = {3};
static constexpr size_t TOTAL_LEN = ADDR_TORV3_SIZE + CHECKSUM_LEN + sizeof(VERSION);
@@ -599,7 +599,7 @@ std::string OnionToString(Span<const uint8_t> addr)
return EncodeBase32(address) + ".onion";
}
-std::string CNetAddr::ToStringIP() const
+std::string CNetAddr::ToStringAddr() const
{
switch (m_net) {
case NET_IPV4:
@@ -622,11 +622,6 @@ std::string CNetAddr::ToStringIP() const
assert(false);
}
-std::string CNetAddr::ToString() const
-{
- return ToStringIP();
-}
-
bool operator==(const CNetAddr& a, const CNetAddr& b)
{
return a.m_net == b.m_net && a.m_addr == b.m_addr;
@@ -916,25 +911,17 @@ std::vector<unsigned char> CService::GetKey() const
return key;
}
-std::string CService::ToStringPort() const
+std::string CService::ToStringAddrPort() const
{
- return strprintf("%u", port);
-}
+ const auto port_str = strprintf("%u", port);
-std::string CService::ToStringIPPort() const
-{
if (IsIPv4() || IsTor() || IsI2P() || IsInternal()) {
- return ToStringIP() + ":" + ToStringPort();
+ return ToStringAddr() + ":" + port_str;
} else {
- return "[" + ToStringIP() + "]:" + ToStringPort();
+ return "[" + ToStringAddr() + "]:" + port_str;
}
}
-std::string CService::ToString() const
-{
- return ToStringIPPort();
-}
-
CSubNet::CSubNet():
valid(false)
{
@@ -1098,7 +1085,7 @@ std::string CSubNet::ToString() const
break;
}
- return network.ToString() + suffix;
+ return network.ToStringAddr() + suffix;
}
bool CSubNet::IsValid() const
@@ -1106,29 +1093,6 @@ bool CSubNet::IsValid() const
return valid;
}
-bool CSubNet::SanityCheck() const
-{
- switch (network.m_net) {
- case NET_IPV4:
- case NET_IPV6:
- break;
- case NET_ONION:
- case NET_I2P:
- case NET_CJDNS:
- return true;
- case NET_INTERNAL:
- case NET_UNROUTABLE:
- case NET_MAX:
- return false;
- }
-
- for (size_t x = 0; x < network.m_addr.size(); ++x) {
- if (network.m_addr[x] & ~netmask[x]) return false;
- }
-
- return true;
-}
-
bool operator==(const CSubNet& a, const CSubNet& b)
{
return a.valid == b.valid && a.network == b.network && !memcmp(a.netmask, b.netmask, 16);