Add -tor and related configuration
This commit is contained in:
parent
d077dd2a6e
commit
54ce3bad64
3 changed files with 30 additions and 6 deletions
23
src/init.cpp
23
src/init.cpp
|
@ -222,6 +222,7 @@ std::string HelpMessage()
|
||||||
" -timeout=<n> " + _("Specify connection timeout (in milliseconds)") + "\n" +
|
" -timeout=<n> " + _("Specify connection timeout (in milliseconds)") + "\n" +
|
||||||
" -proxy=<ip:port> " + _("Connect through socks proxy") + "\n" +
|
" -proxy=<ip:port> " + _("Connect through socks proxy") + "\n" +
|
||||||
" -socks=<n> " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\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" +
|
" -dns " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n" +
|
||||||
" -port=<port> " + _("Listen for connections on <port> (default: 8333 or testnet: 18333)") + "\n" +
|
" -port=<port> " + _("Listen for connections on <port> (default: 8333 or testnet: 18333)") + "\n" +
|
||||||
" -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 125)") + "\n" +
|
" -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 125)") + "\n" +
|
||||||
|
@ -229,12 +230,12 @@ std::string HelpMessage()
|
||||||
" -connect=<ip> " + _("Connect only to the specified node(s)") + "\n" +
|
" -connect=<ip> " + _("Connect only to the specified node(s)") + "\n" +
|
||||||
" -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n" +
|
" -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n" +
|
||||||
" -externalip=<ip> " + _("Specify your own public address") + "\n" +
|
" -externalip=<ip> " + _("Specify your own public address") + "\n" +
|
||||||
" -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4 or IPv6)") + "\n" +
|
" -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4, IPv6 or Tor)") + "\n" +
|
||||||
" -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n" +
|
" -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n" +
|
||||||
" -irc " + _("Find peers using internet relay chat (default: 0)") + "\n" +
|
" -irc " + _("Find peers using internet relay chat (default: 0)") + "\n" +
|
||||||
" -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n" +
|
" -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n" +
|
||||||
" -bind=<addr> " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n" +
|
" -bind=<addr> " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n" +
|
||||||
" -dnsseed " + _("Find peers using DNS lookup (default: 1)") + "\n" +
|
" -dnsseed " + _("Find peers using DNS lookup (default: 1 unless -connect)") + "\n" +
|
||||||
" -banscore=<n> " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" +
|
" -banscore=<n> " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" +
|
||||||
" -bantime=<n> " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" +
|
" -bantime=<n> " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" +
|
||||||
" -maxreceivebuffer=<n> " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 10000)") + "\n" +
|
" -maxreceivebuffer=<n> " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 10000)") + "\n" +
|
||||||
|
@ -469,8 +470,10 @@ bool AppInit2()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CService addrProxy;
|
||||||
|
bool fProxy = false;
|
||||||
if (mapArgs.count("-proxy")) {
|
if (mapArgs.count("-proxy")) {
|
||||||
CService addrProxy = CService(mapArgs["-proxy"], 9050);
|
addrProxy = CService(mapArgs["-proxy"], 9050);
|
||||||
if (!addrProxy.IsValid())
|
if (!addrProxy.IsValid())
|
||||||
return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"].c_str()));
|
return InitError(strprintf(_("Invalid -proxy address: '%s'"), mapArgs["-proxy"].c_str()));
|
||||||
|
|
||||||
|
@ -483,6 +486,20 @@ bool AppInit2()
|
||||||
#endif
|
#endif
|
||||||
SetNameProxy(addrProxy, nSocksVersion);
|
SetNameProxy(addrProxy, nSocksVersion);
|
||||||
}
|
}
|
||||||
|
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
|
// see Step 2: parameter interactions for more information about these
|
||||||
|
|
12
src/net.cpp
12
src/net.cpp
|
@ -206,6 +206,14 @@ void static AdvertizeLocal()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetReachable(enum Network net, bool fFlag)
|
||||||
|
{
|
||||||
|
LOCK(cs_mapLocalHost);
|
||||||
|
vfReachable[net] = fFlag;
|
||||||
|
if (net == NET_IPV6 && fFlag)
|
||||||
|
vfReachable[NET_IPV4] = true;
|
||||||
|
}
|
||||||
|
|
||||||
// learn a new local address
|
// learn a new local address
|
||||||
bool AddLocal(const CService& addr, int nScore)
|
bool AddLocal(const CService& addr, int nScore)
|
||||||
{
|
{
|
||||||
|
@ -228,9 +236,7 @@ bool AddLocal(const CService& addr, int nScore)
|
||||||
info.nScore = nScore;
|
info.nScore = nScore;
|
||||||
info.nPort = addr.GetPort() + (fAlready ? 1 : 0);
|
info.nPort = addr.GetPort() + (fAlready ? 1 : 0);
|
||||||
}
|
}
|
||||||
enum Network net = addr.GetNetwork();
|
SetReachable(addr.GetNetwork());
|
||||||
vfReachable[net] = true;
|
|
||||||
if (net == NET_IPV6) vfReachable[NET_IPV4] = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AdvertizeLocal();
|
AdvertizeLocal();
|
||||||
|
|
|
@ -64,6 +64,7 @@ bool SeenLocal(const CService& addr);
|
||||||
bool IsLocal(const CService& addr);
|
bool IsLocal(const CService& addr);
|
||||||
bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL);
|
bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL);
|
||||||
bool IsReachable(const CNetAddr &addr);
|
bool IsReachable(const CNetAddr &addr);
|
||||||
|
void SetReachable(enum Network net, bool fFlag = true);
|
||||||
CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL);
|
CAddress GetLocalAddress(const CNetAddr *paddrPeer = NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue