MCPcopy Create free account
hub / github.com/LUX-Core/lux / ConnectSocketByName

Function ConnectSocketByName

src/netbase.cpp:567–604  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

565}
566
567bool ConnectSocketByName(CService& addr, SOCKET& hSocketRet, const char* pszDest, int portDefault, int nTimeout, bool* outProxyConnectionFailed)
568{
569 string strDest;
570 int port = portDefault;
571
572 if (outProxyConnectionFailed)
573 *outProxyConnectionFailed = false;
574
575 SplitHostPort(string(pszDest), port, strDest);
576
577 SOCKET hSocket = INVALID_SOCKET;
578
579 CService proxy;
580 GetNameProxy(proxy);
581
582 CService addrResolved(CNetAddr(strDest, fNameLookup && !HaveNameProxy()), port);
583 if (addrResolved.IsValid()) {
584 addr = addrResolved;
585 return ConnectSocket(addr, hSocketRet, nTimeout);
586 }
587
588 addr = CService("0.0.0.0:0");
589
590 if (!HaveNameProxy())
591 return false;
592 // first connect to name proxy server
593 if (!ConnectSocketDirectly(proxy, hSocket, nTimeout)) {
594 if (outProxyConnectionFailed)
595 *outProxyConnectionFailed = true;
596 return false;
597 }
598 // do socks negotiation
599 if (!Socks5(strDest, (unsigned short)port, hSocket))
600 return false;
601
602 hSocketRet = hSocket;
603 return true;
604}
605
606void CNetAddr::Init()
607{

Callers 1

ConnectNodeFunction · 0.85

Calls 9

SplitHostPortFunction · 0.85
GetNameProxyFunction · 0.85
HaveNameProxyFunction · 0.85
ConnectSocketFunction · 0.85
ConnectSocketDirectlyFunction · 0.85
Socks5Function · 0.85
CNetAddrClass · 0.70
CServiceClass · 0.70
IsValidMethod · 0.45

Tested by

no test coverage detected