Changeset View
Changeset View
Standalone View
Standalone View
src/net.h
Show First 20 Lines • Show All 136 Lines • ▼ Show 20 Lines | struct Options { | ||||
int nMaxFeeler = 0; | int nMaxFeeler = 0; | ||||
int nBestHeight = 0; | int nBestHeight = 0; | ||||
CClientUIInterface *uiInterface = nullptr; | CClientUIInterface *uiInterface = nullptr; | ||||
unsigned int nSendBufferMaxSize = 0; | unsigned int nSendBufferMaxSize = 0; | ||||
unsigned int nReceiveFloodSize = 0; | unsigned int nReceiveFloodSize = 0; | ||||
uint64_t nMaxOutboundTimeframe = 0; | uint64_t nMaxOutboundTimeframe = 0; | ||||
uint64_t nMaxOutboundLimit = 0; | uint64_t nMaxOutboundLimit = 0; | ||||
std::vector<std::string> vSeedNodes; | std::vector<std::string> vSeedNodes; | ||||
std::vector<CSubNet> vWhitelistedRange; | |||||
std::vector<CService> vBinds, vWhiteBinds; | |||||
}; | }; | ||||
CConnman(const Config &configIn, uint64_t seed0, uint64_t seed1); | CConnman(const Config &configIn, uint64_t seed0, uint64_t seed1); | ||||
~CConnman(); | ~CConnman(); | ||||
bool Start(CScheduler &scheduler, std::string &strNodeError, | |||||
Options options); | bool Start(CScheduler &scheduler, Options options); | ||||
void Stop(); | void Stop(); | ||||
void Interrupt(); | void Interrupt(); | ||||
bool BindListenPort(const CService &bindAddr, std::string &strError, | |||||
bool fWhitelisted = false); | |||||
bool GetNetworkActive() const { return fNetworkActive; }; | bool GetNetworkActive() const { return fNetworkActive; }; | ||||
void SetNetworkActive(bool active); | void SetNetworkActive(bool active); | ||||
bool OpenNetworkConnection(const CAddress &addrConnect, bool fCountFailure, | bool OpenNetworkConnection(const CAddress &addrConnect, bool fCountFailure, | ||||
CSemaphoreGrant *grantOutbound = nullptr, | CSemaphoreGrant *grantOutbound = nullptr, | ||||
const char *strDest = nullptr, | const char *strDest = nullptr, | ||||
bool fOneShot = false, bool fFeeler = false, | bool fOneShot = false, bool fFeeler = false, | ||||
bool fAddnode = false); | bool fAddnode = false); | ||||
bool CheckIncomingNonce(uint64_t nonce); | bool CheckIncomingNonce(uint64_t nonce); | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | public: | ||||
size_t GetNodeCount(NumConnections num); | size_t GetNodeCount(NumConnections num); | ||||
void GetNodeStats(std::vector<CNodeStats> &vstats); | void GetNodeStats(std::vector<CNodeStats> &vstats); | ||||
bool DisconnectNode(const std::string &node); | bool DisconnectNode(const std::string &node); | ||||
bool DisconnectNode(NodeId id); | bool DisconnectNode(NodeId id); | ||||
unsigned int GetSendBufferSize() const; | unsigned int GetSendBufferSize() const; | ||||
void AddWhitelistedRange(const CSubNet &subnet); | |||||
ServiceFlags GetLocalServices() const; | ServiceFlags GetLocalServices() const; | ||||
//! set the max outbound target in bytes. | //! set the max outbound target in bytes. | ||||
void SetMaxOutboundTarget(uint64_t limit); | void SetMaxOutboundTarget(uint64_t limit); | ||||
uint64_t GetMaxOutboundTarget(); | uint64_t GetMaxOutboundTarget(); | ||||
//! set the timeframe for the max outbound target. | //! set the timeframe for the max outbound target. | ||||
void SetMaxOutboundTimeframe(uint64_t timeframe); | void SetMaxOutboundTimeframe(uint64_t timeframe); | ||||
Show All 30 Lines | private: | ||||
struct ListenSocket { | struct ListenSocket { | ||||
SOCKET socket; | SOCKET socket; | ||||
bool whitelisted; | bool whitelisted; | ||||
ListenSocket(SOCKET socket_, bool whitelisted_) | ListenSocket(SOCKET socket_, bool whitelisted_) | ||||
: socket(socket_), whitelisted(whitelisted_) {} | : socket(socket_), whitelisted(whitelisted_) {} | ||||
}; | }; | ||||
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 ThreadOpenAddedConnections(); | ||||
void AddOneShot(const std::string &strDest); | void AddOneShot(const std::string &strDest); | ||||
void ProcessOneShot(); | void ProcessOneShot(); | ||||
void ThreadOpenConnections(); | void ThreadOpenConnections(); | ||||
void ThreadMessageHandler(); | void ThreadMessageHandler(); | ||||
void AcceptConnection(const ListenSocket &hListenSocket); | void AcceptConnection(const ListenSocket &hListenSocket); | ||||
void ThreadSocketHandler(); | void ThreadSocketHandler(); | ||||
void ThreadDNSAddressSeed(); | void ThreadDNSAddressSeed(); | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | private: | ||||
uint64_t nMaxOutboundTotalBytesSentInCycle; | uint64_t nMaxOutboundTotalBytesSentInCycle; | ||||
uint64_t nMaxOutboundCycleStartTime; | uint64_t nMaxOutboundCycleStartTime; | ||||
uint64_t nMaxOutboundLimit; | uint64_t nMaxOutboundLimit; | ||||
uint64_t nMaxOutboundTimeframe; | uint64_t nMaxOutboundTimeframe; | ||||
// Whitelisted ranges. Any node connecting from these is automatically | // Whitelisted ranges. Any node connecting from these is automatically | ||||
// whitelisted (as well as those connecting to whitelisted binds). | // whitelisted (as well as those connecting to whitelisted binds). | ||||
std::vector<CSubNet> vWhitelistedRange; | std::vector<CSubNet> vWhitelistedRange; | ||||
CCriticalSection cs_vWhitelistedRange; | |||||
unsigned int nSendBufferMaxSize; | unsigned int nSendBufferMaxSize; | ||||
unsigned int nReceiveFloodSize; | unsigned int nReceiveFloodSize; | ||||
std::vector<ListenSocket> vhListenSocket; | std::vector<ListenSocket> vhListenSocket; | ||||
std::atomic<bool> fNetworkActive; | std::atomic<bool> fNetworkActive; | ||||
banmap_t setBanned; | banmap_t setBanned; | ||||
CCriticalSection cs_setBanned; | CCriticalSection cs_setBanned; | ||||
▲ Show 20 Lines • Show All 466 Lines • Show Last 20 Lines |