diff options
| author | Pieter Wuille <[email protected]> | 2015-03-05 04:01:22 -0800 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2015-06-27 14:15:32 +0000 |
| commit | b8ad0859552ac9f64b790606fd84c76538e318a5 (patch) | |
| tree | e5bf7520f931ddfa844929b109efbe84ac162eb9 | |
| parent | Limit message sizes before transfer (diff) | |
| download | discoin-b8ad0859552ac9f64b790606fd84c76538e318a5.tar.xz discoin-b8ad0859552ac9f64b790606fd84c76538e318a5.zip | |
Reduce fingerprinting through timestamps in 'addr' messages.
Suggested by Jonas Nick.
Rebased-From: 9c2737901b5203f267d21d728019d64b46f1d9f3
Github-Pull: #5860
| -rw-r--r-- | src/addrman.cpp | 3 | ||||
| -rw-r--r-- | src/main.cpp | 20 |
2 files changed, 17 insertions, 6 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp index 3628af2ea..79545e13c 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -279,8 +279,9 @@ void CAddrMan::Good_(const CService &addr, int64_t nTime) // update info info.nLastSuccess = nTime; info.nLastTry = nTime; - info.nTime = nTime; info.nAttempts = 0; + // nTime is not updated here, to avoid leaking information about + // currently-connected peers. // if it is already in the tried set, don't do anything else if (info.fInTried) diff --git a/src/main.cpp b/src/main.cpp index 23abbef9a..9d1eca948 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -207,6 +207,10 @@ struct CBlockReject { // processing of incoming data is done after the ProcessMessage call returns, // and we're no longer holding the node's locks. struct CNodeState { + //! The peer's address + CService address; + //! Whether we have a fully established connection. + bool fCurrentlyConnected; // Accumulated misbehaviour score for this peer. int nMisbehavior; // Whether this peer should be disconnected and banned (unless whitelisted). @@ -223,6 +227,7 @@ struct CNodeState { int64_t nLastBlockProcess; CNodeState() { + fCurrentlyConnected = false; nMisbehavior = 0; fShouldBan = false; nBlocksToDownload = 0; @@ -253,12 +258,16 @@ void InitializeNode(NodeId nodeid, const CNode *pnode) { LOCK(cs_main); CNodeState &state = mapNodeState.insert(std::make_pair(nodeid, CNodeState())).first->second; state.name = pnode->addrName; + state.address = pnode->addr; } void FinalizeNode(NodeId nodeid) { LOCK(cs_main); CNodeState *state = State(nodeid); + if (state->nMisbehavior == 0 && state->fCurrentlyConnected) { + AddressCurrentlyConnected(state->address); + } BOOST_FOREACH(const QueuedBlock& entry, state->vBlocksInFlight) mapBlocksInFlight.erase(entry.hash); BOOST_FOREACH(const uint256& hash, state->vBlocksToDownload) @@ -3871,6 +3880,12 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, else if (strCommand == "verack") { pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); + + // Mark this node as currently connected, so we update its timestamp later. + if (pfrom->fNetworkNode) { + LOCK(cs_main); + State(pfrom->GetId())->fCurrentlyConnected = true; + } } @@ -4432,11 +4447,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, } - // Update the last seen time for this node's address - if (pfrom->fNetworkNode) - if (strCommand == "version" || strCommand == "addr" || strCommand == "inv" || strCommand == "getdata" || strCommand == "ping") - AddressCurrentlyConnected(pfrom->addr); - return true; } |