src/netbase.cpp
bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, const SOCKET& hSocket, int nTimeout, bool& outProxyConnectionFailed)
{
    // first connect to proxy server
    if (!ConnectSocketDirectly(proxy.proxy, hSocket, nTimeout, true)) {
        outProxyConnectionFailed = true;
        return false;
    }
    // do socks negotiation
    if (proxy.randomize_credentials) {
        ProxyCredentials random_auth;
        static std::atomic_int counter(0);
        random_auth.username = random_auth.password = strprintf("%i", counter++);
        if (!Socks5(strDest, (unsigned short)port, &random_auth, hSocket)) {
            return false;
        }
    } else {
        if (!Socks5(strDest, (unsigned short)port, 0, hSocket)) {
            return false;
        }
    }
    return true;
}
/**
 * Connect to a specified destination service through a SOCKS5 proxy by first
 * connecting to the SOCKS5 proxy.
 *
 * @param proxy The SOCKS5 proxy.
 * @param strDest The destination service to which to connect.
 * @param port The destination port.
 * @param hSocket The socket on which to connect to the SOCKS5 proxy.
 * @param nTimeout Wait this many milliseconds for the connection to the SOCKS5
 *                 proxy to be established.
 * @param[out] outProxyConnectionFailed Whether or not the connection to the
 *                                      SOCKS5 proxy failed.
 *
 * @returns Whether or not the operation succeeded.
 */
Connect to a specified destination service through a SOCKS5 proxy by first
connecting to the SOCKS5 proxy.

@param proxy The SOCKS5 proxy.
@param strDest The destination service to which to connect.
@param port The destination port.
@param hSocket The socket on which to connect to the SOCKS5 proxy.
@param nTimeout Wait this many milliseconds for the connection to the SOCKS5
proxy to be established.
@param[out] outProxyConnectionFailed Whether or not the connection to the
SOCKS5 proxy failed.

@returns Whether or not the operation succeeded.
Connect to a specified destination service through a SOCKS5 proxy by first connecting to the SOCKS5 proxy . @param proxy The SOCKS5 proxy . @param strDest The destination service to which to connect . @param port The destination port . @param hSocket The socket on which to connect to the SOCKS5 proxy . @param nTimeout Wait this many milliseconds for the connection to the SOCKS5 proxy to be established . @param [ out ] outProxyConnectionFailed Whether or not the connection to the SOCKS5 proxy failed . @returns Whether or not the operation succeeded .
bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, const SOCKET& hSocket, int nTimeout, bool& outProxyConnectionFailed)
{
    if (!ConnectSocketDirectly(proxy.proxy, hSocket, nTimeout, true)) {
        outProxyConnectionFailed = true;
        return false;
    }
    if (proxy.randomize_credentials) {
        ProxyCredentials random_auth;
        static std::atomic_int counter(0);
        random_auth.username = random_auth.password = strprintf("%i", counter++);
        if (!Socks5(strDest, (unsigned short)port, &random_auth, hSocket)) {
            return false;
        }
    } else {
        if (!Socks5(strDest, (unsigned short)port, 0, hSocket)) {
            return false;
        }
    }
    return true;
}
bool ConnectThroughProxy ( const proxyType & proxy , const std :: string & strDest , int port , const SOCKET & hSocket , int nTimeout , bool & outProxyConnectionFailed ) { if ( ! ConnectSocketDirectly ( proxy . proxy , hSocket , nTimeout , true ) ) { outProxyConnectionFailed = true ; return false ; } if ( proxy . randomize_credentials ) { ProxyCredentials random_auth ; static std :: atomic_int counter ( 0 ) ; random_auth . username = random_auth . password = strprintf ( " " , counter ++ ) ; if ( ! Socks5 ( strDest , ( unsigned short ) port , & random_auth , hSocket ) ) { return false ; } } else { if ( ! Socks5 ( strDest , ( unsigned short ) port , 0 , hSocket ) ) { return false ; } } return true ; }
Connect to a specified destination service through a SOCKS5 proxy by first
 connecting to the SOCKS5 proxy.
Connect to a specified destination service through a SOCKS5 proxy by first connecting to the SOCKS5 proxy .
// first connect to proxy server // do socks negotiation