5 #ifndef BITCOIN_NETBASE_H
6 #define BITCOIN_NETBASE_H
8 #if defined(HAVE_CONFIG_H)
21 #include <type_traits>
39 using underlying =
typename std::underlying_type<ConnectionDirection>::type;
44 using underlying =
typename std::underlying_type<ConnectionDirection>::type;
45 return (underlying(a) & underlying(b));
75 std::vector<std::string>
GetNetworkNames(
bool append_unroutable =
false);
99 using DNSLookupFn = std::function<std::vector<CNetAddr>(
const std::string&,
bool)>;
147 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);
222 bool ConnectThroughProxy(
const Proxy& proxy,
const std::string& strDest, uint16_t port,
const Sock& sock,
int nTimeout,
bool& outProxyConnectionFailed);
A combination of a network address (CNetAddr) and a (TCP) port.
Proxy(const CService &_proxy, bool _randomize_credentials=false)
bool randomize_credentials
RAII helper class that manages a socket.
std::unique_ptr< Sock > CreateSockTCP(const CService &address_family)
Create a TCP socket in the given address family.
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 SetNameProxy(const Proxy &addrProxy)
Set the name proxy to use for all connections to nodes specified by a hostname.
std::vector< CNetAddr > WrappedGetAddrInfo(const std::string &name, bool allow_lookup)
Wrapper for getaddrinfo(3).
bool LookupSubNet(const std::string &subnet_str, CSubNet &subnet_out)
Parse and resolve a specified subnet string into the appropriate internal representation.
void InterruptSocks5(bool interrupt)
bool SetProxy(enum Network net, const Proxy &addrProxy)
std::function< std::unique_ptr< Sock >const CService &)> CreateSock
Socket factory.
std::vector< std::string > GetNetworkNames(bool append_unroutable=false)
Return a vector of publicly routable Network names; optionally append NET_UNROUTABLE.
bool ConnectThroughProxy(const Proxy &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...
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.
std::function< std::vector< CNetAddr >(const std::string &, bool)> DNSLookupFn
static ConnectionDirection & operator|=(ConnectionDirection &a, ConnectionDirection b)
static bool operator&(ConnectionDirection a, ConnectionDirection b)
bool GetProxy(enum Network net, Proxy &proxyInfoOut)
enum Network ParseNetwork(const std::string &net)
bool GetNameProxy(Proxy &nameProxyOut)
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.
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.
Credentials for proxy authentication.