diff --git a/server/src/index.ts b/server/src/index.ts index 2ffe470..5b20b7c 100644 --- a/server/src/index.ts +++ b/server/src/index.ts @@ -95,6 +95,8 @@ const galleryVoices = new RateLimit(30, 10 * 60 * 1000); const bells = new RateLimit(3, 60 * 60 * 1000); /** Claims on transfer phrases: a phrase is guessed, not brute-forced. */ const claims = new RateLimit(10, 10 * 60 * 1000); +/** Searches for lost seats: each reads every table written to lately, and a person loses their seats rarely. */ +const searches = new RateLimit(5, 10 * 60 * 1000); const MAX_AUDIENCE = 30; /** How often each socket is asked to answer; one silent through a whole round is a browser gone, and is closed. */ const PING_MS = Number(process.env.PING_MS ?? 30_000); @@ -107,6 +109,7 @@ setInterval(() => { galleryVoices.prune(); bells.prune(); claims.prune(); + searches.prune(); if (n) console.log(`evicted ${n} idle room${n === 1 ? '' : 's'} from memory; ${rooms.loaded} loaded`); }, 60 * 60 * 1000).unref(); @@ -345,7 +348,7 @@ async function handle(req: IncomingMessage, res: ServerResponse): Promise return send(res, 200, { seats }); } if (parts[2] === 'find' && parts.length === 3) { - if (!claims.allow(clientOf(req))) throw new RoomError('Too many searches from here just now; try again later.', 429); + if (!searches.allow(clientOf(req))) throw new RoomError('Too many searches from here just now; try again later.', 429); const found = rooms.findSeats(String(body.name ?? ''), addrOf(req), typeof body.roomId === 'string' ? body.roomId : undefined); // The seats given back are banked at once, so the cookie and the browser agree. if (found.seated.length) bankSeats(req, res, provenBank(req, found.seated, [])); diff --git a/src/lib/components/Hall.svelte b/src/lib/components/Hall.svelte index 79f0305..781e2d6 100644 --- a/src/lib/components/Hall.svelte +++ b/src/lib/components/Hall.svelte @@ -139,7 +139,7 @@ if (r.seated.length) seats = allSeats(); const back = r.seated.length ? `Seated again at ${r.seated.map((s) => s.roomId).join(', ')}.` : ''; const n = r.elsewhere; - const ask = n ? ` ${n === 1 ? 'One more table' : `${n} more tables`} in play ${n === 1 ? 'has' : 'have'} a seat under your name, last used from another address, or given to a bot by the host: ask the host there for a transfer phrase, or write to the keeper.` : ''; + const ask = n ? ` ${n === 1 ? 'One more table' : `${n} more tables`} in play ${n === 1 ? 'has' : 'have'} a seat under your name, last used from another address, or given to a housecarl by the host: ask the host there for a transfer phrase, or write to the keeper.` : ''; found = back + ask || 'No table still in play has a seat under that name.'; } catch (e) { error = e instanceof Error ? e.message : 'The search did not go through.'; diff --git a/src/routes/join/[code]/+page.svelte b/src/routes/join/[code]/+page.svelte index 4e5d096..2cdf07c 100644 --- a/src/routes/join/[code]/+page.svelte +++ b/src/routes/join/[code]/+page.svelte @@ -130,7 +130,7 @@ const r = await api.findSeats(name.trim(), roomId).catch(() => null); const mine = r?.seated.find((s) => s.roomId === roomId); if (!mine) { - if (r?.elsewhere) error = 'A seat here is under that name, but it was last used from another address, or the host gave it to a bot. Ask the host for a transfer phrase, or write to the keeper.'; + if (r?.elsewhere) error = 'A seat here is under that name, but it was last used from another address, or the host gave it to a housecarl. Ask the host for a transfer phrase, or write to the keeper.'; return false; } rememberSeat(roomId, { seat: mine.seat, token: mine.token });