Structured Komodo port diagnostics + probe button
komodoResolveGamePort silently returned null for six distinct failure
modes (unconfigured, no-name, unreachable, http-error, unparseable,
no-udp-in-response), which made "no game_port — Komodo did not return
one" indistinguishable from an auth failure or an unrecognized response
shape. Adds komodoResolvePortDetailed returning a discriminated union
with the failure reason, HTTP status, and a truncated response snippet.
extractUdpPort broadens to cover four more shapes seen in the wild:
extra host-port field names (HostPort/hostPort/host_port/PublicPort),
`type` as a protocol alias, host-network strings ("28962/udp"), and the
docker-inspect container-keyed form ({ "28960/udp": [{ HostPort }] }).
Arrays reached via a ports-flavored key now win over accidental matches
elsewhere in the tree.
New POST /api/servers/[name]/probe-komodo triggers a fresh lookup,
caches the port on success, and returns the structured result. The RCON
diagnostic panel gains a Probe Komodo button (shown when endpoint is
unresolved and Komodo is configured) that renders the snippet inline —
so unrecognized shapes surface directly instead of vanishing.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { json } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { komodoResolvePortDetailed } from '$lib/server/integrations/komodo.js';
|
||||
import { getServer, setServerField } from '$lib/server/fleet/servers.js';
|
||||
|
||||
/**
|
||||
* Trigger a fresh Komodo GetDeployment lookup for a specific server and
|
||||
* return the structured result — including a snippet of the response so
|
||||
* the UI can render "here's where we found the port" (or "here's what
|
||||
* Komodo returned; extend extractUdpPort for this shape").
|
||||
*
|
||||
* On success, the resolved port is written to servers.game_port so the
|
||||
* next RCON attempt uses it without waiting for another sweep tick.
|
||||
*/
|
||||
export const POST: RequestHandler = async ({ params }) => {
|
||||
const name = params.name;
|
||||
if (!name) return json({ ok: false, reason: 'no-name', detail: 'missing server name' }, { status: 400 });
|
||||
|
||||
const row = getServer(name);
|
||||
if (!row) return json({ ok: false, reason: 'no-name', detail: `unknown server: ${name}` }, { status: 404 });
|
||||
|
||||
const result = await komodoResolvePortDetailed(name);
|
||||
if (result.ok) {
|
||||
setServerField(name, 'game_port', result.port);
|
||||
}
|
||||
return json(result);
|
||||
};
|
||||
Reference in New Issue
Block a user