web/network/server-control
Repository files (latest commit first)
Filename Latest commit message Latest commit date
unimatrixgit 77cdf19faa Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence
Preserve the current Alpha source and artwork snapshot. See handoff/alpha-1.0.0.3 for actual deployed hashes, checks, staged follow-ups and the production pause. This checkpoint does not claim every source feature is deployed.
2026-11-02 00:05:34 +01:00
..
agent.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
clan_bank.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
kit_commerce.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
managed-game-permissions.json Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
managed_game_roles.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
player_bank.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
player_kits.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
quest_engine.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
README.md Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
server_game_roles.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_agent.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_bank_routes.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_clan_bank.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_kit_allocations.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_kit_authority.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_kit_commerce.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_kit_routes.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_managed_game_roles.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_managed_permission_routes.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_player_bank.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_player_kits.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_quest_engine.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00
test_server_game_roles.py Checkpoint Alpha 1.0.0.3 graphical menus and moderation evidence 2026-11-02 00:05:34 +01:00

DuneRealms server controls

Two-host deployment (29 October 2026)

The same standard-library agent now has three fixed deployment modes, selected only by the service environment DUNE_CONTROL_MODE. Invalid values abort startup. No request can select a host, URL, unit name, filesystem path or binding address.

Mode Local units / ban sources Remote units Bind
legacy (default for rollback) Existing Arrakis, lobby and proxy None 127.0.0.1:25573
gateway (old host) dune-lobby, dune-proxy; lobby ban file only Arrakis, Kaitain, Giedi Prime through fixed http://10.77.0.2:25573 127.0.0.1:25573
planets (new host) dune-arrakis, dune-kaitain, dune-giedi_prime None 10.77.0.2:25573

Both agents read the same existing private capability from /etc/dunerealms-server-control.secret; no credential is committed. Add Environment=DUNE_CONTROL_MODE=gateway to the old service and Environment=DUNE_CONTROL_MODE=planets to the new service, then reload systemd/restart the agent. The new service must start after wg-quick@wg0.service (or the actual fixed WireGuard unit) and have read access to its three planet folders and write access to their console FIFOs. Keep the existing filesystem sandbox. New planet directories are /opt/dunerealms/servers/arrakis, /opt/dunerealms/servers/kaitain and /opt/dunerealms/servers/giedi_prime.

Do not expose port 25573 publicly. The new host's firewall should permit it only from the old host's WireGuard address. HTTP is transported inside WireGuard; the gateway disables HTTP environment proxies and all redirects so the bearer cannot move to another destination. Responses have a 256-KiB cap. Existing website SSH forwarding remains unchanged: website loopback15433 → old host loopback25573.

The gateway returns five server cards. An unavailable or malformed remote status creates three explicit unavailable planet cards while preserving the two local service cards. Actions/logs relay only enumerated internal IDs arrakis, kaitain, giedi_prime; power jobs and one-line command validation/cooldown remain authoritative at the planet agent. A relay timeout never reports success and never retries a mutation automatically. An operator must refresh status before choosing whether to retry. Existing duplicate/running-action checks prevent immediate replay; this API does not promise exactly-once service/console execution after an ambiguous network timeout.

Ban reads aggregate the lobby and all three planet sources. Missing/malformed/unreachable sources fail the entire read with503; an outage cannot masquerade as an empty ban register. Removal of a remote ban forwards its exact original created snapshot and UUID key. The planet agent retains both before-write and confirmation-loop stale-ban guards, fixed UUID-only pardon, source-file validation and console FIFO checks. The gateway accepts removal200 only when ok, confirmed and absent are all true and the exact requested key matches. A timeout, conflict, malformed success or changed key never approves an appeal.

LuckPerms editor/apply commands relay to the new Arrakis console. Validation remains fixed lp editor groups, lp applyedits <code> or lp trusteditor <code> with current actor attribution; no arbitrary command or remote URL is used. The gateway validates returned editor URLs against exact https://luckperms.net/editor/<session> and redacts sessions in logs. Before the database cutover, group listing retains the old local PostgreSQL query. At cutover, explicitly set DUNE_LUCKPERMS_MYSQL=1: it reads fixed luckperms_groups/luckperms_group_permissions tables from central duneluckperms, using /etc/dunerealms-luckperms-mysql.json. Failure never silently falls back to stale PostgreSQL. The planet agent deliberately rejects group reads.

Website integration requires only control-panel/server-control.mjs, control-panel/public/servers.js and control-panel/public/servers.html. These add the two fixed IDs, dropdown labels and Velocity status mapping (giedi_prime → giedi-prime). Do not replace the entire live CP server during this rollout. Current website rank/node and Origin checks remain unchanged.

The global DuneBan provider adds fixed network scope and reports globalConnected=true only after the shared gameplay ban query succeeds. Its MySQL removal transaction locks the same InnoDB player-lock row as DuneBan, checks the original UTC millisecond creation value, records revocation metadata, and verifies absence after commit. Failure, replacement, malformed snapshot or unavailable database never returns confirmed removal. Local scope and network scope remain distinct even for the same player UUID.

Both central MySQL reads use private SSH forwards: host 127.0.0.1, port 13307, not an exposed database listener. /etc/dunerealms-gameplay-mysql.json requires database dunegameplay; /etc/dunerealms-luckperms-mysql.json requires duneluckperms; both files contain root-provisioned username and password. PyMySQL (and its MySQL8 authentication dependencies) must be installed. No request can alter these endpoints or credentials. Global provider startup must follow schema provisioning and the authenticated tunnel.

Validation: 29 Python tests cover legacy operations, isolated host modes, remote identity/path allowlists, malformed responses, exact ban confirmation, new-planet stale-ban guards, failed-source aggregation, action replay/cooldown, no-redirect transport, bounded responses, authentication, LuckPerms routing/explicit MySQL cutover, and parameterized global ban transactions. Five CP server-control tests cover current authorization, actor attribution, fixed planet IDs and injected-target rejection. Three ban-feed tests validate all five scopes and ensure malformed/unavailable sources do not retire stored history. These are automated tests; deployment and authenticated live relay smoke checks are separate.

The separate server-operations page is https://cp.dunerealms.com/servers, linked from account Administration. It preserves the account panel at the root. It manages the three existing systemd services: Arrakis, the Vaerkring lobby and the Velocity gateway. It does not create or reset worlds.

Capabilities: status, player counts, service memory, recent journal output, start/stop/restart, and one-line console commands for the two Paper servers. Proxy console input is deliberately unavailable because that service has no console FIFO. Actions are asynchronous and their outcome appears in status. Console command acceptance means delivery to the server; inspect logs for command success.

Access requires the current website session, staff role and an explicit username in private SERVER_CONTROL_OPERATORS. Registration/staff membership alone cannot gain server control. Mutations require the exact CP Origin. The backend replaces any supplied actor with the signed-in username and audits action type/target before dispatch; command text and credentials are not written into account audit rows.

agent.py is a standard-library Python service on game-host loopback port 25573. It accepts a separate 64-character bearer from /etc/dunerealms-server-control.secret. Only fixed units and fixed FIFO paths are available; no shell command execution or arbitrary file paths. FIFO writes use non-blocking, no-follow opens and validate the descriptor type. Each server accepts one operation at a time with a cooldown. Journal credential patterns are redacted.

The existing SSH tunnel now also forwards website-loopback 15433 to game-loopback 25573. Its restricted account key permits only PostgreSQL 5432 and control 25573 destinations. Agent port 25573 is not public. Website private settings: SERVER_CONTROL_TOKEN and SERVER_CONTROL_OPERATORS. No credentials belong in this directory.

Agent systemd service: dunerealms-server-control; existing tunnel: dunerealms-inventory-tunnel. The agent needs system service control and console FIFO access, and runs under a read-only filesystem sandbox with private temporary files. Deploy agent changes to /opt/dunerealms/server-control/agent.py and restart its service. Tests: python3 -m unittest discover -s network/server-control -p test_agent.py and the website test suite.

Live deployment 28 October 2026: website release 20261028-server-panel, 60 website tests and 4 Python agent tests passed. Authenticated status, logs, a harmless list command and an idempotent start of the active Arrakis service passed through the public HTTPS API. Foreign-origin writes returned 403; unauthenticated controls returned 401. Browser review confirmed the operator interface. No real restart was required for the panel acceptance test.

The normal account dashboard also embeds these controls under a Servers navigation tab. The embedded view uses the same session and operator checks, hides duplicate site chrome, and reports only its layout height to its same-origin parent. The CP framing policy explicitly permits itself and the main website; other origins remain blocked.