Skip to content

Commit 533500d

Browse files
committed
p2p: Add timeout for AddrFetch peers
If AddrFetch peers don't send us addresses, disconnect them after a while.
1 parent b6c5d1e commit 533500d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/net_processing.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4364,6 +4364,12 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
43644364

43654365
const auto current_time = GetTime<std::chrono::microseconds>();
43664366

4367+
if (pto->IsAddrFetchConn() && current_time - std::chrono::seconds(pto->nTimeConnected) > 10 * AVG_ADDRESS_BROADCAST_INTERVAL) {
4368+
LogPrint(BCLog::NET, "addrfetch connection timeout; disconnecting peer=%d\n", pto->GetId());
4369+
pto->fDisconnect = true;
4370+
return true;
4371+
}
4372+
43674373
MaybeSendPing(*pto, *peer, current_time);
43684374

43694375
// MaybeSendPing may have marked peer for disconnection

0 commit comments

Comments
 (0)