Skip to content

Commit

Permalink
fix: should not prune a peer that is in the allow list once the conne…
Browse files Browse the repository at this point in the history
…ction limit is reached (libp2p#1515)
  • Loading branch information
maschad committed Jan 7, 2023
1 parent d8c8e8c commit 80dc00d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/connection-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,15 @@ export class DefaultConnectionManager extends EventEmitter<ConnectionManagerEven

for (const connection of sortedConnections) {
log('too many connections open - closing a connection to %p', connection.remotePeer)
toClose.push(connection)
// check allow list
const connectionInAllowList = this.allow.some((ma) => {
return ma.getPeerId() === connection.remotePeer.toString()
})

// Connections in the allow list should be excluded from pruning
if (!connectionInAllowList) {
toClose.push(connection)
}

if (toClose.length === toPrune) {
break
Expand Down

0 comments on commit 80dc00d

Please sign in to comment.