Skip to content

Conversation

pranavkonde
Copy link

Fixes #3238

Problem

When using WithAllowlistedMultiaddrs with peer-specific multiaddrs (e.g. /ip4/1.2.3.0/ipcidr/24/p2p/QmPeer), the network prefix was not being added to the connection limiter. This meant users had to use both WithAllowlistedMultiaddrs and WithNetworkPrefixLimit to achieve the desired effect.

Solution

Updated the resource manager initialization to check both allowlist.allowedNetworks and allowlist.allowedPeerByNetwork when setting up connection limiter network prefix limits. This ensures that any network prefixes specified in peer-specific allowlist entries are also added to the connection limiter.

Changes

  • Added logic to iterate through allowlist.allowedPeerByNetwork and add any network prefixes to the connection limiter
  • Added tracking of registered prefixes to avoid duplicates
  • Used the same connection count limit from GetAllowlistedSystemLimits() for consistency
  • Added test case to verify peer-specific allowlisted multiaddrs properly update the connection limiter

Testing

Added a new test case "IPv4 with peer ID" that verifies:

  • Network prefixes from peer-specific allowlisted multiaddrs are added to the connection limiter
  • The correct connection count limit is applied
  • No duplicate prefixes are added when the same prefix appears in both general and peer-specific allowlist entries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rcmgr.WithAllowlistedMultiaddrs should update connLimiter network prefix limits

1 participant