mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 13:02:38 +02:00
net: Remove forcedinbound limit antifeature
This commit is contained in:
parent
b0d90d2885
commit
a2225405a5
@ -1731,7 +1731,6 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
|
|||||||
const CAddress& addr)
|
const CAddress& addr)
|
||||||
{
|
{
|
||||||
int nInbound = 0;
|
int nInbound = 0;
|
||||||
int nForced{0};
|
|
||||||
|
|
||||||
AddWhitelistPermissionFlags(permission_flags, addr, vWhitelistedRangeIncoming);
|
AddWhitelistPermissionFlags(permission_flags, addr, vWhitelistedRangeIncoming);
|
||||||
|
|
||||||
@ -1739,7 +1738,6 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
|
|||||||
LOCK(m_nodes_mutex);
|
LOCK(m_nodes_mutex);
|
||||||
for (const CNode* pnode : m_nodes) {
|
for (const CNode* pnode : m_nodes) {
|
||||||
if (pnode->IsInboundConn()) nInbound++;
|
if (pnode->IsInboundConn()) nInbound++;
|
||||||
if (pnode->m_forced_inbound) nForced++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1780,12 +1778,6 @@ void CConnman::CreateNodeFromAcceptedSocket(std::unique_ptr<Sock>&& sock,
|
|||||||
bool forced{false};
|
bool forced{false};
|
||||||
if (nInbound >= m_max_inbound)
|
if (nInbound >= m_max_inbound)
|
||||||
{
|
{
|
||||||
// Protect from force evicting everyone
|
|
||||||
if (nForced >= MAX_FORCED_INBOUND_CONNECTIONS) {
|
|
||||||
LogPrint(BCLog::NET, "connection from %s dropped (too many forced inbound)\n", addr.ToStringAddrPort());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the inbound connection attempt is granted ForceInbound permission, try a little harder
|
// If the inbound connection attempt is granted ForceInbound permission, try a little harder
|
||||||
// to make room by evicting a peer we may not have otherwise evicted.
|
// to make room by evicting a peer we may not have otherwise evicted.
|
||||||
if (!AttemptToEvictConnection(NetPermissions::HasFlag(permission_flags, NetPermissionFlags::ForceInbound))) {
|
if (!AttemptToEvictConnection(NetPermissions::HasFlag(permission_flags, NetPermissionFlags::ForceInbound))) {
|
||||||
|
@ -85,8 +85,6 @@ static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT = 60;
|
|||||||
static const int NUM_FDS_MESSAGE_CAPTURE = 1;
|
static const int NUM_FDS_MESSAGE_CAPTURE = 1;
|
||||||
/** Interval for ASMap Health Check **/
|
/** Interval for ASMap Health Check **/
|
||||||
static constexpr std::chrono::hours ASMAP_HEALTH_CHECK_INTERVAL{24};
|
static constexpr std::chrono::hours ASMAP_HEALTH_CHECK_INTERVAL{24};
|
||||||
/** Maximum number of forced inbound connections **/
|
|
||||||
static const int MAX_FORCED_INBOUND_CONNECTIONS{8};
|
|
||||||
|
|
||||||
static constexpr bool DEFAULT_FORCEDNSSEED{false};
|
static constexpr bool DEFAULT_FORCEDNSSEED{false};
|
||||||
static constexpr bool DEFAULT_DNSSEED{true};
|
static constexpr bool DEFAULT_DNSSEED{true};
|
||||||
|
@ -160,16 +160,5 @@ class P2PEvict(BitcoinTestFramework):
|
|||||||
with node.assert_debug_log(["failed to find an eviction candidate - connection dropped (full)"]):
|
with node.assert_debug_log(["failed to find an eviction candidate - connection dropped (full)"]):
|
||||||
node.add_p2p_connection(RejectedPeer(), supports_v2_p2p=False, wait_for_verack=False)
|
node.add_p2p_connection(RejectedPeer(), supports_v2_p2p=False, wait_for_verack=False)
|
||||||
|
|
||||||
self.log.debug("Fill force_inbound slots")
|
|
||||||
for i in range(7):
|
|
||||||
allowed_peers.append(node.add_p2p_connection(P2PInterface(), dstport=30202))
|
|
||||||
|
|
||||||
self.log.debug("ForceInbound gets rejected after 8 evictions")
|
|
||||||
with node.assert_debug_log([f"dropped (too many forced inbound)"]):
|
|
||||||
node.add_p2p_connection(RejectedPeer(), supports_v2_p2p=False, dstport=30202, wait_for_verack=False)
|
|
||||||
|
|
||||||
assert_equal(len(node.getpeerinfo()), 10)
|
|
||||||
assert [peer.is_connected for peer in allowed_peers]
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
P2PEvict(__file__).main()
|
P2PEvict(__file__).main()
|
||||||
|
Loading…
Reference in New Issue
Block a user