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 (#1515)
  • Loading branch information
maschad committed Dec 16, 2022
1 parent 4058909 commit 24f7709
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 @@ -690,7 +690,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 24f7709

Please sign in to comment.