5#ifndef BITCOIN_NETBASE_H
6#define BITCOIN_NETBASE_H
8#if defined(HAVE_CONFIG_H)
9#include <config/bitcoin-config.h>
41 using underlying =
typename std::underlying_type<ConnectionDirection>::type;
47 using underlying =
typename std::underlying_type<ConnectionDirection>::type;
48 return (underlying(a) & underlying(b));
55 bool _randomize_credentials =
false)
83std::vector<std::string>
GetNetworkNames(
bool append_unroutable =
false);
109 std::function<std::vector<CNetAddr>(
const std::string &,
bool)>;
127bool LookupHost(
const std::string &
name, std::vector<CNetAddr> &vIP,
128 unsigned int nMaxSolutions,
bool fAllowLookup,
160bool Lookup(
const std::string &
name, std::vector<CService> &vAddr,
161 uint16_t portDefault,
bool fAllowLookup,
unsigned int nMaxSolutions,
228 int nTimeout,
bool manual_connection);
246 uint16_t port,
const Sock &sock,
int nTimeout,
247 bool &outProxyConnectionFailed);
255bool Socks5(
const std::string &strDest, uint16_t port,
A combination of a network address (CNetAddr) and a (TCP) port.
RAII helper class that manages a socket.
bool randomize_credentials
proxyType(const CService &_proxy, bool _randomize_credentials=false)
bool GetNameProxy(proxyType &nameProxyOut)
static const int DEFAULT_NAME_LOOKUP
-dns default
std::string GetNetworkName(enum Network net)
bool LookupHost(const std::string &name, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function=g_dns_lookup)
Resolve a host string to its corresponding network addresses.
bool GetProxy(enum Network net, proxyType &proxyInfoOut)
bool SetSocketNoDelay(const SOCKET &hSocket)
Set the TCP_NODELAY flag on a socket.
bool ConnectThroughProxy(const proxyType &proxy, const std::string &strDest, uint16_t port, const Sock &sock, int nTimeout, bool &outProxyConnectionFailed)
Connect to a specified destination service through a SOCKS5 proxy by first connecting to the SOCKS5 p...
std::vector< std::string > GetNetworkNames(bool append_unroutable=false)
Return a vector of publicly routable Network names; optionally append NET_UNROUTABLE.
void InterruptSocks5(bool interrupt)
std::unique_ptr< Sock > CreateSockTCP(const CService &address_family)
Create a TCP socket in the given address family.
std::function< std::unique_ptr< Sock >(const CService &)> CreateSock
Socket factory.
bool ConnectSocketDirectly(const CService &addrConnect, const Sock &sock, int nTimeout, bool manual_connection)
Try to connect to the specified service on the specified socket.
CService LookupNumeric(const std::string &name, uint16_t portDefault=0, DNSLookupFn dns_lookup_function=g_dns_lookup)
Resolve a service string with a numeric IP to its first corresponding service.
static bool operator&(ConnectionDirection a, ConnectionDirection b)
bool LookupSubNet(const std::string &strSubnet, CSubNet &subnet, DNSLookupFn dns_lookup_function=g_dns_lookup)
Parse and resolve a specified subnet string into the appropriate internal representation.
bool SetNameProxy(const proxyType &addrProxy)
Set the name proxy to use for all connections to nodes specified by a hostname.
static ConnectionDirection & operator|=(ConnectionDirection &a, ConnectionDirection b)
enum Network ParseNetwork(const std::string &net)
bool SetSocketNonBlocking(const SOCKET &hSocket, bool fNonBlocking)
Disable or enable blocking-mode for a socket.
bool IsProxy(const CNetAddr &addr)
bool Lookup(const std::string &name, std::vector< CService > &vAddr, uint16_t portDefault, bool fAllowLookup, unsigned int nMaxSolutions, DNSLookupFn dns_lookup_function=g_dns_lookup)
Resolve a service string to its corresponding service.
bool IsBadPort(uint16_t port)
Determine if a port is "bad" from the perspective of attempting to connect to a node on that port.
std::vector< CNetAddr > WrappedGetAddrInfo(const std::string &name, bool allow_lookup)
Wrapper for getaddrinfo(3).
std::function< std::vector< CNetAddr >(const std::string &, bool)> DNSLookupFn
static const int DEFAULT_CONNECT_TIMEOUT
-timeout default
bool Socks5(const std::string &strDest, uint16_t port, const ProxyCredentials *auth, const Sock &socket)
Connect to a specified destination service through an already connected SOCKS5 proxy.
bool SetProxy(enum Network net, const proxyType &addrProxy)
Credentials for proxy authentication.