Browse Source

removed Tor addresses

pull/5/head
orignal 8 years ago
parent
commit
8e073aed05
  1. 16
      src/init.cpp
  2. 39
      src/netbase.cpp
  3. 6
      src/netbase.h

16
src/init.cpp

@ -331,7 +331,6 @@ std::string HelpMessage() @@ -331,7 +331,6 @@ std::string HelpMessage()
" -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n" +
" -proxy=<ip:port> " + _("Connect through socks proxy") + "\n" +
" -socks=<n> " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n" +
" -tor=<ip:port> " + _("Use proxy to reach tor hidden services (default: same as -proxy)") + "\n"
" -dns " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n" +
" -port=<port> " + _("Listen for connections on <port> (default: 9377 or testnet: 19377)") + "\n" +
" -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 200)") + "\n" +
@ -339,7 +338,7 @@ std::string HelpMessage() @@ -339,7 +338,7 @@ std::string HelpMessage()
" -connect=<ip> " + _("Connect only to the specified node(s)") + "\n" +
" -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n" +
" -externalip=<ip> " + _("Specify your own public address") + "\n" +
" -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4, IPv6, I2P or Tor)") + "\n" +
" -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4, IPv6 or I2P") + "\n" +
" -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n" +
" -checkpoints " + _("Only accept block chain matching built-in checkpoints (default: 1)") + "\n" +
" -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n" +
@ -851,19 +850,6 @@ bool AppInit2(boost::thread_group& threadGroup) @@ -851,19 +850,6 @@ bool AppInit2(boost::thread_group& threadGroup)
fProxy = true;
}
// -tor can override normal proxy, -notor disables tor entirely
if (!(mapArgs.count("-tor") && mapArgs["-tor"] == "0") && (fProxy || mapArgs.count("-tor"))) {
CService addrOnion;
if (!mapArgs.count("-tor"))
addrOnion = addrProxy;
else
addrOnion = CService(mapArgs["-tor"], 9050);
if (!addrOnion.IsValid())
return InitError(strprintf(_("Invalid -tor address: '%s'"), mapArgs["-tor"].c_str()));
SetProxy(NET_TOR, addrOnion, 5);
SetReachable(NET_TOR);
}
// see Step 2: parameter interactions for more information about these
fNoListen = !GetBoolArg("-listen", true);
fDiscover = true; //GetBoolArg("-discover", true); TODO

39
src/netbase.cpp

@ -31,7 +31,6 @@ enum Network ParseNetwork(std::string net) { @@ -31,7 +31,6 @@ enum Network ParseNetwork(std::string net) {
boost::to_lower(net);
if (net == "ipv4") return NET_IPV4;
if (net == "ipv6") return NET_IPV6;
if (net == "tor") return NET_TOR;
if (net == NATIVE_I2P_NET_STRING) return NET_NATIVE_I2P;
return NET_UNROUTABLE;
}
@ -586,7 +585,6 @@ void CNetAddr::SetIP(const CNetAddr& ipIn) @@ -586,7 +585,6 @@ void CNetAddr::SetIP(const CNetAddr& ipIn)
memcpy(i2pDest, ipIn.i2pDest, NATIVE_I2P_DESTINATION_SIZE);
}
static const unsigned char pchOnionCat[] = {0xFD,0x87,0xD8,0x7E,0xEB,0x43};
bool CNetAddr::SetSpecial(const std::string &strName)
{
@ -597,15 +595,6 @@ bool CNetAddr::SetSpecial(const std::string &strName) @@ -597,15 +595,6 @@ bool CNetAddr::SetSpecial(const std::string &strName)
memcpy(i2pDest, addr.c_str(), NATIVE_I2P_DESTINATION_SIZE);
return true;
}
if (strName.size()>6 && strName.substr(strName.size() - 6, 6) == ".onion") {
std::vector<unsigned char> vchAddr = DecodeBase32(strName.substr(0, strName.size() - 6).c_str());
if (vchAddr.size() != 16-sizeof(pchOnionCat))
return false;
memcpy(ip, pchOnionCat, sizeof(pchOnionCat));
for (unsigned int i=0; i<16-sizeof(pchOnionCat); i++)
ip[i + sizeof(pchOnionCat)] = vchAddr[i];
return true;
}
return false;
}
@ -657,7 +646,7 @@ bool CNetAddr::IsIPv4() const @@ -657,7 +646,7 @@ bool CNetAddr::IsIPv4() const
bool CNetAddr::IsIPv6() const
{
return (!IsIPv4() && !IsTor() && !IsNativeI2P());
return (!IsIPv4() && !IsNativeI2P());
}
bool CNetAddr::IsRFC1918() const
@ -716,10 +705,6 @@ bool CNetAddr::IsRFC4843() const @@ -716,10 +705,6 @@ bool CNetAddr::IsRFC4843() const
return (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x00 && (GetByte(12) & 0xF0) == 0x10);
}
bool CNetAddr::IsTor() const
{
return (memcmp(ip, pchOnionCat, sizeof(pchOnionCat)) == 0);
}
bool CNetAddr::IsNativeI2P() const
{
@ -794,7 +779,7 @@ bool CNetAddr::IsValid() const @@ -794,7 +779,7 @@ bool CNetAddr::IsValid() const
bool CNetAddr::IsRoutable() const
{
return IsValid() && !(IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193() && !IsTor()) || IsRFC4843() || IsLocal());
return IsValid() && !(IsRFC1918() || IsRFC3927() || IsRFC4862() || (IsRFC4193()) || IsRFC4843() || IsLocal());
}
enum Network CNetAddr::GetNetwork() const
@ -805,9 +790,6 @@ enum Network CNetAddr::GetNetwork() const @@ -805,9 +790,6 @@ enum Network CNetAddr::GetNetwork() const
if (IsIPv4())
return NET_IPV4;
if (IsTor())
return NET_TOR;
if (IsNativeI2P())
return NET_NATIVE_I2P;
@ -818,8 +800,6 @@ std::string CNetAddr::ToStringIP() const @@ -818,8 +800,6 @@ std::string CNetAddr::ToStringIP() const
{
if (IsNativeI2P())
return GetI2PDestination();
if (IsTor())
return EncodeBase32(&ip[6], 10) + ".onion";
CService serv(*this, 0);
#ifdef USE_IPV6
struct sockaddr_storage sockaddr;
@ -931,12 +911,6 @@ std::vector<unsigned char> CNetAddr::GetGroup() const @@ -931,12 +911,6 @@ std::vector<unsigned char> CNetAddr::GetGroup() const
vchRet.push_back(GetByte(2) ^ 0xFF);
return vchRet;
}
else if (IsTor())
{
nClass = NET_TOR;
nStartByte = 6;
nBits = 4;
}
// for he.net, use /36 groups
else if (GetByte(15) == 0x20 && GetByte(14) == 0x01 && GetByte(13) == 0x04 && GetByte(12) == 0x70)
nBits = 36;
@ -1016,12 +990,6 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const @@ -1016,12 +990,6 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
case NET_IPV4: return REACH_IPV4;
case NET_IPV6: return fTunnel ? REACH_IPV6_WEAK : REACH_IPV6_STRONG; // only prefer giving our IPv6 address if it's not tunnelled
}
case NET_TOR:
switch(ourNet) {
default: return REACH_DEFAULT;
case NET_IPV4: return REACH_IPV4; // Tor users can connect to IPv4 as well
case NET_TOR: return REACH_PRIVATE;
}
case NET_NATIVE_I2P:
switch(ourNet) {
default: return REACH_UNREACHABLE;
@ -1042,7 +1010,6 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const @@ -1042,7 +1010,6 @@ int CNetAddr::GetReachabilityFrom(const CNetAddr *paddrPartner) const
case NET_TEREDO: return REACH_TEREDO;
case NET_IPV6: return REACH_IPV6_WEAK;
case NET_IPV4: return REACH_IPV4;
case NET_TOR: return REACH_PRIVATE; // either from Tor, or don't care about our address
case NET_NATIVE_I2P: return REACH_UNREACHABLE;
}
}
@ -1206,7 +1173,7 @@ std::string CService::ToStringPort() const @@ -1206,7 +1173,7 @@ std::string CService::ToStringPort() const
std::string CService::ToStringIPPort() const
{
if (IsIPv4() || IsTor()) {
if (IsIPv4()) {
return ToStringIP() + ":" + ToStringPort();
} else {
return "[" + ToStringIP() + "]:" + ToStringPort();

6
src/netbase.h

@ -26,7 +26,6 @@ enum Network @@ -26,7 +26,6 @@ enum Network
NET_UNROUTABLE,
NET_IPV4,
NET_IPV6,
NET_TOR,
NET_NATIVE_I2P,
NET_MAX,
};
@ -48,9 +47,9 @@ class CNetAddr @@ -48,9 +47,9 @@ class CNetAddr
explicit CNetAddr(const std::string &strIp, bool fAllowLookup = false);
void Init();
void SetIP(const CNetAddr& ip);
bool SetSpecial(const std::string &strName); // for Tor addresses
bool SetSpecial(const std::string &strName); // for I2P addresses
bool IsIPv4() const; // IPv4 mapped address (::FFFF:0:0/96, 0.0.0.0/0)
bool IsIPv6() const; // IPv6 address (not mapped IPv4, not Tor)
bool IsIPv6() const; // IPv6 address (not mapped IPv4, not I2P)
bool IsRFC1918() const; // IPv4 private networks (10.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12)
bool IsRFC3849() const; // IPv6 documentation address (2001:0DB8::/32)
bool IsRFC3927() const; // IPv4 autoconfig (169.254.0.0/16)
@ -61,7 +60,6 @@ class CNetAddr @@ -61,7 +60,6 @@ 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 IsTor() const;
bool IsLocal() const;
bool IsRoutable() const;
bool IsValid() const;

Loading…
Cancel
Save