Skip to content

Commit 07ff18b

Browse files
authored
Merge pull request #2409 from Pythonix/remove-i2p
net: Remove I2P support from netbase & Correct HE IPv6 Tunnel Broker
2 parents b10d11a + 7a19c76 commit 07ff18b

File tree

2 files changed

+7
-42
lines changed

2 files changed

+7
-42
lines changed

src/netbase.cpp

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ enum Network ParseNetwork(std::string net) {
3333
if (net == "ipv4") return NET_IPV4;
3434
if (net == "ipv6") return NET_IPV6;
3535
if (net == "tor") return NET_TOR;
36-
if (net == "i2p") return NET_I2P;
3736
return NET_UNROUTABLE;
3837
}
3938

@@ -492,7 +491,6 @@ void CNetAddr::SetIP(const CNetAddr& ipIn)
492491
}
493492

494493
static const unsigned char pchOnionCat[] = {0xFD,0x87,0xD8,0x7E,0xEB,0x43};
495-
static const unsigned char pchGarliCat[] = {0xFD,0x60,0xDB,0x4D,0xDD,0xB5};
496494

497495
bool CNetAddr::SetSpecial(const std::string &strName)
498496
{
@@ -505,15 +503,6 @@ bool CNetAddr::SetSpecial(const std::string &strName)
505503
ip[i + sizeof(pchOnionCat)] = vchAddr[i];
506504
return true;
507505
}
508-
if (strName.size()>11 && strName.substr(strName.size() - 11, 11) == ".oc.b32.i2p") {
509-
std::vector<unsigned char> vchAddr = DecodeBase32(strName.substr(0, strName.size() - 11).c_str());
510-
if (vchAddr.size() != 16-sizeof(pchGarliCat))
511-
return false;
512-
memcpy(ip, pchOnionCat, sizeof(pchGarliCat));
513-
for (unsigned int i=0; i<16-sizeof(pchGarliCat); i++)
514-
ip[i + sizeof(pchGarliCat)] = vchAddr[i];
515-
return true;
516-
}
517506
return false;
518507
}
519508

@@ -561,7 +550,7 @@ bool CNetAddr::IsIPv4() const
561550

562551
bool CNetAddr::IsIPv6() const
563552
{
564-
return (!IsIPv4() && !IsTor() && !IsI2P());
553+
return (!IsIPv4() && !IsTor());
565554
}
566555

567556
bool CNetAddr::IsRFC1918() const
@@ -625,11 +614,6 @@ bool CNetAddr::IsTor() const
625614
return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0);
626615
}
627616

628-
bool CNetAddr::IsI2P() const
629-
{
630-
return (memcmp(ip, pchGarliCat, sizeof(pchGarliCat)) == 0);
631-
}
632-
633617
bool CNetAddr::IsLocal() const
634618
{
635619
// IPv4 loopback
@@ -688,7 +672,7 @@ bool CNetAddr::IsValid() const
688672

689673
bool CNetAddr::IsRoutable() const
690674
{
691-
return IsValid() && !(IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193() && !IsTor() && !IsI2P()) || IsRFC4843() || IsLocal());
675+
return IsValid() && !(IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193() && !IsTor()) || IsRFC4843() || IsLocal());
692676
}
693677

694678
enum Network CNetAddr::GetNetwork() const
@@ -702,18 +686,13 @@ enum Network CNetAddr::GetNetwork() const
702686
if (IsTor())
703687
return NET_TOR;
704688

705-
if (IsI2P())
706-
return NET_I2P;
707-
708689
return NET_IPV6;
709690
}
710691

711692
std::string CNetAddr::ToStringIP() const
712693
{
713694
if (IsTor())
714695
return EncodeBase32(&ip[6], 10) + ".onion";
715-
if (IsI2P())
716-
return EncodeBase32(&ip[6], 10) + ".oc.b32.i2p";
717696
CService serv(*this, 0);
718697
struct sockaddr_storage sockaddr;
719698
socklen_t socklen = sizeof(sockaddr);
@@ -818,14 +797,8 @@ std::vector<unsigned char> CNetAddr::GetGroup() const
818797
nStartByte = 6;
819798
nBits = 4;
820799
}
821-
else if (IsI2P())
822-
{
823-
nClass = NET_I2P;
824-
nStartByte = 6;
825-
nBits = 4;
826-
}
827800
// for he.net, use /36 groups
828-
else if (GetByte(15) == 0x20 && GetByte(14) == 0x11 && GetByte(13) == 0x04 && GetByte(12) == 0x70)
801+
else if (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x04 && GetByte(12) == 0x70)
829802
nBits = 36;
830803
// for the rest of the IPv6 network, use /32 groups
831804
else
@@ -909,11 +882,6 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
909882
case NET_IPV4: return REACH_IPV4; // Tor users can connect to IPv4 as well
910883
case NET_TOR: return REACH_PRIVATE;
911884
}
912-
case NET_I2P:
913-
switch(ourNet) {
914-
default: return REACH_DEFAULT;
915-
case NET_I2P: return REACH_PRIVATE;
916-
}
917885
case NET_TEREDO:
918886
switch(ourNet) {
919887
default: return REACH_DEFAULT;
@@ -929,8 +897,7 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
929897
case NET_TEREDO: return REACH_TEREDO;
930898
case NET_IPV6: return REACH_IPV6_WEAK;
931899
case NET_IPV4: return REACH_IPV4;
932-
case NET_I2P: return REACH_PRIVATE; // assume connections from unroutable addresses are
933-
case NET_TOR: return REACH_PRIVATE; // either from Tor/I2P, or don't care about our address
900+
case NET_TOR: return REACH_PRIVATE; // either from Tor, or don't care about our address
934901
}
935902
}
936903
}
@@ -1079,7 +1046,7 @@ std::string CService::ToStringPort() const
10791046

10801047
std::string CService::ToStringIPPort() const
10811048
{
1082-
if (IsIPv4() || IsTor() || IsI2P()) {
1049+
if (IsIPv4() || IsTor()) {
10831050
return ToStringIP() + ":" + ToStringPort();
10841051
} else {
10851052
return "[" + ToStringIP() + "]:" + ToStringPort();

src/netbase.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ enum Network
2424
NET_IPV4,
2525
NET_IPV6,
2626
NET_TOR,
27-
NET_I2P,
2827
NET_CJDNS,
2928
NET_INTERNAL,
3029

@@ -44,9 +43,9 @@ class CNetAddr
4443
explicit CNetAddr(const std::string &strIp, bool fAllowLookup = false);
4544
void Init();
4645
void SetIP(const CNetAddr& ip);
47-
bool SetSpecial(const std::string &strName); // for Tor and I2P addresses
46+
bool SetSpecial(const std::string &strName); // for Tor addresses
4847
bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0)
49-
bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor/I2P)
48+
bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor)
5049
bool IsRFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12)
5150
bool IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32)
5251
bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16)
@@ -58,7 +57,6 @@ class CNetAddr
5857
bool IsRFC6052() const; // IPv6 well-known prefix (64:FF9B::/96)
5958
bool IsRFC6145() const; // IPv6 IPv4-translated address (::FFFF:0:0:0/96)
6059
bool IsTor() const;
61-
bool IsI2P() const;
6260
bool IsLocal() const;
6361
bool IsRoutable() const;
6462
bool IsValid() const;

0 commit comments

Comments
 (0)