@@ -519,18 +519,23 @@ bool IsProxy(const CNetAddr &addr) {
519
519
return false ;
520
520
}
521
521
522
- bool ConnectSocket (const CService &addrDest, SOCKET& hSocketRet, int nTimeout)
522
+ bool ConnectSocket (const CService &addrDest, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed )
523
523
{
524
524
proxyType proxy;
525
+ if (outProxyConnectionFailed)
526
+ *outProxyConnectionFailed = false ;
525
527
// no proxy needed (none set for target network)
526
528
if (!GetProxy (addrDest.GetNetwork (), proxy))
527
529
return ConnectSocketDirectly (addrDest, hSocketRet, nTimeout);
528
530
529
531
SOCKET hSocket = INVALID_SOCKET;
530
532
531
533
// first connect to proxy server
532
- if (!ConnectSocketDirectly (proxy, hSocket, nTimeout))
534
+ if (!ConnectSocketDirectly (proxy, hSocket, nTimeout)) {
535
+ if (outProxyConnectionFailed)
536
+ *outProxyConnectionFailed = true ;
533
537
return false ;
538
+ }
534
539
// do socks negotiation
535
540
if (!Socks5 (addrDest.ToStringIP (), addrDest.GetPort (), hSocket))
536
541
return false ;
@@ -539,10 +544,14 @@ bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout)
539
544
return true ;
540
545
}
541
546
542
- bool ConnectSocketByName (CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout)
547
+ bool ConnectSocketByName (CService &addr, SOCKET& hSocketRet, const char *pszDest, int portDefault, int nTimeout, bool *outProxyConnectionFailed )
543
548
{
544
549
string strDest;
545
550
int port = portDefault;
551
+
552
+ if (outProxyConnectionFailed)
553
+ *outProxyConnectionFailed = false ;
554
+
546
555
SplitHostPort (string (pszDest), port, strDest);
547
556
548
557
SOCKET hSocket = INVALID_SOCKET;
@@ -561,8 +570,11 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest
561
570
if (!HaveNameProxy ())
562
571
return false ;
563
572
// first connect to name proxy server
564
- if (!ConnectSocketDirectly (nameProxy, hSocket, nTimeout))
573
+ if (!ConnectSocketDirectly (nameProxy, hSocket, nTimeout)) {
574
+ if (outProxyConnectionFailed)
575
+ *outProxyConnectionFailed = true ;
565
576
return false ;
577
+ }
566
578
// do socks negotiation
567
579
if (!Socks5 (strDest, (unsigned short )port, hSocket))
568
580
return false ;
0 commit comments