import { rconServers } from "@minecraft-account-manager/database"; import { asc } from "drizzle-orm"; import { RconConsole, type RconTerminalNotice } from "@/components/rcon-console"; import { db } from "@/lib/database"; export const dynamic = "force-dynamic"; const savedMessages: Record = { created: "RCON connection created.", updated: "RCON connection updated.", enabled: "RCON connection enabled.", disabled: "RCON connection disabled.", deleted: "RCON connection deleted.", tested: "RCON authentication succeeded.", }; const errorMessages: Record = { "invalid-connection": "Enter a valid DNS hostname, port, name, and password.", "duplicate-name": "Connection names must be unique.", configuration: "RCON credential encryption is not configured.", "save-failed": "The RCON connection could not be saved.", "unknown-connection": "That RCON connection no longer exists.", "confirmation-required": "Confirm the connection before deleting it.", "connection-unavailable": "The connection is invalid or its credential is unavailable.", "test-busy": "Another RCON operation is already using that server.", "test-timeout": "RCON authentication timed out.", "test-unavailable": "The RCON server was unavailable or rejected authentication.", }; function queryValue(value: string | string[] | undefined) { return Array.isArray(value) ? value[0] : value; } export default async function RconPage({ searchParams, }: { searchParams: Promise>; }) { const query = await searchParams; const saved = queryValue(query.saved); const error = queryValue(query.error); const notice: RconTerminalNotice | undefined = error ? { status: "error", message: errorMessages[error] ?? "The RCON operation failed." } : saved ? { status: "success", message: savedMessages[saved] ?? "RCON settings saved." } : undefined; const servers = await db.select({ id: rconServers.id, name: rconServers.name, host: rconServers.host, port: rconServers.port, enabled: rconServers.enabled, }).from(rconServers).orderBy(asc(rconServers.name)); return (

Server operations

RCON

Select and manage a connection, then run commands through the portal backend. Credentials are never sent to the browser.

Command proxy

Terminal

Only the latest bounded response is shown. Commands and responses are not saved as console history.

); }