Limit pings like messages in the tracker
ws answered every ping on its own, past the message rate limit and past the bound on bytes queued for a peer: a client pinging without reading made the tracker buffer pongs until it ran out of memory. Pongs are now sent by the tracker, pings and pongs count as messages, and a pong is queued only within the same bound as any message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
22d794965e
commit
4725b14a40
2 files changed
+28
-4
No files matched your search
@@ -234,6 +234,22 @@ test('limits the message rate', async () => {
|
||||
await rejected(client, fields, 'too many messages');
|
||||
});
|
||||
|
||||
test('limits pings like messages, also from a peer that stops reading', async () => {
|
||||
// ws's client, browsers send no pings. ws used to answer every one, its pongs piled up in the tracker.
|
||||
const client = new ServerSocket(url, { headers: { origin: ORIGIN, 'x-forwarded-for': ip } });
|
||||
const closed = once(client, 'close');
|
||||
const reasons = [];
|
||||
client.on('message', (data) => reasons.push(JSON.parse(data)['failure reason']));
|
||||
await once(client, 'open');
|
||||
client.ping('x');
|
||||
expect(String((await once(client, 'pong'))[0])).toBe('x');
|
||||
client._socket.pause();
|
||||
for (let i = 0; i < 1000; i++) client.ping('x'.repeat(125));
|
||||
client._socket.resume();
|
||||
await closed;
|
||||
expect(reasons).toEqual(['too many messages']);
|
||||
});
|
||||
|
||||
test('limits the signaling forwarded per connection', async () => {
|
||||
const { hash, receiver } = await swarm();
|
||||
const big = () => ({ offer_id: id(), offer: sdp('offer', 'x'.repeat(15_000)) });
|
||||
|
||||
Reference in new issue
Block a user