diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-04-02 17:06:11 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-05-11 15:29:19 +0200 |
commit | d32148567f5866a7cd2a77a2f44f846134011c9c (patch) | |
tree | e5f4fe51543a2d60eb2191ebef204dcdeafde7bb /src | |
parent | 23aa78c405f82257e8578afb3d5d244aa27dcd74 (diff) |
Preliminary support for Tor/I2P hidden services
There are plans to let Bitcoin function as Tor/I2P hidden service.
To do so, we could use the established encoding provided by OnionCat
and GarliCat (without actually using those tools) to embed Tor/I2P
addresses in IPv6.
This patch makes these addresses considered routable, so they can
travel over the Bitcoin network in 'addr' messages. This will hopefully
make it easier to deploy real hidden service support later.
Diffstat (limited to 'src')
-rw-r--r-- | src/netbase.cpp | 14 | ||||
-rw-r--r-- | src/netbase.h | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp index a22d42a967..37e6120e7f 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -615,6 +615,18 @@ bool CNetAddr::IsRFC4843() const return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x00 && (GetByte(12) & 0xF0) == 0x10); } +bool CNetAddr::IsOnionCat() const +{ + static const unsigned char pchOnionCat[] = {0xFD,0x87,0xD8,0x7E,0xEB,0x43}; + return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0); +} + +bool CNetAddr::IsGarliCat() const +{ + static const unsigned char pchGarliCat[] = {0xFD,0x60,0xDB,0x4D,0xDD,0xB5}; + return (memcmp(ip, pchGarliCat, sizeof(pchGarliCat)) == 0); +} + bool CNetAddr::IsLocal() const { // IPv4 loopback @@ -673,7 +685,7 @@ bool CNetAddr::IsValid() const bool CNetAddr::IsRoutable() const { - return IsValid() && !(IsRFC1918() || IsRFC3927() || IsRFC4862() || IsRFC4193() || IsRFC4843() || IsLocal()); + return IsValid() && !(IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193() && !IsOnionCat() && !IsGarliCat()) || IsRFC4843() || IsLocal()); } std::string CNetAddr::ToStringIP() const diff --git a/src/netbase.h b/src/netbase.h index acbcc36d18..1b6d8d59bb 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -42,6 +42,8 @@ class CNetAddr bool IsRFC4862() const; // IPv6 autoconfig (FE80::/64) bool IsRFC6052() const; // IPv6 well-known prefix (64:FF9B::/96) bool IsRFC6145() const; // IPv6 IPv4-translated address (::FFFF:0:0:0/96) + bool IsOnionCat() const; + bool IsGarliCat() const; bool IsLocal() const; bool IsRoutable() const; bool IsValid() const; |