Changeset View
Changeset View
Standalone View
Standalone View
src/netbase.cpp
// Copyright (c) 2009-2010 Satoshi Nakamoto | // Copyright (c) 2009-2010 Satoshi Nakamoto | ||||
// Copyright (c) 2009-2016 The Bitcoin Core developers | // Copyright (c) 2009-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <netbase.h> | #include <netbase.h> | ||||
#include <sync.h> | #include <sync.h> | ||||
#include <tinyformat.h> | #include <tinyformat.h> | ||||
#include <util/strencodings.h> | #include <util/strencodings.h> | ||||
#include <util/string.h> | #include <util/string.h> | ||||
#include <util/system.h> | #include <util/system.h> | ||||
#include <atomic> | #include <atomic> | ||||
#include <cstdint> | |||||
#ifndef WIN32 | #ifndef WIN32 | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#endif | #endif | ||||
#ifdef USE_POLL | #ifdef USE_POLL | ||||
#include <poll.h> | #include <poll.h> | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 839 Lines • ▼ Show 20 Lines | if (!ConnectSocketDirectly(proxy.proxy, hSocket, nTimeout, true)) { | ||||
return false; | return false; | ||||
} | } | ||||
// do socks negotiation | // do socks negotiation | ||||
if (proxy.randomize_credentials) { | if (proxy.randomize_credentials) { | ||||
ProxyCredentials random_auth; | ProxyCredentials random_auth; | ||||
static std::atomic_int counter(0); | static std::atomic_int counter(0); | ||||
random_auth.username = random_auth.password = | random_auth.username = random_auth.password = | ||||
strprintf("%i", counter++); | strprintf("%i", counter++); | ||||
if (!Socks5(strDest, (unsigned short)port, &random_auth, hSocket)) { | if (!Socks5(strDest, uint16_t(port), &random_auth, hSocket)) { | ||||
return false; | return false; | ||||
} | } | ||||
} else if (!Socks5(strDest, (unsigned short)port, 0, hSocket)) { | } else if (!Socks5(strDest, uint16_t(port), 0, hSocket)) { | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
/** | /** | ||||
* Parse and resolve a specified subnet string into the appropriate internal | * Parse and resolve a specified subnet string into the appropriate internal | ||||
* representation. | * representation. | ||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |