aboutsummaryrefslogtreecommitdiff
path: root/src/netbase.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2014-12-02 17:43:42 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2014-12-02 17:54:16 +0100
commit35e408f8a48a5406cec214c1d660e6f6a2d026f3 (patch)
treeb6d60a54e62f760266b4f854182eadf8c8438f20 /src/netbase.cpp
parent90f7aa777865864d5cf7d1f12af8ef37d851faab (diff)
Regard connection failures as attempt for addrman
This avoids connecting to them again too soon in ThreadOpenConnections. Make an exception for connection failures to the proxy as these shouldn't affect the status of specific nodes.
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r--src/netbase.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp
index aca5a107fe..053c645a1b 100644
--- a/src/netbase.cpp
+++ b/src/netbase.cpp
@@ -519,9 +519,11 @@ bool IsProxy(const CNetAddr &addr) {
return false;
}
-bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout)
+bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed)
{
proxyType proxy;
+ if (outProxyConnectionFailed)
+ *outProxyConnectionFailed = false;
// no proxy needed (none set for target network)
if (!GetProxy(addrDest.GetNetwork(), proxy))
return ConnectSocketDirectly(addrDest, hSocketRet, nTimeout);
@@ -529,8 +531,11 @@ bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout)
SOCKET hSocket = INVALID_SOCKET;
// first connect to proxy server
- if (!ConnectSocketDirectly(proxy, hSocket, nTimeout))
+ if (!ConnectSocketDirectly(proxy, hSocket, nTimeout)) {
+ if (outProxyConnectionFailed)
+ *outProxyConnectionFailed = true;
return false;
+ }
// do socks negotiation
if (!Socks5(addrDest.ToStringIP(), addrDest.GetPort(), hSocket))
return false;
@@ -539,10 +544,14 @@ bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout)
return true;
}
-bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout)
+bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout, bool *outProxyConnectionFailed)
{
string strDest;
int port = portDefault;
+
+ if (outProxyConnectionFailed)
+ *outProxyConnectionFailed = false;
+
SplitHostPort(string(pszDest), port, strDest);
SOCKET hSocket = INVALID_SOCKET;
@@ -561,8 +570,11 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest
if (!HaveNameProxy())
return false;
// first connect to name proxy server
- if (!ConnectSocketDirectly(nameProxy, hSocket, nTimeout))
+ if (!ConnectSocketDirectly(nameProxy, hSocket, nTimeout)) {
+ if (outProxyConnectionFailed)
+ *outProxyConnectionFailed = true;
return false;
+ }
// do socks negotiation
if (!Socks5(strDest, (unsigned short)port, hSocket))
return false;