mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
ISS telemetry relay: cap frames on the socket, time out the handshake, slower ladder for flapping sessions
- The feed socket is opened with maxPayload at the 64 KB frame cap and a 10 s handshake timeout: ws would otherwise buffer up to 100 MiB before the cap applied. - Only a session that has run a minute brings the retry ladder back to its first step, so a feed that sends a snapshot and then END keeps backing off; the ladder's later steps are tested. - The rate limit keys IPv6 clients by /64, and any path under the route is a JSON 404.
This commit is contained in:
1 parent
14814b4dab
commit
2c2e9de14d
2 files changed
+76
-9
No files matched your search
@@ -315,7 +315,7 @@ function install(plugin, preview = false) {
|
||||
plugin[preview ? 'configurePreviewServer' : 'configureServer']({
|
||||
middlewares: { use: (route, handler) => routes.set(route, handler) },
|
||||
});
|
||||
return (method = 'GET', headers = {}) => {
|
||||
return (method = 'GET', headers = {}, url = '/') => {
|
||||
const res = {
|
||||
headers: {},
|
||||
writeHead(status, headers) {
|
||||
@@ -329,10 +329,7 @@ function install(plugin, preview = false) {
|
||||
this.status ??= this.statusCode;
|
||||
},
|
||||
};
|
||||
routes.get(ISS_TELEMETRY_ROUTE)(
|
||||
{ url: '/', method, headers, socket: {} },
|
||||
res,
|
||||
);
|
||||
routes.get(ISS_TELEMETRY_ROUTE)({ url, method, headers, socket: {} }, res);
|
||||
return res;
|
||||
};
|
||||
}
|
||||
@@ -375,6 +372,10 @@ test('switched on, the route opens the feed once and serves the snapshot', () =>
|
||||
request();
|
||||
assert.equal(sockets.length, 1, 'one connection for every request');
|
||||
assert.equal(request('POST').status, 405);
|
||||
const unknown = request('GET', {}, '/anything');
|
||||
assert.equal(unknown.status, 404);
|
||||
assert.deepEqual(JSON.parse(unknown.body), { error: 'Not Found' });
|
||||
assert.equal(request('GET', {}, '/?t=1').status, 200, 'a query is fine');
|
||||
assert.equal(
|
||||
request('GET', { 'sec-fetch-site': 'cross-site' }).status,
|
||||
403,
|
||||
@@ -388,3 +389,42 @@ test('switched on, the route opens the feed once and serves the snapshot', () =>
|
||||
}
|
||||
assert.equal(sockets[0].terminated, true);
|
||||
});
|
||||
|
||||
test('a session that keeps ending soon after its snapshot climbs the retry ladder', () => {
|
||||
const { relay, sockets, clock } = relayAt(NOV_13);
|
||||
relay.demand();
|
||||
/** The current socket opens, sends a snapshot update, then ends. */
|
||||
const shortSession = () => {
|
||||
const socket = sockets.at(-1);
|
||||
socket.emit('open');
|
||||
socket.emit('message', 'CONOK,S1,50000,5000,*');
|
||||
socket.emit(
|
||||
'message',
|
||||
`U,1,${index('S0000004')},${stampOf(clock.ms)}|17|24`,
|
||||
);
|
||||
socket.emit('message', 'END,41,session closed');
|
||||
};
|
||||
// Each wait is the next step: 5 s, 15 s, 60 s, then 5 minutes.
|
||||
for (const wait of [5_000, 15_000, 60_000, 300_000, 300_000]) {
|
||||
shortSession();
|
||||
const before = sockets.length;
|
||||
clock.ms += wait - 1_000;
|
||||
relay.demand();
|
||||
assert.equal(sockets.length, before, `not before ${wait / 1000} s`);
|
||||
clock.ms += 1_000;
|
||||
relay.demand();
|
||||
assert.equal(sockets.length, before + 1, `again after ${wait / 1000} s`);
|
||||
}
|
||||
// A session that runs a minute before its updates brings the ladder down.
|
||||
const socket = sockets.at(-1);
|
||||
socket.emit('open');
|
||||
socket.emit('message', 'CONOK,S1,50000,5000,*');
|
||||
clock.ms += 60_000;
|
||||
relay.demand();
|
||||
socket.emit('message', `U,1,${index('S0000004')},${stampOf(clock.ms)}|17|24`);
|
||||
socket.emit('message', 'END,41,session closed');
|
||||
const before = sockets.length;
|
||||
clock.ms += 5_000;
|
||||
relay.demand();
|
||||
assert.equal(sockets.length, before + 1, 'back to 5 s');
|
||||
});
|
||||
Reference in new issue
Block a user