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 Jan 16, 2023
1 parent fd41aa2 commit 9344798
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 @@ -681,7 +681,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 9344798

Please sign in to comment.