| 540 | } |
| 541 | |
| 542 | bool ConnectSocket(const CService& addrDest, SOCKET& hSocketRet, int nTimeout, bool* outProxyConnectionFailed) |
| 543 | { |
| 544 | proxyType proxy; |
| 545 | if (outProxyConnectionFailed) |
| 546 | *outProxyConnectionFailed = false; |
| 547 | // no proxy needed (none set for target network) |
| 548 | if (!GetProxy(addrDest.GetNetwork(), proxy)) |
| 549 | return ConnectSocketDirectly(addrDest, hSocketRet, nTimeout); |
| 550 | |
| 551 | SOCKET hSocket = INVALID_SOCKET; |
| 552 | |
| 553 | // first connect to proxy server |
| 554 | if (!ConnectSocketDirectly(proxy, hSocket, nTimeout)) { |
| 555 | if (outProxyConnectionFailed) |
| 556 | *outProxyConnectionFailed = true; |
| 557 | return false; |
| 558 | } |
| 559 | // do socks negotiation |
| 560 | if (!Socks5(addrDest.ToStringIP(), addrDest.GetPort(), hSocket)) |
| 561 | return false; |
| 562 | |
| 563 | hSocketRet = hSocket; |
| 564 | return true; |
| 565 | } |
| 566 | |
| 567 | bool ConnectSocketByName(CService& addr, SOCKET& hSocketRet, const char* pszDest, int portDefault, int nTimeout, bool* outProxyConnectionFailed) |
| 568 | { |
no test coverage detected