feat: hardware bans, panel search and logs, jam-a-gram and wall post logs

- the client (1.3.0) sends one-way hashes of the device's ids at
  sign-in; the server keys them again with a secret of its own
  (data/device-key) and keeps them per account (lib/devices.js). a
  sign-in without them is refused with 426 (AJ_REQUIRE_DEVICE=0 lets it
  in), so 1.2 clients cannot sign in.
- hardware bans: every device an account used in the last 90 days.
  any id but a network card blocks sign-in, sign-up and the game, on
  any account. a network card match, ids that look altered, or a device
  shared with a banned player raise hardware alerts instead.
- both panels: hardware ban and lift, the account's hardware ids,
  search by hardware id, other accounts by device or address, a
  timeline (bans, staff actions, reports, alerts), and hardware bans
  and alerts in the bans tab.
- jam-a-grams and wall posts go into the chat log, the filtered ones
  marked not sent. chat search filters by kind, by what the filter
  stopped, and from a time back; each player's page lists their
  jam-a-grams and wall posts, sent and received.
- account search runs on the server and ranks exact names first, then
  names starting with the search; the admin panel no longer downloads
  every account. hidden tabs only refresh the waiting counts in the
  title. masterpieces can be searched by maker, approved ones too.
  reports can show the reported player's chat at the time. links follow
  the open tab and player.
- admin actions on accounts go into the moderator log.
- privacy policy covers hardware hashes and the new logs.
This commit is contained in:
Burrowdev committed 2026-10-17 23:54:46 +03:00
1 parent 0e86592d40
commit cf729d52dc
21 files changed
+1898 -131

No files matched your search

+53 -12
View File
@@ -8,6 +8,7 @@ const bans = require("./bans.js");
const captcha = require("./captcha.js");
const chatlog = require("./chatlog.js");
const config = require("../config.js");
const devices = require("./devices.js");
const limits = require("./limits.js");
const manage = require("./manage.js");
const masterpieces = require("./masterpieces.js");
@@ -44,7 +45,6 @@ const SESSION_HOURS = 12;
const TEN_MINUTES_MS = 600000;
const MAX_BAN_HOURS = 24 * 365 * 10;
const MAX_MESSAGE_LENGTH = 200;
const MAX_FOUND = 50;
const failuresByAddress = limits.limiter(config.failedLoginsPerTenMinutes, TEN_MINUTES_MS);
const actionsPerTenMinutes = limits.limiter(300, TEN_MINUTES_MS); // per moderator
@@ -99,19 +99,17 @@ const playerRow = (account, playing) => {
playtime: account.playtime,
bio: account.bio,
discord: account.discord,
deviceBanned: devices.bannedId(account) !== 0,
};
};
const playing = () => new Map(world.players().map(player => [player.username, player.room || "(between rooms)"]));
// by name (lib/staff.js says in what order).
const findPlayers = query => {
const wanted = String(query || "").trim().toLowerCase().slice(0, 100);
const online = playing();
return accounts.all()
.filter(account => account.username.toLowerCase().includes(wanted))
.sort((a, b) => Number(online.has(b.username)) - Number(online.has(a.username)) || a.username.localeCompare(b.username))
.slice(0, MAX_FOUND)
.map(account => playerRow(account, online));
const {found, total} = staff.findAccounts(query);
return {players: found.map(account => playerRow(account, online)), total};
};
// one player: the row, what was done about their bans (without addresses),
@@ -121,6 +119,9 @@ const playerDetail = account => ({
history: bans.historyOf(account).map(({at, action, seconds, reason, by}) => ({at, action, seconds, reason, by})),
appeal: bans.appealOf(account),
openReports: reports.list(false).filter(report => report.target.toLowerCase() === account.username.toLowerCase()).length,
devicesKnown: devices.knownFor(account).ids,
stoppedThisWeek: chatlog.notSentCount(account, 7),
paintings: masterpieces.madeBy(account).length,
});
// an address with its end left out, and a name to lift its ban by.
@@ -213,6 +214,11 @@ const act = (mod, target, body) => {
}
return {ok: "Their address is banned.", detail: result.ban.reason};
}
// every computer they signed in from lately (lib/devices.js).
case "banDevices":
return staff.banDevices(target, body.reason, by);
case "unbanDevices":
return staff.unbanDevicesOf(target, by);
default:
return {error: "Unknown action."};
}
@@ -339,9 +345,36 @@ const handle = async (req, res, url, from, web) => {
paintings: masterpieces.list(masterpieces.PENDING).length});
return;
// other accounts the same person may have, and their story (lib/staff.js).
case "GET /mod/api/alts": {
const account = accounts.byName(url.searchParams.get("username") || "");
reply(account ? 200 : 404, account ? {alts: staff.altsOf(account), ids: devices.idsFor(account)} : {error: "No such player."});
return;
}
case "GET /mod/api/timeline": {
const account = accounts.byName(url.searchParams.get("username") || "");
reply(account ? 200 : 404, account ? {events: staff.timelineOf(account)} : {error: "No such player."});
return;
}
// who the server's chat filter stopped most this week.
case "GET /mod/api/filterhits":
reply(200, {players: chatlog.mostStopped(7, 50)});
return;
case "GET /mod/api/players": {
if (url.searchParams.get("by") !== "address") {
reply(200, {players: findPlayers(url.searchParams.get("q"))});
const searchBy = url.searchParams.get("by");
if (searchBy === "device") {
const found = staff.byDevice(url.searchParams.get("q"));
if (found.error) {
reply(400, found);
return;
}
const online = playing();
reply(200, {players: found.players.map(entry => ({...playerRow(accounts.byName(entry.username), online), matchedAt: entry.lastAt}))});
return;
}
if (searchBy !== "address") {
reply(200, findPlayers(url.searchParams.get("q")));
return;
}
// by address: only the address typed, which is written down (once
@@ -386,7 +419,8 @@ const handle = async (req, res, url, from, web) => {
case "GET /mod/api/chat": {
const params = url.searchParams;
const lines = chatlog.search({username: (params.get("username") || "").trim().slice(0, 100), room: (params.get("room") || "").trim().slice(0, 100),
text: (params.get("text") || "").trim().slice(0, 100), before: Number(params.get("before")) || 0});
text: (params.get("text") || "").trim().slice(0, 100), kind: params.get("kind") || "", direction: params.get("direction") || "", until: Number(params.get("until")) || 0,
before: Number(params.get("before")) || 0});
reply(200, {lines, more: lines.length === chatlog.PAGE, days: config.chatLogDays});
return;
}
@@ -426,7 +460,7 @@ const handle = async (req, res, url, from, web) => {
}
case "GET /mod/api/bans":
reply(200, {accounts: staff.disciplined(), addresses: bans.addressBans().map(maskedAddress)});
reply(200, {accounts: staff.disciplined(), addresses: bans.addressBans().map(maskedAddress), devices: devices.list(), alerts: devices.alerts()});
return;
case "POST /mod/api/address": {
@@ -435,9 +469,16 @@ const handle = async (req, res, url, from, web) => {
return;
}
// A device ban lifted (lib/devices.js).
case "POST /mod/api/device": {
const result = staff.unbanDevices(body.id, mod.username);
done(result, "hardware ban lifted", result.username || "");
return;
}
// paintings players framed (lib/masterpieces.js).
case "GET /mod/api/masterpieces":
reply(200, {waiting: masterpieces.list(masterpieces.PENDING), approved: masterpieces.list(masterpieces.APPROVED)});
reply(200, {...masterpieces.listsFor(url.searchParams.get("creator")), waitingCount: masterpieces.list(masterpieces.PENDING).length});
return;
case "GET /mod/api/masterpiece": {