MCPcopy Create free account
hub / github.com/ElementsProject/elements / ConnectThroughProxy

Function ConnectThroughProxy

src/netbase.cpp:656–677  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

654}
655
656bool ConnectThroughProxy(const Proxy& proxy, const std::string& strDest, uint16_t port, const Sock& sock, int nTimeout, bool& outProxyConnectionFailed)
657{
658 // first connect to proxy server
659 if (!ConnectSocketDirectly(proxy.proxy, sock, nTimeout, true)) {
660 outProxyConnectionFailed = true;
661 return false;
662 }
663 // do socks negotiation
664 if (proxy.randomize_credentials) {
665 ProxyCredentials random_auth;
666 static std::atomic_int counter(0);
667 random_auth.username = random_auth.password = strprintf("%i", counter++);
668 if (!Socks5(strDest, port, &random_auth, sock)) {
669 return false;
670 }
671 } else {
672 if (!Socks5(strDest, port, 0, sock)) {
673 return false;
674 }
675 }
676 return true;
677}
678
679bool LookupSubNet(const std::string& subnet_str, CSubNet& subnet_out)
680{

Callers 1

ConnectNodeMethod · 0.85

Calls 2

ConnectSocketDirectlyFunction · 0.85
Socks5Function · 0.85

Tested by

no test coverage detected