mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
Add -proxytoo option, which allows proxy use non-exclusively, unlike the -proxy option.
Conflicts: src/init.cpp src/netbase.cpp Conflicts: .gitignore src/init.cpp Conflicts: src/init.cpp src/netbase.cpp
This commit is contained in:
parent
6afc2e7b23
commit
4fcaa57368
20
src/init.cpp
20
src/init.cpp
@ -304,7 +304,8 @@ std::string HelpMessage()
|
||||
" -datadir=<dir> " + _("Specify data directory") + "\n" +
|
||||
" -dbcache=<n> " + _("Set database cache size in megabytes (default: 25)") + "\n" +
|
||||
" -timeout=<n> " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n" +
|
||||
" -proxy=<ip:port> " + _("Connect through socks proxy") + "\n" +
|
||||
" -proxy=<ip:port> " + _("Exclusively connect through socks proxy") + "\n" +
|
||||
" -proxytoo=<ip:port> " + _("Also 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" +
|
||||
@ -788,6 +789,23 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||
SetReachable(NET_TOR);
|
||||
}
|
||||
|
||||
if (mapArgs.count("-proxytoo")) {
|
||||
fProxyToo = true;
|
||||
CService addrProxy = CService(mapArgs["-proxytoo"], 9050);
|
||||
if (!addrProxy.IsValid())
|
||||
return InitError(strprintf(_("Invalid -proxytoo address: '%s'"), mapArgs["-proxytoo"].c_str()));
|
||||
|
||||
if (!IsLimited(NET_IPV4))
|
||||
SetProxy(NET_IPV4, addrProxy, nSocksVersion);
|
||||
if (nSocksVersion > 4) {
|
||||
#ifdef USE_IPV6
|
||||
if (!IsLimited(NET_IPV6))
|
||||
SetProxy(NET_IPV6, addrProxy, nSocksVersion);
|
||||
#endif
|
||||
SetNameProxy(addrProxy, nSocksVersion);
|
||||
}
|
||||
}
|
||||
|
||||
// see Step 2: parameter interactions for more information about these
|
||||
fNoListen = !GetBoolArg("-listen", true);
|
||||
fDiscover = GetBoolArg("-discover", true);
|
||||
|
@ -21,6 +21,7 @@ using namespace std;
|
||||
static proxyType proxyInfo[NET_MAX];
|
||||
static proxyType nameproxyInfo;
|
||||
static CCriticalSection cs_proxyInfos;
|
||||
int fProxyToo = false;
|
||||
int nConnectTimeout = 5000;
|
||||
bool fNameLookup = false;
|
||||
|
||||
@ -475,7 +476,7 @@ bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout)
|
||||
proxyType proxy;
|
||||
|
||||
// no proxy needed
|
||||
if (!GetProxy(addrDest.GetNetwork(), proxy))
|
||||
if (!GetProxy(addrDest.GetNetwork(), proxy) || (fProxyToo && rand() %2 == 0))
|
||||
return ConnectSocketDirectly(addrDest, hSocketRet, nTimeout);
|
||||
|
||||
SOCKET hSocket = INVALID_SOCKET;
|
||||
|
@ -148,4 +148,6 @@ bool LookupNumeric(const char *pszName, CService& addr, int portDefault = 0);
|
||||
bool ConnectSocket(const CService &addr, SOCKET& hSocketRet, int nTimeout = nConnectTimeout);
|
||||
bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault = 0, int nTimeout = nConnectTimeout);
|
||||
|
||||
// Settings
|
||||
extern int fProxyToo;
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user