Skip to content

Commit 1c3484b

Browse files
committed
fix: should not prune a peer that is in the allow list once the connection limit is reached (#1515)
1 parent cccd34e commit 1c3484b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/connection-manager/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,15 @@ export class DefaultConnectionManager extends EventEmitter<ConnectionManagerEven
671671

672672
for (const connection of sortedConnections) {
673673
log('too many connections open - closing a connection to %p', connection.remotePeer)
674-
toClose.push(connection)
674+
// check allow list
675+
const connectionInAllowList = this.allow.some((ma) => {
676+
return ma.getPeerId() === connection.remotePeer.toString()
677+
})
678+
679+
// Connections in the allow list should be excluded from pruning
680+
if (!connectionInAllowList) {
681+
toClose.push(connection)
682+
}
675683

676684
if (toClose.length === toPrune) {
677685
break

0 commit comments

Comments
 (0)