aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorGleb Naumenko <naumenko.gs@gmail.com>2021-09-14 14:54:40 +0300
committerstratospher <44024636+stratospher@users.noreply.github.com>2023-03-15 20:12:03 +0530
commit3faae99c3d8e512f9d3f6e7fb0785c60d4bed654 (patch)
tree9c147ffdadbbf26cc35f5a5a51078a9e330bc84e /src/net.cpp
parent8c4958bd4c06026dc108bc7f5f063d1f389d279b (diff)
p2p: Diversify connections only w.r.t *persistent* outbound peers
ADDR_FETCH and FEELER are short-lived connections, and they should not affect our choice of peers. Also, improve comments.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/net.cpp b/src/net.cpp
index d1895b7172..e19decbda8 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1721,19 +1721,22 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
if (pnode->IsFullOutboundConn()) nOutboundFullRelay++;
if (pnode->IsBlockOnlyConn()) nOutboundBlockRelay++;
- // 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:
+ // Manually selected connections should not affect how we select outbound
+ // peers from addrman.
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::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
}