#include <compat.h>
#include <netaddress.h>
#include <serialize.h>
#include <stdint.h>
#include <string>
#include <vector>
Go to the source code of this file.
|
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) |
|
SOCKET | CreateSocket (const CService &addrConnect) |
|
bool | ConnectSocketDirectly (const CService &addrConnect, const SOCKET &hSocketRet, int nTimeout, bool manual_connection) |
|
bool | ConnectThroughProxy (const proxyType &proxy, const std::string &strDest, int port, const SOCKET &hSocketRet, int nTimeout, bool *outProxyConnectionFailed) |
|
std::string | NetworkErrorString (int err) |
|
bool | CloseSocket (SOCKET &hSocket) |
|
bool | SetSocketNonBlocking (const SOCKET &hSocket, bool fNonBlocking) |
|
bool | SetSocketNoDelay (const SOCKET &hSocket) |
|
struct timeval | MillisToTimeval (int64_t nTimeout) |
|
void | InterruptSocks5 (bool interrupt) |
|
◆ CloseSocket()
bool CloseSocket |
( |
SOCKET & |
hSocket | ) |
|
Close socket and set hSocket to INVALID_SOCKET
◆ ConnectSocketDirectly()
bool ConnectSocketDirectly |
( |
const CService & |
addrConnect, |
|
|
const SOCKET & |
hSocket, |
|
|
int |
nTimeout, |
|
|
bool |
manual_connection |
|
) |
| |
Try to connect to the specified service on the specified socket.
- Parameters
-
addrConnect | The service to which to connect. |
hSocket | 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. thru the addnode RPC) |
- Returns
- Whether or not a connection was successfully made.
◆ ConnectThroughProxy()
bool ConnectThroughProxy |
( |
const proxyType & |
proxy, |
|
|
const std::string & |
strDest, |
|
|
int |
port, |
|
|
const SOCKET & |
hSocket, |
|
|
int |
nTimeout, |
|
|
bool * |
outProxyConnectionFailed |
|
) |
| |
Connect to a specified destination service through a SOCKS5 proxy by first connecting to the SOCKS5 proxy.
- Parameters
-
proxy | The SOCKS5 proxy. |
strDest | The destination service to which to connect. |
port | The destination port. |
hSocket | 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. |
outProxyConnectionFailed[out] | Whether or not the connection to the SOCKS5 proxy failed. |
- Returns
- Whether or not the operation succeeded.
◆ CreateSocket()
Try to create a socket file descriptor with specific properties in the communications domain (address family) of the specified service.
For details on the desired properties, see the inline comments in the source code.
◆ GetNameProxy()
bool GetNameProxy |
( |
proxyType & |
nameProxyOut | ) |
|
◆ GetNetworkName()
std::string GetNetworkName |
( |
enum Network |
net | ) |
|
◆ GetProxy()
◆ HaveNameProxy()
◆ InterruptSocks5()
void InterruptSocks5 |
( |
bool |
interrupt | ) |
|
◆ IsProxy()
◆ Lookup() [1/2]
bool Lookup |
( |
const char * |
pszName, |
|
|
CService & |
addr, |
|
|
int |
portDefault, |
|
|
bool |
fAllowLookup |
|
) |
| |
◆ Lookup() [2/2]
bool Lookup |
( |
const char * |
pszName, |
|
|
std::vector< CService > & |
vAddr, |
|
|
int |
portDefault, |
|
|
bool |
fAllowLookup, |
|
|
unsigned int |
nMaxSolutions |
|
) |
| |
Resolve a service string to its corresponding service.
- Parameters
-
| pszName | 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 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." |
- Returns
- Whether or not the service string successfully resolved to any resulting services.
◆ LookupHost() [1/2]
bool LookupHost |
( |
const char * |
pszName, |
|
|
std::vector< CNetAddr > & |
vIP, |
|
|
unsigned int |
nMaxSolutions, |
|
|
bool |
fAllowLookup |
|
) |
| |
Resolve a host string to its corresponding network addresses.
- Parameters
-
| pszName | 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. |
- Returns
- Whether or not the specified host string successfully resolved to any resulting network addresses.
- See also
- Lookup(const char *, std::vector<CService>&, int, bool, unsigned int) for additional parameter descriptions.
◆ LookupHost() [2/2]
bool LookupHost |
( |
const char * |
pszName, |
|
|
CNetAddr & |
addr, |
|
|
bool |
fAllowLookup |
|
) |
| |
◆ LookupNumeric()
CService LookupNumeric |
( |
const char * |
pszName, |
|
|
int |
portDefault |
|
) |
| |
Resolve a service string with a numeric IP to its first corresponding service.
- Returns
- The resulting CService if the resolution was successful, [::]:0 otherwise.
- See also
- Lookup(const char *, CService&, int, bool) for additional parameter descriptions.
◆ LookupSubNet()
bool LookupSubNet |
( |
const char * |
pszName, |
|
|
CSubNet & |
ret |
|
) |
| |
Parse and resolve a specified subnet string into the appropriate internal representation.
- Parameters
-
pszName | 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 ). |
ret | The resulting internal representation of a subnet. |
- Returns
- Whether the operation succeeded or not.
◆ MillisToTimeval()
struct timeval MillisToTimeval |
( |
int64_t |
nTimeout | ) |
|
Convert milliseconds to a struct timeval for e.g. select.
◆ NetworkErrorString()
std::string NetworkErrorString |
( |
int |
err | ) |
|
Return readable error string for a network error code
◆ ParseNetwork()
enum Network ParseNetwork |
( |
std::string |
net | ) |
|
◆ SetNameProxy()
bool SetNameProxy |
( |
const proxyType & |
addrProxy | ) |
|
Set the name proxy to use for all connections to nodes specified by a hostname. After setting this proxy, connecting to a node sepcified 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.
- Returns
- Whether or not the operation succeeded.
- Note
- SOCKS5's support for UDP-over-SOCKS5 has been considered, but no SOCK5 server in common use (most notably Tor) actually implements UDP support, and a DNS resolver is beyond the scope of this project.
◆ SetProxy()
◆ SetSocketNoDelay()
bool SetSocketNoDelay |
( |
const SOCKET & |
hSocket | ) |
|
Set the TCP_NODELAY flag on a socket
◆ SetSocketNonBlocking()
bool SetSocketNonBlocking |
( |
const SOCKET & |
hSocket, |
|
|
bool |
fNonBlocking |
|
) |
| |
Disable or enable blocking-mode for a socket
◆ DEFAULT_CONNECT_TIMEOUT
const int DEFAULT_CONNECT_TIMEOUT = 5000 |
|
static |
◆ DEFAULT_NAME_LOOKUP
const int DEFAULT_NAME_LOOKUP = true |
|
static |
◆ fNameLookup
◆ nConnectTimeout