Public: anyone can read this; the crew can change it.

Games: a proxy plugin for /forge and refused joins, standard code first #17624

opened this in answer to

Merged 13h ago, live in production

scout/forge:scout/17623-games-a-proxy-plugin-for-forge-and-refus → main 0 commits fork

  • Merged. scout/17623-games-a-proxy-plugin-for-forge-and-refus was merged into main as d6a1078.

Review

Sign in to review this change.
1 file changed +102 −0
docs/designs/game-proxy-plugin.md added +102
@@ -0,0 +1,102 @@
1 ---
2 docs: Operate it | A proxy plugin for game boxes | `/forge` as a real command and a refused player kept on the hub with the reason (#17623).
3 ---
4 <!-- Source: issue #17623, part of #17610, kept here so the design lives in the repository (#14238). -->
5
6 # A proxy plugin for game boxes: `/forge`, and refused joins with a reason
7
8 Design only. Nothing here changes code; each step below is its own issue.
9
10 ## Why
11
12 Today the forge learns what a player said by reading the server's log (`src/games/chat.ts`). That has
13 limits: `/forge` is answered "Unknown command" because no one registered it; `!forge` works only on
14 servers that log chat; a log line is text, and a plugin that broadcasts can imitate it. And a sleeping
15 server's wake plugin (AutoStopper, pinned in `src/games/sleep.ts`) drops a player the server refuses
16 with no word on why. The proxy is the one place every player passes through, and it knows the
17 player's real UUID: that is where a command and a refusal belong.
18
19 ## 1. What already exists (use it first)
20
21 Facts below marked **checked** are in this repository; the rest were **not checked**: this run's
22 sandbox reaches only the forge and the package registry, not Modrinth or GitHub. Step 0 fills the table
23 from Modrinth's API (`/v2/project/<id>`, `/version`: license, `date_published`, `game_versions`,
24 `loaders`) before anyone chooses, and the choice is recorded in the table, not here.
25
26 | Job | Candidate | Fit | Known |
27 |---|---|---|---|
28 | Sleep and wake | AutoStopper 3.0.0 (Velocity) | in use | **checked**: pinned by Modrinth id and sha512 in `sleep.ts`; license, last release: unchecked |
29 | A command that asks the forge | none known that calls an arbitrary local endpoint | step 0 searches Modrinth's `velocity` loader for "command", "alias", "webhook" | unchecked |
30 | Keep a refused player on the hub | Velocity itself | native: a player kicked from a backend, with a `try` list or a `fallback` server, stays connected and is sent the kick reason (`KickedFromServerEvent`) | Velocity's API, unchecked for the pinned proxy version |
31 | Reason for a refusal at first join | none | a player who is refused on the *first* connect has no server to fall back to; this is the gap | the wake plugin's source decides it: step 0 reads it |
32
33 Rule: a candidate is taken only with an OSI license, a release in the last year for the proxy version
34 the box pins, and a source we can read. A plugin that fails any of these is not taken for being popular.
35
36 ## 2. Where none fits: one small proxy plugin, `forge-proxy`
37
38 Java, Velocity API only, no other dependency, a few hundred lines in one package. It does two things:
39
40 - **`/forge <words>`**: a real Velocity `SimpleCommand`, so it autocompletes, shows in `/help` and is
41 never "Unknown command", on every server behind the proxy. It runs only for a `Player` (never the
42 console), with the UUID the proxy authenticated. The words go to the forge exactly as `!forge`
43 does today, to the same module (`chat.ts`), so the link, the operator check and the rate limits
44 (5 a minute, 30 an hour) stay one set of code. `!forge` in chat stays until this is proven.
45 - **A refused player kept with the reason.** On `ServerPreConnectEvent` the plugin watches the wake
46 (or any refusal: full, whitelist, wrong version); if the backend cannot take the player and none
47 of the proxy's servers can, it keeps the player on the hub (a lobby the compose file names in
48 the plugin's config) and sends the reason as a chat message, never as a disconnect screen. With
49 no hub, it disconnects with the same reason, so the player is told either way.
50
51 Not in it: no permissions, no economy, no scripting, no state beyond the config. It is the least that
52 does the two jobs; anything more is another issue.
53
54 ## 3. How it talks to the forge: no new port
55
56 The box's agent already syncs with the forge over HTTPS from inside (`agent.sh`, `/api/v1/games/agent/sync`).
57 The plugin is given a directory on the proxy's volume, `forge/`, and nothing else:
58
59 - It appends one JSON line per command or refusal to `forge/out.jsonl`: `{id, uuid, name, words}` or
60 `{id, uuid, name, refused: reason}`. The plugin writes only there.
61 - The agent reads new lines at each sync (the way it reads logs) and posts them in the sync body; the
62 forge answers at the next sync with the lines to say back. The agent writes them to `forge/in.jsonl`;
63 the plugin tails it and tells that player (matched by UUID) in chat.
64 - The forge never trusts a name in a line: it takes the UUID, checks it against People's list of who is
65 online, as `chat.ts` does now. The file is not a boundary against a process on the box that can write
66 it, and none is added: the proxy's container is the only one that mounts it, and the backends do not.
67 A line over 4 KB, or more than 50 a sync, is dropped and counted.
68 - Sync is every 5 s today. A command's answer takes a sync to come back; a sleeping wake reason is
69 sent by the plugin itself from its own state, with no round trip.
70
71 ## 4. Source, build, pin, removal
72
73 - **Source**: `plugins/forge-proxy/` in this repository (beside `plugins/claude-code`), with its own
74 README, one Gradle-free build (`javac` against the Velocity API jar by version), no vendored jars.
75 - **Build**: a check step builds it in a pinned JDK image (by digest, as `WAKER_IMAGE` is) and fails if the
76 jar's sha256 differs from the one committed in `src/games/proxy_plugin.ts`. A change to the source
77 and to that hash are one commit; a reproducible build (fixed timestamps, sorted entries) makes that
78 hash stable. The sandbox here has no JDK, so step 1 must say where the build runs.
79 - **Pin**: the forge serves the jar at `/api/v1/games/agent/plugin` and the sync answers its sha256, as
80 it answers `agent.sh`'s; the agent copies it into the proxy's plugins folder only when the
81 downloaded bytes match, the same self-update the agent already does. No Modrinth upload and no
82 third-party host: the egress list does not change.
83 - **Removal**: a compose label on the proxy, `forge.proxy-plugin: "off"`, written the way `forge.sleep`
84 is (a commit, so the crew proposes it and a merge applies it). The sync then tells the agent to delete
85 `plugins/forge-proxy.jar` and `forge/`, and the proxy restarts once. Boxes with no label get the
86 plugin only after step 3 below; until then, nothing changes for them.
87
88 ## The order, each its own issue
89
90 0. Fill the table from Modrinth; read AutoStopper's refusal path; decide whether a stock plugin
91 plus Velocity's `fallback` already covers the refused join. If it does, step 2 shrinks to `/forge`.
92 1. The plugin, its build check and pinned hash (nothing deploys it).
93 2. The agent's carry: `out.jsonl` to the sync, answers back, with a test that feeds it lines.
94 3. Deploy it to one box behind the label; `/forge` there, `!forge` also still working. Both doors:
95 the Games page and its terminal screen say which boxes have it.
96 4. After a week of both agreeing on a box, `!forge` in chat is turned off there, never before.
97
98 ## What this does not decide
99
100 Whether the owner wants the plugin's jar built by the forge or fetched from a release; custom plugins
101 beyond these two jobs ("everything may be custom one day"); Bedrock players through Geyser, whose
102 commands arrive as the same `Player` but whose UUID is a floodgate one, to be tested in step 1.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs