5 #ifndef BITCOIN_NETBASE_H 6 #define BITCOIN_NETBASE_H 8 #if defined(HAVE_CONFIG_H) 21 #include <type_traits> 22 #include <unordered_set> 40 using underlying =
typename std::underlying_type<ConnectionDirection>::type;
45 using underlying =
typename std::underlying_type<ConnectionDirection>::type;
46 return (underlying(a) & underlying(b));
77 m_reachable.insert(net);
84 m_reachable.erase(net);
98 return m_reachable.count(net) > 0;
131 std::vector<std::string>
GetNetworkNames(
bool append_unroutable =
false);
155 using DNSLookupFn = std::function<std::vector<CNetAddr>(
const std::string&, bool)>;
202 std::vector<CService>
Lookup(
const std::string&
name, uint16_t portDefault,
bool fAllowLookup,
unsigned int nMaxSolutions,
DNSLookupFn dns_lookup_function =
g_dns_lookup);
277 bool ConnectThroughProxy(
const Proxy& proxy,
const std::string& strDest, uint16_t port,
const Sock& sock,
int nTimeout,
bool& outProxyConnectionFailed);
319 #endif // BITCOIN_NETBASE_H
std::unique_ptr< Sock > CreateSockTCP(const CService &address_family)
Create a TCP socket in the given address family.
void Remove(Network net) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
bool ConnectSocketDirectly(const CService &addrConnect, const Sock &sock, int nTimeout, bool manual_connection)
Try to connect to the specified service on the specified socket.
A set of addresses that represent the hash of a string or FQDN.
bool randomize_credentials
void Add(Network net) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
void InterruptSocks5(bool interrupt)
bool Contains(Network net) const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
bool GetNameProxy(Proxy &nameProxyOut)
List of reachable networks.
CService MaybeFlipIPv6toCJDNS(const CService &service)
If an IPv6 address belongs to the address range used by the CJDNS network and the CJDNS network is re...
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...
enum Network ParseNetwork(const std::string &net)
bool IsProxy(const CNetAddr &addr)
static ConnectionDirection & operator|=(ConnectionDirection &a, ConnectionDirection b)
std::vector< CNetAddr > WrappedGetAddrInfo(const std::string &name, bool allow_lookup)
Wrapper for getaddrinfo(3).
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.
static bool operator &(ConnectionDirection a, ConnectionDirection b)
ReachableNets g_reachable_nets
A combination of a network address (CNetAddr) and a (TCP) port.
bool SetProxy(enum Network net, const Proxy &addrProxy)
Credentials for proxy authentication.
static const int DEFAULT_NAME_LOOKUP
-dns default
bool SetNameProxy(const Proxy &addrProxy)
Set the name proxy to use for all connections to nodes specified by a hostname.
#define EXCLUSIVE_LOCKS_REQUIRED(...)
std::function< std::vector< CNetAddr >(const std::string &, bool)> DNSLookupFn
bool GetProxy(enum Network net, Proxy &proxyInfoOut)
std::function< std::unique_ptr< Sock >const CService &)> CreateSock
Socket factory.
bool LookupSubNet(const std::string &subnet_str, CSubNet &subnet_out)
Parse and resolve a specified subnet string into the appropriate internal representation.
static const int DEFAULT_CONNECT_TIMEOUT
-timeout default
std::vector< CService > Lookup(const std::string &name, uint16_t portDefault, bool fAllowLookup, unsigned int nMaxSolutions, DNSLookupFn dns_lookup_function=g_dns_lookup)
Resolve a service string to its corresponding service.
std::string GetNetworkName(enum Network net)
void RemoveAll() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
#define AssertLockNotHeld(cs)
bool Contains(const CNetAddr &addr) const EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
bool IsBadPort(uint16_t port)
Determine if a port is "bad" from the perspective of attempting to connect to a node on that port...
RAII helper class that manages a socket and closes it automatically when it goes out of scope...
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::unordered_set< Network > m_reachable GUARDED_BY(m_mutex)
Proxy(const CService &_proxy, bool _randomize_credentials=false)
std::vector< CNetAddr > LookupHost(const std::string &name, unsigned int nMaxSolutions, bool fAllowLookup, DNSLookupFn dns_lookup_function=g_dns_lookup)
Resolve a host string to its corresponding network addresses.
Addresses from these networks are not publicly routable on the global Internet.