Bitcoin
|
#include <net.h>
Classes | |
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) } |
Public Member Functions | |
void | Init (const Options &connOptions) |
CConnman (uint64_t seed0, uint64_t seed1) | |
~CConnman () | |
bool | Start (CScheduler &scheduler, const Options &options) |
void | Stop () NO_THREAD_SAFETY_ANALYSIS |
void | Interrupt () |
bool | GetNetworkActive () const |
bool | GetUseAddrmanOutgoing () const |
void | SetNetworkActive (bool active) |
void | OpenNetworkConnection (const CAddress &addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound=nullptr, const char *strDest=nullptr, bool fOneShot=false, bool fFeeler=false, bool manual_connection=false) |
bool | CheckIncomingNonce (uint64_t nonce) |
bool | ForNode (NodeId id, std::function< bool(CNode *pnode)> func) |
void | PushMessage (CNode *pnode, CSerializedNetMsg &&msg) |
template<typename Callable > | |
void | ForEachNode (Callable &&func) |
template<typename Callable > | |
void | ForEachNode (Callable &&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 |
size_t | GetAddressCount () const |
void | SetServices (const CService &addr, ServiceFlags nServices) |
void | MarkAddressGood (const CAddress &addr) |
void | AddNewAddresses (const std::vector< CAddress > &vAddr, const CAddress &addrFrom, int64_t nTimePenalty=0) |
std::vector< CAddress > | GetAddresses () |
void | SetTryNewOutboundPeer (bool flag) |
bool | GetTryNewOutboundPeer () |
int | GetExtraOutboundCount () |
bool | AddNode (const std::string &node) |
bool | RemoveAddedNode (const std::string &node) |
std::vector< AddedNodeInfo > | GetAddedNodeInfo () |
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 |
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) |
uint64_t | GetOutboundTargetBytesLeft () |
uint64_t | GetMaxOutboundTimeLeftInCycle () |
uint64_t | GetTotalBytesRecv () |
uint64_t | GetTotalBytesSent () |
void | SetBestHeight (int height) |
int | GetBestHeight () const |
CSipHasher | GetDeterministicRandomizer (uint64_t id) const |
unsigned int | GetReceiveFloodSize () const |
void | WakeMessageHandler () |
int64_t | PoissonNextSendInbound (int64_t now, int average_interval_seconds) |
Private Member Functions | |
bool | BindListenPort (const CService &bindAddr, std::string &strError, bool fWhitelisted=false) |
bool | Bind (const CService &addr, unsigned int flags) |
bool | InitBinds (const std::vector< CService > &binds, const std::vector< CService > &whiteBinds) |
void | ThreadOpenAddedConnections () |
void | AddOneShot (const std::string &strDest) |
void | ProcessOneShot () |
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 |
CNode * | FindNode (const CNetAddr &ip) |
CNode * | FindNode (const CSubNet &subNet) |
CNode * | FindNode (const std::string &addrName) |
CNode * | FindNode (const CService &addr) |
bool | AttemptToEvictConnection () |
CNode * | ConnectNode (CAddress addrConnect, const char *pszDest, bool fCountFailure, bool manual_connection) |
bool | IsWhitelistedRange (const CNetAddr &addr) |
void | DeleteNode (CNode *pnode) |
NodeId | GetNewNodeId () |
size_t | SocketSendData (CNode *pnode) const |
void | DumpAddresses () |
void | RecordBytesRecv (uint64_t bytes) |
void | RecordBytesSent (uint64_t bytes) |
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 > vOneShots | GUARDED_BY (cs_vOneShots) |
std::vector< std::string > vAddedNodes | GUARDED_BY (cs_vAddedNodes) |
std::vector< CNode * > vNodes | GUARDED_BY (cs_vNodes) |
Static Private Member Functions | |
static bool | NodeFullyConnected (const CNode *pnode) |
Friends | |
struct | CConnmanTest |
CConnman::~CConnman | ( | ) |
|
private |
void CConnman::AddNewAddresses | ( | const std::vector< CAddress > & | vAddr, |
const CAddress & | addrFrom, | ||
int64_t | nTimePenalty = 0 |
||
) |
bool CConnman::AddNode | ( | const std::string & | node | ) |
|
private |
|
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.
|
private |
|
private |
bool CConnman::CheckIncomingNonce | ( | uint64_t | nonce | ) |
|
private |
debug print
|
private |
bool CConnman::DisconnectNode | ( | const std::string & | node | ) |
bool CConnman::DisconnectNode | ( | const CSubNet & | subnet | ) |
bool CConnman::DisconnectNode | ( | const CNetAddr & | addr | ) |
bool CConnman::DisconnectNode | ( | NodeId | id | ) |
|
private |
|
private |
|
private |
|
inline |
|
inline |
|
inline |
|
inline |
|
private |
std::vector< AddedNodeInfo > CConnman::GetAddedNodeInfo | ( | ) |
size_t CConnman::GetAddressCount | ( | ) | const |
std::vector< CAddress > CConnman::GetAddresses | ( | ) |
int CConnman::GetBestHeight | ( | ) | const |
CSipHasher CConnman::GetDeterministicRandomizer | ( | uint64_t | id | ) | const |
Get a unique deterministic randomizer.
int CConnman::GetExtraOutboundCount | ( | ) |
ServiceFlags CConnman::GetLocalServices | ( | ) | const |
uint64_t CConnman::GetMaxOutboundTarget | ( | ) |
uint64_t CConnman::GetMaxOutboundTimeframe | ( | ) |
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
|
inline |
|
private |
size_t CConnman::GetNodeCount | ( | NumConnections | num | ) |
void CConnman::GetNodeStats | ( | std::vector< CNodeStats > & | vstats | ) |
uint64_t CConnman::GetOutboundTargetBytesLeft | ( | ) |
response the bytes left in the current max outbound cycle in case of no limit, it will always response 0
unsigned int CConnman::GetReceiveFloodSize | ( | ) | const |
uint64_t CConnman::GetTotalBytesRecv | ( | ) |
uint64_t CConnman::GetTotalBytesSent | ( | ) |
bool CConnman::GetTryNewOutboundPeer | ( | ) |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
inline |
|
private |
void CConnman::Interrupt | ( | ) |
|
private |
void CConnman::MarkAddressGood | ( | const CAddress & | addr | ) |
|
staticprivate |
|
private |
void CConnman::OpenNetworkConnection | ( | const CAddress & | addrConnect, |
bool | fCountFailure, | ||
CSemaphoreGrant * | grantOutbound = nullptr , |
||
const char * | strDest = nullptr , |
||
bool | fOneShot = false , |
||
bool | fFeeler = false , |
||
bool | manual_connection = false |
||
) |
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
Attempts to obfuscate tx time through exponentially distributed emitting. Works assuming that a single interval is used. Variable intervals will result in privacy decrease.
|
private |
void CConnman::PushMessage | ( | CNode * | pnode, |
CSerializedNetMsg && | msg | ||
) |
|
private |
|
private |
bool CConnman::RemoveAddedNode | ( | const std::string & | node | ) |
void CConnman::SetBestHeight | ( | int | height | ) |
void CConnman::SetMaxOutboundTarget | ( | uint64_t | limit | ) |
set the max outbound target in bytes
void CConnman::SetMaxOutboundTimeframe | ( | uint64_t | timeframe | ) |
set the timeframe for the max outbound target
void CConnman::SetNetworkActive | ( | bool | active | ) |
void CConnman::SetServices | ( | const CService & | addr, |
ServiceFlags | nServices | ||
) |
void CConnman::SetTryNewOutboundPeer | ( | bool | flag | ) |
|
private |
|
private |
|
private |
bool CConnman::Start | ( | CScheduler & | scheduler, |
const Options & | options | ||
) |
void CConnman::Stop | ( | ) |
|
private |
|
private |
|
private |
|
private |
|
private |
void CConnman::WakeMessageHandler | ( | ) |
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
mutableprivate |
|
private |
|
private |
|
private |
|
private |
flag for waking the message processor.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
flag for deciding to connect to an extra outbound peer, in excess of nMaxOutbound This takes the place of a feeler connection
|
private |
|
private |
|
private |
|
private |
|
private |
Services this instance offers
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
SipHasher seeds for deterministic randomness
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |