Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions | Variables
netbase.cpp File Reference
#include "netbase.h"
#include "hash.h"
#include "sync.h"
#include "uint256.h"
#include "util.h"
#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.

Functions

enum Network ParseNetwork (std::string net)
 
void SplitHostPort (std::string in, int &portOut, std::string &hostOut)
 
static bool LookupIntern (const char *pszName, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup)
 
bool LookupHost (const char *pszName, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions, bool fAllowLookup)
 
bool LookupHostNumeric (const char *pszName, std::vector< CNetAddr > &vIP, unsigned int nMaxSolutions)
 
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)
 
bool LookupNumeric (const char *pszName, CService &addr, int portDefault)
 
static bool Socks4 (const CService &addrDest, SOCKET &hSocket)
 
static bool Socks5 (string strDest, int port, SOCKET &hSocket)
 
static bool ConnectSocketDirectly (const CService &addrConnect, SOCKET &hSocketRet, int nTimeout)
 
bool SetProxy (enum Network net, CService addrProxy, int nSocksVersion)
 
bool GetProxy (enum Network net, proxyType &proxyInfoOut)
 
bool SetNameProxy (CService addrProxy, int nSocksVersion)
 
bool GetNameProxy (proxyType &nameproxyInfoOut)
 
bool HaveNameProxy ()
 
bool IsProxy (const CNetAddr &addr)
 
bool ConnectSocket (const CService &addrDest, SOCKET &hSocketRet, int nTimeout)
 
bool ConnectSocketByName (CService &addr, SOCKET &hSocketRet, const char *pszDest, int portDefault, int nTimeout)
 
bool operator== (const CNetAddr &a, const CNetAddr &b)
 
bool operator!= (const CNetAddr &a, const CNetAddr &b)
 
bool operator< (const CNetAddr &a, const CNetAddr &b)
 
static int GetExtNetwork (const CNetAddr *addr)
 
bool operator== (const CService &a, const CService &b)
 
bool operator!= (const CService &a, const CService &b)
 
bool operator< (const CService &a, const CService &b)
 
std::string NetworkErrorString (int err)
 Return readable error string for a network error code. More...
 

Variables

static proxyType proxyInfo [NET_MAX]
 
static proxyType nameproxyInfo
 
static CCriticalSection cs_proxyInfos
 
int nConnectTimeout = 5000
 
bool fNameLookup = false
 
static const unsigned char pchIPv4 [12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff }
 
static const unsigned char pchOnionCat [] = {0xFD,0x87,0xD8,0x7E,0xEB,0x43}
 
static const int NET_UNKNOWN = NET_MAX + 0
 
static const int NET_TEREDO = NET_MAX + 1
 

Function Documentation

bool ConnectSocket ( const CService addrDest,
SOCKET hSocketRet,
int  nTimeout 
)

Definition at line 471 of file netbase.cpp.

References closesocket, ConnectSocketDirectly(), CNetAddr::GetNetwork(), CService::GetPort(), GetProxy(), INVALID_SOCKET, Socks4(), Socks5(), and CNetAddr::ToStringIP().

Referenced by ConnectNode(), ConnectSocketByName(), and GetMyExternalIP2().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ConnectSocketByName ( CService addr,
SOCKET hSocketRet,
const char *  pszDest,
int  portDefault,
int  nTimeout 
)

Definition at line 504 of file netbase.cpp.

References closesocket, ConnectSocket(), ConnectSocketDirectly(), fNameLookup, GetNameProxy(), INVALID_SOCKET, CNetAddr::IsValid(), Socks5(), and SplitHostPort().

Referenced by ConnectNode().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 314 of file netbase.cpp.

References closesocket, CService::GetSockAddr(), INVALID_SOCKET, LogPrint(), LogPrintf, NetworkErrorString(), SOCKET_ERROR, CService::ToString(), WSAEINPROGRESS, WSAEINVAL, WSAEWOULDBLOCK, and WSAGetLastError.

Referenced by ConnectSocket(), and ConnectSocketByName().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static int GetExtNetwork ( const CNetAddr addr)
static

Definition at line 892 of file netbase.cpp.

References CNetAddr::GetNetwork(), CNetAddr::IsRFC4380(), and NET_UNKNOWN.

Referenced by CNetAddr::GetReachabilityFrom().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool GetNameProxy ( proxyType nameproxyInfoOut)

Definition at line 449 of file netbase.cpp.

References LOCK, and nameproxyInfo.

Referenced by ConnectSocketByName().

+ Here is the caller graph for this function:

bool GetProxy ( enum Network  net,
proxyType proxyInfoOut 
)

Definition at line 430 of file netbase.cpp.

References LOCK, NET_MAX, and proxyInfo.

Referenced by ConnectSocket(), getblockchaininfo(), getinfo(), getnetworkinfo(), and OptionsModel::getProxySettings().

+ Here is the caller graph for this function:

bool HaveNameProxy ( )

Definition at line 457 of file netbase.cpp.

References LOCK, and nameproxyInfo.

Referenced by ThreadDNSAddressSeed(), and ThreadOpenAddedConnections().

+ Here is the caller graph for this function:

bool IsProxy ( const CNetAddr addr)

Definition at line 462 of file netbase.cpp.

References LOCK, NET_MAX, and proxyInfo.

Referenced by CNode::PushVersion().

+ Here is the caller graph for this function:

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

Definition at line 133 of file netbase.cpp.

References LookupIntern(), and SplitHostPort().

Referenced by AppInit2(), CService::CService(), getaddednodeinfo(), Lookup(), LookupNumeric(), and ThreadOpenAddedConnections().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 151 of file netbase.cpp.

References Lookup().

+ Here is the call graph for this function:

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

Definition at line 115 of file netbase.cpp.

References LookupIntern().

Referenced by CNetAddr::CNetAddr(), Discover(), LookupHostNumeric(), and ThreadDNSAddressSeed().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 128 of file netbase.cpp.

References LookupHost().

+ Here is the call graph for this function:

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

Definition at line 64 of file netbase.cpp.

References CNetAddr::SetSpecial().

Referenced by Lookup(), and LookupHost().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 161 of file netbase.cpp.

References Lookup().

Referenced by OptionsDialog::doProxyIpChecks().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string NetworkErrorString ( int  err)

Return readable error string for a network error code.

Definition at line 1143 of file netbase.cpp.

References strprintf.

Referenced by BindListenPort(), ConnectNode(), ConnectSocketDirectly(), RecvLine(), SocketSendData(), ThreadSocketHandler(), and CNetCleanup::~CNetCleanup().

+ Here is the caller graph for this function:

bool operator!= ( const CNetAddr a,
const CNetAddr b 
)

Definition at line 782 of file netbase.cpp.

References CNetAddr::ip.

bool operator!= ( const CService a,
const CService b 
)

Definition at line 1048 of file netbase.cpp.

References CService::port.

bool operator< ( const CNetAddr a,
const CNetAddr b 
)

Definition at line 787 of file netbase.cpp.

References CNetAddr::ip.

bool operator< ( const CService a,
const CService b 
)

Definition at line 1053 of file netbase.cpp.

References CService::port.

bool operator== ( const CNetAddr a,
const CNetAddr b 
)

Definition at line 777 of file netbase.cpp.

References CNetAddr::ip.

bool operator== ( const CService a,
const CService b 
)

Definition at line 1043 of file netbase.cpp.

References CService::port.

enum Network ParseNetwork ( std::string  net)

Definition at line 35 of file netbase.cpp.

References NET_IPV4, NET_IPV6, NET_TOR, and NET_UNROUTABLE.

Referenced by AppInit2().

+ Here is the caller graph for this function:

bool SetNameProxy ( CService  addrProxy,
int  nSocksVersion 
)

Definition at line 439 of file netbase.cpp.

References CNetAddr::IsValid(), LOCK, and nameproxyInfo.

Referenced by AppInit2().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SetProxy ( enum Network  net,
CService  addrProxy,
int  nSocksVersion 
)

Definition at line 419 of file netbase.cpp.

References CNetAddr::IsValid(), LOCK, NET_MAX, and proxyInfo.

Referenced by AppInit2().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool Socks4 ( const CService addrDest,
SOCKET hSocket 
)
static

Definition at line 166 of file netbase.cpp.

References closesocket, error(), CService::GetSockAddr(), CNetAddr::IsIPv4(), LogPrintf, memcpy(), MSG_NOSIGNAL, and CService::ToString().

Referenced by ConnectSocket().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool Socks5 ( string  strDest,
int  port,
SOCKET hSocket 
)
static

Definition at line 210 of file netbase.cpp.

References closesocket, error(), LogPrintf, and MSG_NOSIGNAL.

Referenced by ConnectSocket(), and ConnectSocketByName().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void SplitHostPort ( std::string  in,
int portOut,
std::string &  hostOut 
)

Definition at line 43 of file netbase.cpp.

Referenced by ConnectSocketByName(), and Lookup().

+ Here is the caller graph for this function:

Variable Documentation

CCriticalSection cs_proxyInfos
static

Definition at line 29 of file netbase.cpp.

bool fNameLookup = false
proxyType nameproxyInfo
static

Definition at line 28 of file netbase.cpp.

Referenced by GetNameProxy(), HaveNameProxy(), and SetNameProxy().

int nConnectTimeout = 5000

Definition at line 30 of file netbase.cpp.

Referenced by AppInit2().

const int NET_TEREDO = NET_MAX + 1
static

Definition at line 891 of file netbase.cpp.

const int NET_UNKNOWN = NET_MAX + 0
static

Definition at line 890 of file netbase.cpp.

Referenced by GetExtNetwork().

const unsigned char pchIPv4[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xff, 0xff }
static

Definition at line 33 of file netbase.cpp.

Referenced by CNetAddr::CNetAddr(), CNetAddr::IsIPv4(), and CNetAddr::IsValid().

const unsigned char pchOnionCat[] = {0xFD,0x87,0xD8,0x7E,0xEB,0x43}
static

Definition at line 551 of file netbase.cpp.

Referenced by CNetAddr::IsTor(), and CNetAddr::SetSpecial().

proxyType proxyInfo[NET_MAX]
static

Definition at line 27 of file netbase.cpp.

Referenced by GetProxy(), IsProxy(), and SetProxy().