mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-01 05:42:17 +01:00
-BEGIN VERIFY SCRIPT- for f in \ src/*.cpp \ src/*.h \ src/bench/*.cpp \ src/bench/*.h \ src/compat/*.cpp \ src/compat/*.h \ src/consensus/*.cpp \ src/consensus/*.h \ src/crypto/*.cpp \ src/crypto/*.h \ src/crypto/ctaes/*.h \ src/policy/*.cpp \ src/policy/*.h \ src/primitives/*.cpp \ src/primitives/*.h \ src/qt/*.cpp \ src/qt/*.h \ src/qt/test/*.cpp \ src/qt/test/*.h \ src/rpc/*.cpp \ src/rpc/*.h \ src/script/*.cpp \ src/script/*.h \ src/support/*.cpp \ src/support/*.h \ src/support/allocators/*.h \ src/test/*.cpp \ src/test/*.h \ src/wallet/*.cpp \ src/wallet/*.h \ src/wallet/test/*.cpp \ src/wallet/test/*.h \ src/zmq/*.cpp \ src/zmq/*.h do base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f done -END VERIFY SCRIPT-
70 lines
2.6 KiB
C++
70 lines
2.6 KiB
C++
// Copyright (c) 2009-2016 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_NETBASE_H
|
|
#define BITCOIN_NETBASE_H
|
|
|
|
#if defined(HAVE_CONFIG_H)
|
|
#include <config/bitcoin-config.h>
|
|
#endif
|
|
|
|
#include <compat.h>
|
|
#include <netaddress.h>
|
|
#include <serialize.h>
|
|
|
|
#include <stdint.h>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
extern int nConnectTimeout;
|
|
extern bool fNameLookup;
|
|
|
|
//! -timeout default
|
|
static const int DEFAULT_CONNECT_TIMEOUT = 5000;
|
|
//! -dns default
|
|
static const int DEFAULT_NAME_LOOKUP = true;
|
|
|
|
class proxyType
|
|
{
|
|
public:
|
|
proxyType(): randomize_credentials(false) {}
|
|
explicit proxyType(const CService &_proxy, bool _randomize_credentials=false): proxy(_proxy), randomize_credentials(_randomize_credentials) {}
|
|
|
|
bool IsValid() const { return proxy.IsValid(); }
|
|
|
|
CService proxy;
|
|
bool randomize_credentials;
|
|
};
|
|
|
|
enum Network ParseNetwork(std::string net);
|
|
std::string GetNetworkName(enum Network net);
|
|
bool SetProxy(enum Network net, const proxyType &addrProxy);
|
|
bool GetProxy(enum Network net, proxyType &proxyInfoOut);
|
|
bool IsProxy(const CNetAddr &addr);
|
|
bool SetNameProxy(const proxyType &addrProxy);
|
|
bool HaveNameProxy();
|
|
bool GetNameProxy(proxyType &nameProxyOut);
|
|
bool LookupHost(const char *pszName, std::vector<CNetAddr>& vIP, unsigned int nMaxSolutions, bool fAllowLookup);
|
|
bool LookupHost(const char *pszName, CNetAddr& addr, bool fAllowLookup);
|
|
bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLookup);
|
|
bool Lookup(const char *pszName, std::vector<CService>& vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions);
|
|
CService LookupNumeric(const char *pszName, int portDefault = 0);
|
|
bool LookupSubNet(const char *pszName, CSubNet& subnet);
|
|
bool ConnectSocketDirectly(const CService &addrConnect, SOCKET& hSocketRet, int nTimeout);
|
|
bool ConnectThroughProxy(const proxyType &proxy, const std::string& strDest, int port, SOCKET& hSocketRet, int nTimeout, bool *outProxyConnectionFailed);
|
|
/** Return readable error string for a network error code */
|
|
std::string NetworkErrorString(int err);
|
|
/** Close socket and set hSocket to INVALID_SOCKET */
|
|
bool CloseSocket(SOCKET& hSocket);
|
|
/** Disable or enable blocking-mode for a socket */
|
|
bool SetSocketNonBlocking(const SOCKET& hSocket, bool fNonBlocking);
|
|
/** Set the TCP_NODELAY flag on a socket */
|
|
bool SetSocketNoDelay(const SOCKET& hSocket);
|
|
/**
|
|
* Convert milliseconds to a struct timeval for e.g. select.
|
|
*/
|
|
struct timeval MillisToTimeval(int64_t nTimeout);
|
|
void InterruptSocks5(bool interrupt);
|
|
|
|
#endif // BITCOIN_NETBASE_H
|