| 463 | int GetConnectTime() { return SysCfg().GetConnectTimeOut(); } |
| 464 | |
| 465 | bool ConnectSocket(const CService& addrDest, SOCKET& hSocketRet, int nTimeout) { |
| 466 | ProxyType proxy; |
| 467 | |
| 468 | // no proxy needed |
| 469 | if (!GetProxy(addrDest.GetNetwork(), proxy)) |
| 470 | return ConnectSocketDirectly(addrDest, hSocketRet, nTimeout); |
| 471 | |
| 472 | SOCKET hSocket = INVALID_SOCKET; |
| 473 | |
| 474 | // first connect to proxy server |
| 475 | if (!ConnectSocketDirectly(proxy.first, hSocket, nTimeout)) |
| 476 | return false; |
| 477 | |
| 478 | // do socks negotiation |
| 479 | switch (proxy.second) { |
| 480 | case 4: |
| 481 | if (!Socks4(addrDest, hSocket)) |
| 482 | return false; |
| 483 | break; |
| 484 | case 5: |
| 485 | if (!Socks5(addrDest.ToStringIP(), addrDest.GetPort(), hSocket)) |
| 486 | return false; |
| 487 | break; |
| 488 | default: |
| 489 | closesocket(hSocket); |
| 490 | return false; |
| 491 | } |
| 492 | |
| 493 | hSocketRet = hSocket; |
| 494 | return true; |
| 495 | } |
| 496 | |
| 497 | bool ConnectSocketByName(CService& addr, SOCKET& hSocketRet, const char* pszDest, int portDefault, int nTimeout) { |
| 498 | string strDest; |
no test coverage detected