aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2016-04-17 20:21:58 -0400
committerCory Fields <cory-nospam-@coryfields.com>2016-09-08 12:24:06 -0400
commit960cf2e4058a9c195bf64e1aecb46024f9ef022a (patch)
tree4f1400221f79419d8942fe48961c4ef24886c0e3 /src/net.h
parent551e0887db9034b1e6490a267ba864b1d26ff469 (diff)
net: move nLocalHostNonce to CConnman
This behavior seems to have been quite racy and broken. Move nLocalHostNonce into CNode, and check received nonces against all non-fully-connected nodes. If there's a match, assume we've connected to ourself.
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/net.h b/src/net.h
index 36043b0b8c..32668045c5 100644
--- a/src/net.h
+++ b/src/net.h
@@ -114,6 +114,7 @@ public:
void Stop();
bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = NULL, const char *strDest = NULL, bool fOneShot = false, bool fFeeler = false);
+ bool CheckIncomingNonce(uint64_t nonce);
bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func);
bool ForEachNode(std::function<bool(CNode* pnode)> func);
@@ -297,7 +298,6 @@ extern bool fListen;
extern ServiceFlags nLocalServices;
extern ServiceFlags nRelevantServices;
extern bool fRelayTxes;
-extern uint64_t nLocalHostNonce;
/** Maximum number of connections to simultaneously allow (aka connection slots) */
extern int nMaxConnections;
@@ -523,12 +523,17 @@ private:
static uint64_t CalculateKeyedNetGroup(const CAddress& ad);
+ uint64_t nLocalHostNonce;
public:
NodeId GetId() const {
return id;
}
+ uint64_t GetLocalNonce() const {
+ return nLocalHostNonce;
+ }
+
int GetRefCount()
{
assert(nRefCount >= 0);