Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
merge bitcoin#27264: Improve diversification of new connections
  • Loading branch information
kwvg committed Sep 12, 2024
commit 3465df2689ea7b9fbdb67fc41afc90f705d20dde
17 changes: 9 additions & 8 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2482,19 +2482,20 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect, CDe
if (pnode->IsBlockOnlyConn()) nOutboundBlockRelay++;
if (pnode->IsFullOutboundConn() && pnode->ConnectedThroughNetwork() == Network::NET_ONION) nOutboundOnionRelay++;

// Netgroups for inbound and manual peers are not excluded because our goal here
// is to not use multiple of our limited outbound slots on a single netgroup
// but inbound and manual peers do not use our outbound slots. Inbound peers
// also have the added issue that they could be attacker controlled and used
// to prevent us from connecting to particular hosts if we used them here.
// Make sure our persistent outbound slots belong to different netgroups.
switch (pnode->m_conn_type) {
// We currently don't take inbound connections into account. Since they are
// free to make, an attacker could make them to prevent us from connecting to
// certain peers.
case ConnectionType::INBOUND:
case ConnectionType::MANUAL:
// Short-lived outbound connections should not affect how we select outbound
// peers from addrman.
case ConnectionType::ADDR_FETCH:
case ConnectionType::FEELER:
break;
case ConnectionType::MANUAL:
case ConnectionType::OUTBOUND_FULL_RELAY:
case ConnectionType::BLOCK_RELAY:
case ConnectionType::ADDR_FETCH:
case ConnectionType::FEELER:
setConnected.insert(m_netgroupman.GetGroup(pnode->addr));
} // no default case, so the compiler can warn about missing cases
}
Expand Down