Bitcoin ABC 0.26.3
P2P Digital Currency
|
#include <compat.h>
#include <netaddress.h>
#include <serialize.h>
#include <util/sock.h>
#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <vector>
Go to the source code of this file.
Classes | |
class | proxyType |
Typedefs | |
using | DNSLookupFn = std::function< std::vector< CNetAddr >(const std::string &, bool)> |
Functions | |
std::vector< CNetAddr > | WrappedGetAddrInfo (const std::string &name, bool allow_lookup) |
Wrapper for getaddrinfo(3). | |
enum Network | ParseNetwork (const std::string &net) |
std::string | GetNetworkName (enum Network net) |
std::vector< std::string > | GetNetworkNames (bool append_unroutable=false) |
Return a vector of publicly routable Network names; optionally append NET_UNROUTABLE. | |
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) |
Set the name proxy to use for all connections to nodes specified by a hostname. | |
bool | HaveNameProxy () |
bool | GetNameProxy (proxyType &nameProxyOut) |
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 | LookupHost (const std::string &name, CNetAddr &addr, bool fAllowLookup, DNSLookupFn dns_lookup_function=g_dns_lookup) |
Resolve a host string to its first corresponding network address. | |
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 | Lookup (const std::string &name, CService &addr, uint16_t portDefault, bool fAllowLookup, DNSLookupFn dns_lookup_function=g_dns_lookup) |
Resolve a service string to its first corresponding service. | |
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. | |
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. | |
std::unique_ptr< Sock > | CreateSockTCP (const CService &address_family) |
Create a TCP socket in the given address family. | |
bool | ConnectSocketDirectly (const CService &addrConnect, const Sock &sock, int nTimeout, bool manual_connection) |
Try to connect to the specified service on the specified 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 proxy. | |
bool | SetSocketNonBlocking (const SOCKET &hSocket, bool fNonBlocking) |
Disable or enable blocking-mode for a socket. | |
bool | SetSocketNoDelay (const SOCKET &hSocket) |
Set the TCP_NODELAY flag on a socket. | |
void | InterruptSocks5 (bool interrupt) |
bool | IsBadPort (uint16_t port) |
Determine if a port is "bad" from the perspective of attempting to connect to a node on that port. | |
Variables | |
int | nConnectTimeout |
bool | fNameLookup |
static const int | DEFAULT_CONNECT_TIMEOUT = 5000 |
-timeout default | |
static const int | DEFAULT_NAME_LOOKUP = true |
-dns default | |
DNSLookupFn | g_dns_lookup |
std::function< std::unique_ptr< Sock >(const CService &)> | CreateSock |
Socket factory. | |
using DNSLookupFn = std::function<std::vector<CNetAddr>(const std::string &, bool)> |
bool ConnectSocketDirectly | ( | const CService & | addrConnect, |
const Sock & | sock, | ||
int | nTimeout, | ||
bool | manual_connection | ||
) |
Try to connect to the specified service on the specified socket.
addrConnect | The service to which to connect. |
sock | The socket on which to connect. |
nTimeout | Wait this many milliseconds for the connection to be established. |
manual_connection | Whether or not the connection was manually requested (e.g. through the addnode RPC) |
Definition at line 634 of file netbase.cpp.
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 proxy.
proxy | The SOCKS5 proxy. | |
strDest | The destination service to which to connect. | |
port | The destination port. | |
sock | The socket on which to connect to the SOCKS5 proxy. | |
nTimeout | Wait this many milliseconds for the connection to the SOCKS5 proxy to be established. | |
[out] | outProxyConnectionFailed | Whether or not the connection to the SOCKS5 proxy failed. |
Definition at line 763 of file netbase.cpp.
std::unique_ptr< Sock > CreateSockTCP | ( | const CService & | address_family | ) |
Create a TCP socket in the given address family.
[in] | address_family | The socket is created in the same address family as this address. |
Definition at line 572 of file netbase.cpp.
Definition at line 739 of file netbase.cpp.
Definition at line 113 of file netbase.cpp.
std::vector< std::string > GetNetworkNames | ( | bool | append_unroutable = false | ) |
Return a vector of publicly routable Network names; optionally append NET_UNROUTABLE.
Definition at line 136 of file netbase.cpp.
Definition at line 720 of file netbase.cpp.
bool HaveNameProxy | ( | ) |
Definition at line 748 of file netbase.cpp.
Definition at line 855 of file netbase.cpp.
Determine if a port is "bad" from the perspective of attempting to connect to a node on that port.
[in] | port | Port to check. |
Definition at line 859 of file netbase.cpp.
bool Lookup | ( | const std::string & | name, |
CService & | addr, | ||
uint16_t | portDefault, | ||
bool | fAllowLookup, | ||
DNSLookupFn | dns_lookup_function = g_dns_lookup |
||
) |
Resolve a service string to its first corresponding service.
Definition at line 245 of file netbase.cpp.
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.
name | The string representing a service. Could be a name or a numerical IP address (IPv6 addresses should be in their disambiguated bracketed form), optionally followed by a uint16_t port number. (e.g. example.com:8333 or | |
[out] | vAddr | The resulting services to which the specified service string resolved. |
portDefault | The default port for resulting services if not specified by the service string. | |
fAllowLookup | Whether or not hostname lookups are permitted. If yes, external queries may be performed. | |
nMaxSolutions | The maximum number of results we want, specifying 0 means "as many solutions as we get." |
Definition at line 222 of file netbase.cpp.
bool LookupHost | ( | const std::string & | name, |
CNetAddr & | addr, | ||
bool | fAllowLookup, | ||
DNSLookupFn | dns_lookup_function = g_dns_lookup |
||
) |
Resolve a host string to its first corresponding network address.
Definition at line 208 of file netbase.cpp.
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.
name | The string representing a host. Could be a name or a numerical IP address (IPv6 addresses in their bracketed form are allowed). | |
[out] | vIP | The resulting network addresses to which the specified host string resolved. |
Definition at line 190 of file netbase.cpp.
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.
Definition at line 260 of file netbase.cpp.
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.
strSubnet | A string representation of a subnet of the form network address [ "/", ( CIDR-style suffix | netmask ) ] (e.g. 2001:db8::/32 , 192.0.2.0/255.255.255.0 , or 8.8.8.8 ). |
subnet | The resulting internal representation of a subnet. |
Definition at line 786 of file netbase.cpp.
Definition at line 91 of file netbase.cpp.
Set the name proxy to use for all connections to nodes specified by a hostname.
After setting this proxy, connecting to a node specified by a hostname won't result in a local lookup of said hostname, rather, connect to the node by asking the name proxy for a proxy connection to the hostname, effectively delegating the hostname lookup to the specified proxy.
This delegation increases privacy for those who set the name proxy as they no longer leak their external hostname queries to their DNS servers.
Definition at line 730 of file netbase.cpp.
Definition at line 710 of file netbase.cpp.
Set the TCP_NODELAY flag on a socket.
Definition at line 848 of file netbase.cpp.
Disable or enable blocking-mode for a socket.
Definition at line 822 of file netbase.cpp.
std::vector< CNetAddr > WrappedGetAddrInfo | ( | const std::string & | name, |
bool | allow_lookup | ||
) |
Wrapper for getaddrinfo(3).
Do not use directly: call Lookup/LookupHost/LookupNumeric/LookupSubNet.
Definition at line 45 of file netbase.cpp.
|
extern |
Socket factory.
Defaults to CreateSockTCP()
, but can be overridden by unit tests.
Definition at line 620 of file netbase.cpp.
|
static |
|
extern |
Definition at line 38 of file netbase.cpp.
|
extern |
Definition at line 89 of file netbase.cpp.
|
extern |
Definition at line 37 of file netbase.cpp.