Mise à jour de GitLab prévue ce samedi 23 octobre 2021 à partir de 9h00 CET

Commit 5647a1f4 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

[fix] Trim duplicated INCOMING connections

parent db65bfbd
......@@ -116,6 +116,7 @@ export class WS2PServer extends events.EventEmitter {
}
async trimConnections() {
/*** OVERFLOW TRIMMING ***/
let disconnectedOne = true
// Disconnect non-members
while (disconnectedOne && this.connections.length > this.maxLevel2Size) {
......@@ -136,6 +137,22 @@ export class WS2PServer extends events.EventEmitter {
this.removeConnection(c)
}
}
/*** DUPLICATES TRIMMING ***/
disconnectedOne = true
while (disconnectedOne) {
disconnectedOne = false
const pubkeysFound = []
for (const c of this.connections) {
if (pubkeysFound.indexOf(c.pubkey) !== -1) {
c.close()
this.removeConnection(c)
disconnectedOne = true
}
else if (c.pubkey !== this.server.conf.pair.pub) {
pubkeysFound.push(c.pubkey)
}
}
}
}
private removeConnection(c:WS2PConnection) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment