aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-04-10 20:22:04 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-05-11 15:29:19 +0200
commit090e5b40f1b3ac9ac6209f8996da4d686686a2ac (patch)
treec26367aef8abd697b3f035e2340dcb407cd3424f /src/netbase.cpp
parentd32148567f5866a7cd2a77a2f44f846134011c9c (diff)
Limited relaying/storing of foreign addresses
Introduce a boolean variable for each "network" (ipv4, ipv6, tor, i2p), and track whether we are likely to able to connect to it. Addresses in "addr" messages outside of our network get limited relaying and are not stored in addrman.
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r--src/netbase.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index 37e6120e7f..4c852f5eee 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -25,6 +25,14 @@ int nConnectTimeout = 5000;
static const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff };
+enum Network ParseNetwork(std::string net) {
+ if (net == "ipv4") return NET_IPV4;
+ if (net == "ipv6") return NET_IPV6;
+ if (net == "tor") return NET_TOR;
+ if (net == "i2p") return NET_I2P;
+ return NET_UNROUTABLE;
+}
+
bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup)
{
vIP.clear();
@@ -688,6 +696,23 @@ bool CNetAddr::IsRoutable() const
return IsValid() && !(IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193() && !IsOnionCat() && !IsGarliCat()) || IsRFC4843() || IsLocal());
}
+enum Network CNetAddr::GetNetwork() const
+{
+ if (!IsRoutable())
+ return NET_UNROUTABLE;
+
+ if (IsIPv4())
+ return NET_IPV4;
+
+ if (IsOnionCat())
+ return NET_TOR;
+
+ if (IsGarliCat())
+ return NET_I2P;
+
+ return NET_IPV6;
+}
+
std::string CNetAddr::ToStringIP() const
{
if (IsIPv4())