Raven Core  3.0.0
P2P Digital Currency
Classes | Macros | Enumerations | Functions | Variables
netbase.cpp File Reference
#include "netbase.h"
#include "hash.h"
#include "sync.h"
#include "uint256.h"
#include "random.h"
#include "util.h"
#include "utilstrencodings.h"
#include <atomic>
#include <fcntl.h>
#include <boost/algorithm/string/case_conv.hpp>
#include <boost/algorithm/string/predicate.hpp>
Include dependency graph for netbase.cpp:

Go to the source code of this file.

Classes

struct  ProxyCredentials
 Credentials for proxy authentication. More...
 

Macros

#define MSG_NOSIGNAL   0
 

Enumerations

enum  SOCKSVersion : uint8_t { SOCKS4 = 0x04, SOCKS5 = 0x05 }
 SOCKS version. More...
 
enum  SOCKS5Method : uint8_t { NOAUTH = 0x00, GSSAPI = 0x01, USER_PASS = 0x02, NO_ACCEPTABLE = 0xff }
 Values defined for METHOD in RFC1928. More...
 
enum  SOCKS5Command : uint8_t { CONNECT = 0x01, BIND = 0x02, UDP_ASSOCIATE = 0x03 }
 Values defined for CMD in RFC1928. More...
 
enum  SOCKS5Reply : uint8_t {
  SUCCEEDED = 0x00, GENFAILURE = 0x01, NOTALLOWED = 0x02, NETUNREACHABLE = 0x03,
  HOSTUNREACHABLE = 0x04, CONNREFUSED = 0x05, TTLEXPIRED = 0x06, CMDUNSUPPORTED = 0x07,
  ATYPEUNSUPPORTED = 0x08
}
 Values defined for REP in RFC1928. More...
 
enum  SOCKS5Atyp : uint8_t { IPV4 = 0x01, DOMAINNAME = 0x03, IPV6 = 0x04 }
 Values defined for ATYPE in RFC1928. More...
 
enum  IntrRecvError {
  IntrRecvError::OK, IntrRecvError::Timeout, IntrRecvError::Disconnected, IntrRecvError::NetworkError,
  IntrRecvError::Interrupted
}
 Status codes that can be returned by InterruptibleRecv. More...
 

Functions

enum Network ParseNetwork (std::string net)
 
std::string GetNetworkName (enum Network net)
 
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, std::vector< CService > &vAddr, int portDefault, bool fAllowLookup, unsigned int nMaxSolutions)
 
bool Lookup (const char *pszName, CService &addr, int portDefault, bool fAllowLookup)
 
CService LookupNumeric (const char *pszName, int portDefault)
 
struct timeval MillisToTimeval (int64_t nTimeout)
 Convert milliseconds to a struct timeval for e.g. More...
 
std::string Socks5ErrorString (uint8_t err)
 Convert SOCKS5 reply to an error message. More...
 
bool ConnectSocketDirectly (const CService &addrConnect, SOCKET &hSocketRet, int nTimeout)
 
bool SetProxy (enum Network net, const proxyType &addrProxy)
 
bool GetProxy (enum Network net, proxyType &proxyInfoOut)
 
bool SetNameProxy (const proxyType &addrProxy)
 
bool GetNameProxy (proxyType &nameProxyOut)
 
bool HaveNameProxy ()
 
bool IsProxy (const CNetAddr &addr)
 
bool ConnectThroughProxy (const proxyType &proxy, const std::string &strDest, int port, SOCKET &hSocketRet, int nTimeout, bool *outProxyConnectionFailed)
 
bool LookupSubNet (const char *pszName, CSubNet &ret)
 
std::string NetworkErrorString (int err)
 Return readable error string for a network error code. More...
 
bool CloseSocket (SOCKET &hSocket)
 Close socket and set hSocket to INVALID_SOCKET. More...
 
bool SetSocketNonBlocking (const SOCKET &hSocket, bool fNonBlocking)
 Disable or enable blocking-mode for a socket. More...
 
bool SetSocketNoDelay (const SOCKET &hSocket)
 Set the TCP_NODELAY flag on a socket. More...
 
void InterruptSocks5 (bool interrupt)
 

Variables

int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT
 
bool fNameLookup = DEFAULT_NAME_LOOKUP
 

Macro Definition Documentation

◆ MSG_NOSIGNAL

#define MSG_NOSIGNAL   0

Definition at line 30 of file netbase.cpp.

Enumeration Type Documentation

◆ IntrRecvError

enum IntrRecvError
strong

Status codes that can be returned by InterruptibleRecv.

Enumerator
OK 
Timeout 
Disconnected 
NetworkError 
Interrupted 

Definition at line 230 of file netbase.cpp.

◆ SOCKS5Atyp

enum SOCKS5Atyp : uint8_t

Values defined for ATYPE in RFC1928.

Enumerator
IPV4 
DOMAINNAME 
IPV6 

Definition at line 223 of file netbase.cpp.

◆ SOCKS5Command

enum SOCKS5Command : uint8_t

Values defined for CMD in RFC1928.

Enumerator
CONNECT 
BIND 
UDP_ASSOCIATE 

Definition at line 203 of file netbase.cpp.

◆ SOCKS5Method

enum SOCKS5Method : uint8_t

Values defined for METHOD in RFC1928.

Enumerator
NOAUTH 
GSSAPI 

No authentication required.

USER_PASS 

GSSAPI.

NO_ACCEPTABLE 

Username/password.

Definition at line 195 of file netbase.cpp.

◆ SOCKS5Reply

enum SOCKS5Reply : uint8_t

Values defined for REP in RFC1928.

Enumerator
SUCCEEDED 
GENFAILURE 

Succeeded.

NOTALLOWED 

General failure.

NETUNREACHABLE 

Connection not allowed by ruleset.

HOSTUNREACHABLE 

Network unreachable.

CONNREFUSED 

Network unreachable.

TTLEXPIRED 

Connection refused.

CMDUNSUPPORTED 

TTL expired.

ATYPEUNSUPPORTED 

Command not supported.

Definition at line 210 of file netbase.cpp.

◆ SOCKSVersion

enum SOCKSVersion : uint8_t

SOCKS version.

Enumerator
SOCKS4 
SOCKS5 

Definition at line 189 of file netbase.cpp.

Function Documentation

◆ CloseSocket()

bool CloseSocket ( SOCKET hSocket)

Close socket and set hSocket to INVALID_SOCKET.

Definition at line 687 of file netbase.cpp.

Here is the caller graph for this function:

◆ ConnectSocketDirectly()

bool ConnectSocketDirectly ( const CService addrConnect,
SOCKET hSocketRet,
int  nTimeout 
)

Definition at line 456 of file netbase.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConnectThroughProxy()

bool ConnectThroughProxy ( const proxyType proxy,
const std::string &  strDest,
int  port,
SOCKET hSocketRet,
int  nTimeout,
bool *  outProxyConnectionFailed 
)

Definition at line 591 of file netbase.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNameProxy()

bool GetNameProxy ( proxyType nameProxyOut)

Definition at line 569 of file netbase.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNetworkName()

std::string GetNetworkName ( enum Network  net)

Definition at line 52 of file netbase.cpp.

◆ GetProxy()

bool GetProxy ( enum Network  net,
proxyType proxyInfoOut 
)

Definition at line 552 of file netbase.cpp.

Here is the caller graph for this function:

◆ HaveNameProxy()

bool HaveNameProxy ( )

Definition at line 577 of file netbase.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ InterruptSocks5()

void InterruptSocks5 ( bool  interrupt)

Definition at line 734 of file netbase.cpp.

Here is the caller graph for this function:

◆ IsProxy()

bool IsProxy ( const CNetAddr addr)

Definition at line 582 of file netbase.cpp.

◆ Lookup() [1/2]

bool Lookup ( const char *  pszName,
std::vector< CService > &  vAddr,
int  portDefault,
bool  fAllowLookup,
unsigned int  nMaxSolutions 
)

Definition at line 142 of file netbase.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Lookup() [2/2]

bool Lookup ( const char *  pszName,
CService addr,
int  portDefault,
bool  fAllowLookup 
)

Definition at line 160 of file netbase.cpp.

Here is the call graph for this function:

◆ LookupHost() [1/2]

bool LookupHost ( const char *  pszName,
std::vector< CNetAddr > &  vIP,
unsigned int  nMaxSolutions,
bool  fAllowLookup 
)

Definition at line 119 of file netbase.cpp.

Here is the caller graph for this function:

◆ LookupHost() [2/2]

bool LookupHost ( const char *  pszName,
CNetAddr addr,
bool  fAllowLookup 
)

Definition at line 132 of file netbase.cpp.

Here is the call graph for this function:

◆ LookupNumeric()

CService LookupNumeric ( const char *  pszName,
int  portDefault 
)

Definition at line 170 of file netbase.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LookupSubNet()

bool LookupSubNet ( const char *  pszName,
CSubNet ret 
)

Definition at line 615 of file netbase.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MillisToTimeval()

struct timeval MillisToTimeval ( int64_t  nTimeout)

Convert milliseconds to a struct timeval for e.g.

select.

Definition at line 180 of file netbase.cpp.

Here is the caller graph for this function:

◆ NetworkErrorString()

std::string NetworkErrorString ( int  err)

Return readable error string for a network error code.

Definition at line 669 of file netbase.cpp.

Here is the caller graph for this function:

◆ ParseNetwork()

enum Network ParseNetwork ( std::string  net)

Definition at line 44 of file netbase.cpp.

◆ SetNameProxy()

bool SetNameProxy ( const proxyType addrProxy)

Definition at line 561 of file netbase.cpp.

Here is the call graph for this function:

◆ SetProxy()

bool SetProxy ( enum Network  net,
const proxyType addrProxy 
)

Definition at line 543 of file netbase.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetSocketNoDelay()

bool SetSocketNoDelay ( const SOCKET hSocket)

Set the TCP_NODELAY flag on a socket.

Definition at line 727 of file netbase.cpp.

Here is the caller graph for this function:

◆ SetSocketNonBlocking()

bool SetSocketNonBlocking ( const SOCKET hSocket,
bool  fNonBlocking 
)

Disable or enable blocking-mode for a socket.

Definition at line 700 of file netbase.cpp.

Here is the caller graph for this function:

◆ Socks5ErrorString()

std::string Socks5ErrorString ( uint8_t  err)

Convert SOCKS5 reply to an error message.

Definition at line 296 of file netbase.cpp.

Variable Documentation

◆ fNameLookup

bool fNameLookup = DEFAULT_NAME_LOOKUP

Definition at line 38 of file netbase.cpp.

◆ nConnectTimeout

int nConnectTimeout = DEFAULT_CONNECT_TIMEOUT

Definition at line 37 of file netbase.cpp.