Bitcoin Core  0.21.1
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Classes | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
CConnman Class Reference

#include <net.h>

Collaboration diagram for CConnman:
[legend]

Classes

struct  CachedAddrResponse
 Cache responses to addr requests to minimize privacy leak. More...
 
struct  ListenSocket
 
struct  Options
 

Public Types

enum  NumConnections { CONNECTIONS_NONE = 0, CONNECTIONS_IN = (1U << 0), CONNECTIONS_OUT = (1U << 1), CONNECTIONS_ALL = (CONNECTIONS_IN | CONNECTIONS_OUT) }
 
using NodeFn = std::function< void(CNode *)>
 

Public Member Functions

void Init (const Options &connOptions)
 
 CConnman (uint64_t seed0, uint64_t seed1, bool network_active=true)
 
 ~CConnman ()
 
bool Start (CScheduler &scheduler, const Options &options)
 
void StopThreads ()
 
void StopNodes ()
 
void Stop ()
 
void Interrupt ()
 
bool GetNetworkActive () const
 
bool GetUseAddrmanOutgoing () const
 
void SetNetworkActive (bool active)
 
void OpenNetworkConnection (const CAddress &addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *strDest, ConnectionType conn_type)
 
bool CheckIncomingNonce (uint64_t nonce)
 
bool ForNode (NodeId id, std::function< bool(CNode *pnode)> func)
 
void PushMessage (CNode *pnode, CSerializedNetMsg &&msg)
 
void ForEachNode (const NodeFn &func)
 
void ForEachNode (const NodeFn &func) const
 
template<typename Callable , typename CallableAfter >
void ForEachNodeThen (Callable &&pre, CallableAfter &&post)
 
template<typename Callable , typename CallableAfter >
void ForEachNodeThen (Callable &&pre, CallableAfter &&post) const
 
void SetServices (const CService &addr, ServiceFlags nServices)
 
void MarkAddressGood (const CAddress &addr)
 
bool AddNewAddresses (const std::vector< CAddress > &vAddr, const CAddress &addrFrom, int64_t nTimePenalty=0)
 
std::vector< CAddressGetAddresses (size_t max_addresses, size_t max_pct)
 
std::vector< CAddressGetAddresses (CNode &requestor, size_t max_addresses, size_t max_pct)
 Cache is used to minimize topology leaks, so it should be used for all non-trusted calls, for example, p2p. More...
 
void SetTryNewOutboundPeer (bool flag)
 
bool GetTryNewOutboundPeer ()
 
int GetExtraOutboundCount ()
 
bool AddNode (const std::string &node)
 
bool RemoveAddedNode (const std::string &node)
 
std::vector< AddedNodeInfoGetAddedNodeInfo ()
 
size_t GetNodeCount (NumConnections num)
 
void GetNodeStats (std::vector< CNodeStats > &vstats)
 
bool DisconnectNode (const std::string &node)
 
bool DisconnectNode (const CSubNet &subnet)
 
bool DisconnectNode (const CNetAddr &addr)
 
bool DisconnectNode (NodeId id)
 
ServiceFlags GetLocalServices () const
 Used to convey which local services we are offering peers during node connection. More...
 
void SetMaxOutboundTarget (uint64_t limit)
 set the max outbound target in bytes More...
 
uint64_t GetMaxOutboundTarget ()
 
void SetMaxOutboundTimeframe (uint64_t timeframe)
 set the timeframe for the max outbound target More...
 
uint64_t GetMaxOutboundTimeframe ()
 
bool OutboundTargetReached (bool historicalBlockServingLimit)
 check if the outbound target is reached if param historicalBlockServingLimit is set true, the function will response true if the limit for serving historical blocks has been reached More...
 
uint64_t GetOutboundTargetBytesLeft ()
 response the bytes left in the current max outbound cycle in case of no limit, it will always response 0 More...
 
uint64_t GetMaxOutboundTimeLeftInCycle ()
 response the time in second left in the current max outbound cycle in case of no limit, it will always response 0 More...
 
uint64_t GetTotalBytesRecv ()
 
uint64_t GetTotalBytesSent ()
 
void SetBestHeight (int height)
 
int GetBestHeight () const
 
CSipHasher GetDeterministicRandomizer (uint64_t id) const
 Get a unique deterministic randomizer. More...
 
unsigned int GetReceiveFloodSize () const
 
void WakeMessageHandler ()
 
int64_t PoissonNextSendInbound (int64_t now, int average_interval_seconds)
 Attempts to obfuscate tx time through exponentially distributed emitting. More...
 
void SetAsmap (std::vector< bool > asmap)
 

Private Member Functions

bool BindListenPort (const CService &bindAddr, bilingual_str &strError, NetPermissionFlags permissions)
 
bool Bind (const CService &addr, unsigned int flags, NetPermissionFlags permissions)
 
bool InitBinds (const std::vector< CService > &binds, const std::vector< NetWhitebindPermissions > &whiteBinds, const std::vector< CService > &onion_binds)
 
void ThreadOpenAddedConnections ()
 
void AddAddrFetch (const std::string &strDest)
 
void ProcessAddrFetch ()
 
void ThreadOpenConnections (std::vector< std::string > connect)
 
void ThreadMessageHandler ()
 
void AcceptConnection (const ListenSocket &hListenSocket)
 
void DisconnectNodes ()
 
void NotifyNumConnectionsChanged ()
 
void InactivityCheck (CNode *pnode)
 
bool GenerateSelectSet (std::set< SOCKET > &recv_set, std::set< SOCKET > &send_set, std::set< SOCKET > &error_set)
 
void SocketEvents (std::set< SOCKET > &recv_set, std::set< SOCKET > &send_set, std::set< SOCKET > &error_set)
 
void SocketHandler ()
 
void ThreadSocketHandler ()
 
void ThreadDNSAddressSeed ()
 
uint64_t CalculateKeyedNetGroup (const CAddress &ad) const
 
CNodeFindNode (const CNetAddr &ip)
 
CNodeFindNode (const CSubNet &subNet)
 
CNodeFindNode (const std::string &addrName)
 
CNodeFindNode (const CService &addr)
 
bool AlreadyConnectedToAddress (const CAddress &addr)
 Determine whether we're already connected to a given address, in order to avoid initiating duplicate connections. More...
 
bool AttemptToEvictConnection ()
 Try to find a connection to evict when the node is full. More...
 
CNodeConnectNode (CAddress addrConnect, const char *pszDest, bool fCountFailure, ConnectionType conn_type)
 
void AddWhitelistPermissionFlags (NetPermissionFlags &flags, const CNetAddr &addr) const
 
void DeleteNode (CNode *pnode)
 
NodeId GetNewNodeId ()
 
size_t SocketSendData (CNode *pnode) const
 
void DumpAddresses ()
 
void RecordBytesRecv (uint64_t bytes)
 
void RecordBytesSent (uint64_t bytes)
 
std::vector< CAddressGetCurrentBlockRelayOnlyConns () const
 Return vector of current BLOCK_RELAY peers. More...
 
uint64_t nTotalBytesRecv GUARDED_BY (cs_totalBytesRecv)
 
uint64_t nTotalBytesSent GUARDED_BY (cs_totalBytesSent)
 
uint64_t
nMaxOutboundTotalBytesSentInCycle 
GUARDED_BY (cs_totalBytesSent)
 
uint64_t nMaxOutboundCycleStartTime GUARDED_BY (cs_totalBytesSent)
 
uint64_t nMaxOutboundLimit GUARDED_BY (cs_totalBytesSent)
 
uint64_t nMaxOutboundTimeframe GUARDED_BY (cs_totalBytesSent)
 
std::deque< std::string >
m_addr_fetches 
GUARDED_BY (m_addr_fetches_mutex)
 
std::vector< std::string >
vAddedNodes 
GUARDED_BY (cs_vAddedNodes)
 
std::vector< CNode * > vNodes GUARDED_BY (cs_vNodes)
 
bool fMsgProcWake GUARDED_BY (mutexMsgProc)
 flag for waking the message processor. More...
 

Static Private Member Functions

static bool NodeFullyConnected (const CNode *pnode)
 

Private Attributes

RecursiveMutex cs_totalBytesRecv
 
RecursiveMutex cs_totalBytesSent
 
int64_t m_peer_connect_timeout
 
std::vector
< NetWhitelistPermissions
vWhitelistedRange
 
unsigned int nSendBufferMaxSize {0}
 
unsigned int nReceiveFloodSize {0}
 
std::vector< ListenSocketvhListenSocket
 
std::atomic< bool > fNetworkActive {true}
 
bool fAddressesInitialized {false}
 
CAddrMan addrman
 
RecursiveMutex m_addr_fetches_mutex
 
RecursiveMutex cs_vAddedNodes
 
std::list< CNode * > vNodesDisconnected
 
RecursiveMutex cs_vNodes
 
std::atomic< NodeIdnLastNodeId {0}
 
unsigned int nPrevNodeCount {0}
 
std::map< uint64_t,
CachedAddrResponse
m_addr_response_caches
 Addr responses stored in different caches per (network, local socket) prevent cross-network node identification. More...
 
ServiceFlags nLocalServices
 Services this instance offers. More...
 
std::unique_ptr< CSemaphoresemOutbound
 
std::unique_ptr< CSemaphoresemAddnode
 
int nMaxConnections
 
int m_max_outbound_full_relay
 
int m_max_outbound_block_relay
 
int nMaxAddnode
 
int nMaxFeeler
 
int m_max_outbound
 
bool m_use_addrman_outgoing
 
std::atomic< int > nBestHeight
 
CClientUIInterfaceclientInterface
 
NetEventsInterfacem_msgproc
 
BanManm_banman
 Pointer to this node's banman. More...
 
std::vector< CAddressm_anchors
 Addresses that were saved during the previous clean shutdown. More...
 
const uint64_t nSeed0
 SipHasher seeds for deterministic randomness. More...
 
const uint64_t nSeed1
 
std::condition_variable condMsgProc
 
Mutex mutexMsgProc
 
std::atomic< bool > flagInterruptMsgProc {false}
 
CThreadInterrupt interruptNet
 
std::thread threadDNSAddressSeed
 
std::thread threadSocketHandler
 
std::thread threadOpenAddedConnections
 
std::thread threadOpenConnections
 
std::thread threadMessageHandler
 
std::atomic_bool m_try_another_outbound_peer
 flag for deciding to connect to an extra outbound peer, in excess of m_max_outbound_full_relay This takes the place of a feeler connection More...
 
std::atomic< int64_t > m_next_send_inv_to_incoming {0}
 
std::vector< CServicem_onion_binds
 A vector of -bind=<address>:<port>=onion arguments each of which is an address and port that are designated for incoming Tor connections. More...
 

Friends

struct CConnmanTest
 
struct ConnmanTestMsg
 

Detailed Description

Definition at line 187 of file net.h.

Member Typedef Documentation

using CConnman::NodeFn = std::function<void(CNode*)>

Definition at line 278 of file net.h.

Member Enumeration Documentation

Enumerator
CONNECTIONS_NONE 
CONNECTIONS_IN 
CONNECTIONS_OUT 
CONNECTIONS_ALL 

Definition at line 191 of file net.h.

Constructor & Destructor Documentation

CConnman::CConnman ( uint64_t  seed0,
uint64_t  seed1,
bool  network_active = true 
)

Definition at line 2391 of file net.cpp.

Here is the call graph for this function:

CConnman::~CConnman ( )

Definition at line 2665 of file net.cpp.

Here is the call graph for this function:

Member Function Documentation

void CConnman::AcceptConnection ( const ListenSocket hListenSocket)
private

Definition at line 1047 of file net.cpp.

Here is the call graph for this function:

void CConnman::AddAddrFetch ( const std::string &  strDest)
private

Definition at line 124 of file net.cpp.

Here is the caller graph for this function:

bool CConnman::AddNewAddresses ( const std::vector< CAddress > &  vAddr,
const CAddress addrFrom,
int64_t  nTimePenalty = 0 
)

Definition at line 2681 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::AddNode ( const std::string &  node)

Definition at line 2740 of file net.cpp.

void CConnman::AddWhitelistPermissionFlags ( NetPermissionFlags flags,
const CNetAddr addr 
) const
private

Definition at line 505 of file net.cpp.

Here is the call graph for this function:

bool CConnman::AlreadyConnectedToAddress ( const CAddress addr)
private

Determine whether we're already connected to a given address, in order to avoid initiating duplicate connections.

Definition at line 361 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::AttemptToEvictConnection ( )
private

Try to find a connection to evict when the node is full.

Extreme care must be taken to avoid opening the node to attacker triggered network partitioning. The strategy used here is to protect a small number of peers for each of several distinct characteristics which are difficult to forge. In order to partition a node the attacker must be simultaneously better at all of them than honest peers.

Definition at line 938 of file net.cpp.

Here is the call graph for this function:

bool CConnman::Bind ( const CService addr,
unsigned int  flags,
NetPermissionFlags  permissions 
)
private

Definition at line 2407 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::BindListenPort ( const CService bindAddr,
bilingual_str strError,
NetPermissionFlags  permissions 
)
private

Definition at line 2263 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t CConnman::CalculateKeyedNetGroup ( const CAddress ad) const
private

Definition at line 3072 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::CheckIncomingNonce ( uint64_t  nonce)

Definition at line 366 of file net.cpp.

Here is the caller graph for this function:

CNode * CConnman::ConnectNode ( CAddress  addrConnect,
const char *  pszDest,
bool  fCountFailure,
ConnectionType  conn_type 
)
private

debug print

Definition at line 392 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::DeleteNode ( CNode pnode)
private

Definition at line 2654 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::DisconnectNode ( const std::string &  node)

Definition at line 2790 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::DisconnectNode ( const CSubNet subnet)

Definition at line 2800 of file net.cpp.

Here is the call graph for this function:

bool CConnman::DisconnectNode ( const CNetAddr addr)

Definition at line 2813 of file net.cpp.

Here is the call graph for this function:

bool CConnman::DisconnectNode ( NodeId  id)

Definition at line 2818 of file net.cpp.

void CConnman::DisconnectNodes ( )
private

Definition at line 1163 of file net.cpp.

void CConnman::DumpAddresses ( )
private

Definition at line 1801 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

CNode * CConnman::FindNode ( const CNetAddr ip)
private

Definition at line 317 of file net.cpp.

Here is the caller graph for this function:

CNode * CConnman::FindNode ( const CSubNet subNet)
private

Definition at line 328 of file net.cpp.

Here is the call graph for this function:

CNode * CConnman::FindNode ( const std::string &  addrName)
private

Definition at line 339 of file net.cpp.

CNode * CConnman::FindNode ( const CService addr)
private

Definition at line 350 of file net.cpp.

void CConnman::ForEachNode ( const NodeFn func)
inline

Definition at line 279 of file net.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::ForEachNode ( const NodeFn func) const
inline

Definition at line 288 of file net.h.

Here is the call graph for this function:

template<typename Callable , typename CallableAfter >
void CConnman::ForEachNodeThen ( Callable &&  pre,
CallableAfter &&  post 
)
inline

Definition at line 298 of file net.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename Callable , typename CallableAfter >
void CConnman::ForEachNodeThen ( Callable &&  pre,
CallableAfter &&  post 
) const
inline

Definition at line 309 of file net.h.

Here is the call graph for this function:

bool CConnman::ForNode ( NodeId  id,
std::function< bool(CNode *pnode)>  func 
)

Definition at line 3038 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::GenerateSelectSet ( std::set< SOCKET > &  recv_set,
std::set< SOCKET > &  send_set,
std::set< SOCKET > &  error_set 
)
private

Definition at line 1269 of file net.cpp.

std::vector< AddedNodeInfo > CConnman::GetAddedNodeInfo ( )

Definition at line 2097 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< CAddress > CConnman::GetAddresses ( size_t  max_addresses,
size_t  max_pct 
)

Definition at line 2686 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector< CAddress > CConnman::GetAddresses ( CNode requestor,
size_t  max_addresses,
size_t  max_pct 
)

Cache is used to minimize topology leaks, so it should be used for all non-trusted calls, for example, p2p.

A non-malicious call (from RPC or a peer with addr permission) should call the function without a parameter to avoid using the cache.

Definition at line 2697 of file net.cpp.

Here is the call graph for this function:

int CConnman::GetBestHeight ( ) const

Definition at line 2948 of file net.cpp.

Here is the caller graph for this function:

std::vector< CAddress > CConnman::GetCurrentBlockRelayOnlyConns ( ) const
private

Return vector of current BLOCK_RELAY peers.

Definition at line 2084 of file net.cpp.

Here is the caller graph for this function:

CSipHasher CConnman::GetDeterministicRandomizer ( uint64_t  id) const

Get a unique deterministic randomizer.

Definition at line 3067 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int CConnman::GetExtraOutboundCount ( )

Definition at line 1846 of file net.cpp.

Here is the caller graph for this function:

ServiceFlags CConnman::GetLocalServices ( ) const

Used to convey which local services we are offering peers during node connection.

The data returned by this is used in CNode construction, which is used to advertise which services we are offering that peer during net_processing.cpp:PushNodeVersion().

Definition at line 2938 of file net.cpp.

uint64_t CConnman::GetMaxOutboundTarget ( )

Definition at line 2859 of file net.cpp.

uint64_t CConnman::GetMaxOutboundTimeframe ( )

Definition at line 2865 of file net.cpp.

uint64_t CConnman::GetMaxOutboundTimeLeftInCycle ( )

response the time in second left in the current max outbound cycle in case of no limit, it will always response 0

Definition at line 2871 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::GetNetworkActive ( ) const
inline

Definition at line 268 of file net.h.

Here is the caller graph for this function:

NodeId CConnman::GetNewNodeId ( )
private

Definition at line 2401 of file net.cpp.

Here is the caller graph for this function:

size_t CConnman::GetNodeCount ( NumConnections  num)

Definition at line 2763 of file net.cpp.

void CConnman::GetNodeStats ( std::vector< CNodeStats > &  vstats)

Definition at line 2779 of file net.cpp.

uint64_t CConnman::GetOutboundTargetBytesLeft ( )

response the bytes left in the current max outbound cycle in case of no limit, it will always response 0

Definition at line 2917 of file net.cpp.

unsigned int CConnman::GetReceiveFloodSize ( ) const

Definition at line 2953 of file net.cpp.

Here is the caller graph for this function:

uint64_t CConnman::GetTotalBytesRecv ( )

Definition at line 2926 of file net.cpp.

uint64_t CConnman::GetTotalBytesSent ( )

Definition at line 2932 of file net.cpp.

bool CConnman::GetTryNewOutboundPeer ( )

Definition at line 1829 of file net.cpp.

Here is the caller graph for this function:

bool CConnman::GetUseAddrmanOutgoing ( ) const
inline

Definition at line 269 of file net.h.

Here is the caller graph for this function:

uint64_t nTotalBytesRecv CConnman::GUARDED_BY ( cs_totalBytesRecv  )
inlineprivate

Definition at line 477 of file net.h.

uint64_t nTotalBytesSent CConnman::GUARDED_BY ( cs_totalBytesSent  )
inlineprivate

Definition at line 478 of file net.h.

uint64_t nMaxOutboundTotalBytesSentInCycle CConnman::GUARDED_BY ( cs_totalBytesSent  )
private
uint64_t nMaxOutboundCycleStartTime CConnman::GUARDED_BY ( cs_totalBytesSent  )
private
uint64_t nMaxOutboundLimit CConnman::GUARDED_BY ( cs_totalBytesSent  )
private
uint64_t nMaxOutboundTimeframe CConnman::GUARDED_BY ( cs_totalBytesSent  )
private
std::deque<std::string> m_addr_fetches CConnman::GUARDED_BY ( m_addr_fetches_mutex  )
private
std::vector<std::string> vAddedNodes CConnman::GUARDED_BY ( cs_vAddedNodes  )
private
std::vector<CNode*> vNodes CConnman::GUARDED_BY ( cs_vNodes  )
private
bool fMsgProcWake CConnman::GUARDED_BY ( mutexMsgProc  )
private

flag for waking the message processor.

void CConnman::InactivityCheck ( CNode pnode)
private

Definition at line 1236 of file net.cpp.

Here is the call graph for this function:

void CConnman::Init ( const Options connOptions)
inline

Definition at line 226 of file net.h.

Here is the caller graph for this function:

bool CConnman::InitBinds ( const std::vector< CService > &  binds,
const std::vector< NetWhitebindPermissions > &  whiteBinds,
const std::vector< CService > &  onion_binds 
)
private

Definition at line 2425 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::Interrupt ( )

Definition at line 2577 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::MarkAddressGood ( const CAddress addr)

Definition at line 2676 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::NodeFullyConnected ( const CNode pnode)
staticprivate

Definition at line 3000 of file net.cpp.

Here is the caller graph for this function:

void CConnman::NotifyNumConnectionsChanged ( )
private

Definition at line 1222 of file net.cpp.

void CConnman::OpenNetworkConnection ( const CAddress addrConnect,
bool  fCountFailure,
CSemaphoreGrant grantOutbound,
const char *  strDest,
ConnectionType  conn_type 
)

Definition at line 2179 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::OutboundTargetReached ( bool  historicalBlockServingLimit)

check if the outbound target is reached if param historicalBlockServingLimit is set true, the function will response true if the limit for serving historical blocks has been reached

Definition at line 2897 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int64_t CConnman::PoissonNextSendInbound ( int64_t  now,
int  average_interval_seconds 
)

Attempts to obfuscate tx time through exponentially distributed emitting.

Works assuming that a single interval is used. Variable intervals will result in privacy decrease.

Definition at line 3051 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::ProcessAddrFetch ( )
private

Definition at line 1812 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::PushMessage ( CNode pnode,
CSerializedNetMsg &&  msg 
)

Definition at line 3005 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::RecordBytesRecv ( uint64_t  bytes)
private

Definition at line 2830 of file net.cpp.

void CConnman::RecordBytesSent ( uint64_t  bytes)
private

Definition at line 2836 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::RemoveAddedNode ( const std::string &  node)

Definition at line 2751 of file net.cpp.

void CConnman::SetAsmap ( std::vector< bool >  asmap)
inline

Definition at line 404 of file net.h.

void CConnman::SetBestHeight ( int  height)

Definition at line 2943 of file net.cpp.

Here is the caller graph for this function:

void CConnman::SetMaxOutboundTarget ( uint64_t  limit)

set the max outbound target in bytes

Definition at line 2853 of file net.cpp.

void CConnman::SetMaxOutboundTimeframe ( uint64_t  timeframe)

set the timeframe for the max outbound target

Definition at line 2885 of file net.cpp.

Here is the call graph for this function:

void CConnman::SetNetworkActive ( bool  active)

Definition at line 2378 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::SetServices ( const CService addr,
ServiceFlags  nServices 
)

Definition at line 2671 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::SetTryNewOutboundPeer ( bool  flag)

Definition at line 1834 of file net.cpp.

Here is the caller graph for this function:

void CConnman::SocketEvents ( std::set< SOCKET > &  recv_set,
std::set< SOCKET > &  send_set,
std::set< SOCKET > &  error_set 
)
private

Definition at line 1358 of file net.cpp.

Here is the call graph for this function:

void CConnman::SocketHandler ( )
private

Definition at line 1433 of file net.cpp.

Here is the call graph for this function:

size_t CConnman::SocketSendData ( CNode pnode) const
private

Definition at line 808 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CConnman::Start ( CScheduler scheduler,
const Options options 
)

Definition at line 2452 of file net.cpp.

Here is the call graph for this function:

void CConnman::Stop ( )
inline

Definition at line 261 of file net.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::StopNodes ( )

Definition at line 2615 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::StopThreads ( )

Definition at line 2601 of file net.cpp.

Here is the caller graph for this function:

void CConnman::ThreadDNSAddressSeed ( )
private

Definition at line 1691 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::ThreadMessageHandler ( )
private

Definition at line 2214 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::ThreadOpenAddedConnections ( )
private

Definition at line 2151 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::ThreadOpenConnections ( std::vector< std::string >  connect)
private

Definition at line 1860 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::ThreadSocketHandler ( )
private

Definition at line 1557 of file net.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CConnman::WakeMessageHandler ( )

Definition at line 1567 of file net.cpp.

Here is the caller graph for this function:

Friends And Related Function Documentation

friend struct CConnmanTest
friend

Definition at line 609 of file net.h.

friend struct ConnmanTestMsg
friend

Definition at line 610 of file net.h.

Member Data Documentation

CAddrMan CConnman::addrman
private

Definition at line 499 of file net.h.

CClientUIInterface* CConnman::clientInterface
private

Definition at line 567 of file net.h.

std::condition_variable CConnman::condMsgProc
private

Definition at line 584 of file net.h.

RecursiveMutex CConnman::cs_totalBytesRecv
private

Definition at line 475 of file net.h.

RecursiveMutex CConnman::cs_totalBytesSent
private

Definition at line 476 of file net.h.

RecursiveMutex CConnman::cs_vAddedNodes
private

Definition at line 503 of file net.h.

RecursiveMutex CConnman::cs_vNodes
mutableprivate

Definition at line 506 of file net.h.

bool CConnman::fAddressesInitialized {false}
private

Definition at line 498 of file net.h.

std::atomic<bool> CConnman::flagInterruptMsgProc {false}
private

Definition at line 586 of file net.h.

std::atomic<bool> CConnman::fNetworkActive {true}
private

Definition at line 497 of file net.h.

CThreadInterrupt CConnman::interruptNet
private

Definition at line 588 of file net.h.

RecursiveMutex CConnman::m_addr_fetches_mutex
private

Definition at line 501 of file net.h.

std::map<uint64_t, CachedAddrResponse> CConnman::m_addr_response_caches
private

Addr responses stored in different caches per (network, local socket) prevent cross-network node identification.

If a node for example is multi-homed under Tor and IPv6, a single cache (or no cache at all) would let an attacker to easily detect that it is the same node by comparing responses. Indexing by local socket prevents leakage when a node has multiple listening addresses on the same network.

The used memory equals to 1000 CAddress records (or around 40 bytes) per distinct Network (up to 5) we have/had an inbound peer from, resulting in at most ~196 KB. Every separate local socket may add up to ~196 KB extra.

Definition at line 535 of file net.h.

std::vector<CAddress> CConnman::m_anchors
private

Addresses that were saved during the previous clean shutdown.

We'll attempt to make block-relay-only connections to them.

Definition at line 576 of file net.h.

BanMan* CConnman::m_banman
private

Pointer to this node's banman.

May be nullptr - check existence before dereferencing.

Definition at line 570 of file net.h.

int CConnman::m_max_outbound
private

Definition at line 564 of file net.h.

int CConnman::m_max_outbound_block_relay
private

Definition at line 560 of file net.h.

int CConnman::m_max_outbound_full_relay
private

Definition at line 556 of file net.h.

NetEventsInterface* CConnman::m_msgproc
private

Definition at line 568 of file net.h.

std::atomic<int64_t> CConnman::m_next_send_inv_to_incoming {0}
private

Definition at line 601 of file net.h.

std::vector<CService> CConnman::m_onion_binds
private

A vector of -bind=<address>:<port>=onion arguments each of which is an address and port that are designated for incoming Tor connections.

Definition at line 607 of file net.h.

int64_t CConnman::m_peer_connect_timeout
private

Definition at line 487 of file net.h.

std::atomic_bool CConnman::m_try_another_outbound_peer
private

flag for deciding to connect to an extra outbound peer, in excess of m_max_outbound_full_relay This takes the place of a feeler connection

Definition at line 599 of file net.h.

bool CConnman::m_use_addrman_outgoing
private

Definition at line 565 of file net.h.

Mutex CConnman::mutexMsgProc
private

Definition at line 585 of file net.h.

std::atomic<int> CConnman::nBestHeight
private

Definition at line 566 of file net.h.

std::atomic<NodeId> CConnman::nLastNodeId {0}
private

Definition at line 507 of file net.h.

ServiceFlags CConnman::nLocalServices
private

Services this instance offers.

This data is replicated in each CNode instance we create during peer connection (in ConnectNode()) under a member also called nLocalServices.

This data is not marked const, but after being set it should not change. See the note in CNode::nLocalServices documentation.

See Also
CNode::nLocalServices

Definition at line 549 of file net.h.

int CConnman::nMaxAddnode
private

Definition at line 562 of file net.h.

int CConnman::nMaxConnections
private

Definition at line 553 of file net.h.

int CConnman::nMaxFeeler
private

Definition at line 563 of file net.h.

unsigned int CConnman::nPrevNodeCount {0}
private

Definition at line 508 of file net.h.

unsigned int CConnman::nReceiveFloodSize {0}
private

Definition at line 494 of file net.h.

const uint64_t CConnman::nSeed0
private

SipHasher seeds for deterministic randomness.

Definition at line 579 of file net.h.

const uint64_t CConnman::nSeed1
private

Definition at line 579 of file net.h.

unsigned int CConnman::nSendBufferMaxSize {0}
private

Definition at line 493 of file net.h.

std::unique_ptr<CSemaphore> CConnman::semAddnode
private

Definition at line 552 of file net.h.

std::unique_ptr<CSemaphore> CConnman::semOutbound
private

Definition at line 551 of file net.h.

std::thread CConnman::threadDNSAddressSeed
private

Definition at line 590 of file net.h.

std::thread CConnman::threadMessageHandler
private

Definition at line 594 of file net.h.

std::thread CConnman::threadOpenAddedConnections
private

Definition at line 592 of file net.h.

std::thread CConnman::threadOpenConnections
private

Definition at line 593 of file net.h.

std::thread CConnman::threadSocketHandler
private

Definition at line 591 of file net.h.

std::vector<ListenSocket> CConnman::vhListenSocket
private

Definition at line 496 of file net.h.

std::list<CNode*> CConnman::vNodesDisconnected
private

Definition at line 505 of file net.h.

std::vector<NetWhitelistPermissions> CConnman::vWhitelistedRange
private

Definition at line 491 of file net.h.


The documentation for this class was generated from the following files: