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:
@@ -7,6 +7,16 @@
|
||||
import PlayerRoster from '$ui/components/PlayerRoster.svelte';
|
||||
import { gametypeLabel } from '$ui/gametype.js';
|
||||
import { decodeRconError, rconFixHint } from '$ui/rconError.js';
|
||||
import { komodoFixHint, type KomodoPortFailure } from '$ui/komodoError.js';
|
||||
|
||||
interface KomodoProbeResult {
|
||||
ok: boolean;
|
||||
port?: number;
|
||||
reason?: KomodoPortFailure;
|
||||
detail?: string;
|
||||
httpStatus?: number;
|
||||
snippet?: string;
|
||||
}
|
||||
|
||||
interface Server {
|
||||
name: string;
|
||||
@@ -81,6 +91,37 @@
|
||||
if (!ep) return 'unresolved';
|
||||
return `${ep.host}:${ep.port}`;
|
||||
}
|
||||
|
||||
let komodoProbe = $state<KomodoProbeResult | null>(null);
|
||||
let probing = $state(false);
|
||||
|
||||
async function probeKomodo(): Promise<void> {
|
||||
if (probing || !name) return;
|
||||
probing = true;
|
||||
komodoProbe = null;
|
||||
try {
|
||||
const res = await fetch(`/api/servers/${encodeURIComponent(name)}/probe-komodo`, {
|
||||
method: 'POST'
|
||||
});
|
||||
komodoProbe = (await res.json()) as KomodoProbeResult;
|
||||
// On success, refresh the server row so the endpoint field
|
||||
// updates from `unresolved` to `host:port` without a full reload.
|
||||
if (komodoProbe.ok && server) {
|
||||
const srvRes = await fetch('/api/servers');
|
||||
const srvBody = (await srvRes.json()) as { servers: Server[]; integrations: Integrations };
|
||||
server = srvBody.servers.find((s) => s.name === name) ?? server;
|
||||
integrations = srvBody.integrations;
|
||||
}
|
||||
} catch (err) {
|
||||
komodoProbe = {
|
||||
ok: false,
|
||||
reason: 'unreachable',
|
||||
detail: (err as Error).message
|
||||
};
|
||||
} finally {
|
||||
probing = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if server}
|
||||
@@ -139,6 +180,46 @@
|
||||
<span class="reason-detail">{effectiveErr}</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if !effectiveEndpoint && integrations.komodo}
|
||||
<div class="probe-row">
|
||||
<button class="probe-btn" onclick={probeKomodo} disabled={probing}>
|
||||
{probing ? 'probing komodo…' : 'probe komodo'}
|
||||
</button>
|
||||
<span class="probe-hint">Ask Komodo for this server's UDP port now.</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if komodoProbe}
|
||||
{#if komodoProbe.ok}
|
||||
<div class="probe-result probe-ok">
|
||||
<span class="probe-tag ok">resolved</span>
|
||||
<span class="probe-detail">
|
||||
Port <strong>{komodoProbe.port}</strong> cached to server row — RCON will retry on the next tick.
|
||||
</span>
|
||||
</div>
|
||||
{#if komodoProbe.snippet}
|
||||
<details class="snippet-details">
|
||||
<summary>show response snippet</summary>
|
||||
<pre class="snippet">{komodoProbe.snippet}</pre>
|
||||
</details>
|
||||
{/if}
|
||||
{:else}
|
||||
<div class="probe-result probe-bad">
|
||||
<span class="probe-tag bad">{komodoProbe.reason}</span>
|
||||
<span class="probe-detail">
|
||||
{komodoProbe.detail}
|
||||
{#if komodoProbe.httpStatus} · HTTP {komodoProbe.httpStatus}{/if}
|
||||
</span>
|
||||
</div>
|
||||
{#if komodoProbe.reason}
|
||||
<div class="hint">{komodoFixHint(komodoProbe.reason, komodoProbe.httpStatus)}</div>
|
||||
{/if}
|
||||
{#if komodoProbe.snippet}
|
||||
<pre class="snippet">{komodoProbe.snippet}</pre>
|
||||
{/if}
|
||||
{/if}
|
||||
{/if}
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
@@ -350,6 +431,107 @@
|
||||
border-radius: var(--r-sm);
|
||||
}
|
||||
|
||||
.probe-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
margin-top: 14px;
|
||||
}
|
||||
.probe-btn {
|
||||
background: var(--cherry-875);
|
||||
color: var(--cream);
|
||||
border: 1px solid var(--spark-500);
|
||||
border-radius: var(--r-sm);
|
||||
padding: 7px 14px;
|
||||
font-family: var(--font-body);
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.3px;
|
||||
cursor: pointer;
|
||||
transition: box-shadow 0.15s, background 0.15s;
|
||||
}
|
||||
.probe-btn:hover:not(:disabled) {
|
||||
box-shadow: var(--spark-glow);
|
||||
background: var(--cherry-825);
|
||||
}
|
||||
.probe-btn:disabled { opacity: 0.5; cursor: default; }
|
||||
.probe-hint {
|
||||
color: var(--ink-500);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
.probe-result {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-top: 12px;
|
||||
padding: 10px 14px;
|
||||
border-radius: var(--r-sm);
|
||||
border: 1px solid transparent;
|
||||
}
|
||||
.probe-ok {
|
||||
background: rgba(34, 224, 255, 0.08);
|
||||
border-color: rgba(34, 224, 255, 0.3);
|
||||
}
|
||||
.probe-bad {
|
||||
background: rgba(255, 48, 80, 0.08);
|
||||
border-color: rgba(255, 48, 80, 0.25);
|
||||
}
|
||||
.probe-tag {
|
||||
padding: 2px 8px;
|
||||
border-radius: var(--r-sm);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 10px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 1px;
|
||||
border: 1px solid transparent;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.probe-tag.ok {
|
||||
background: rgba(34, 224, 255, 0.15);
|
||||
border-color: rgba(34, 224, 255, 0.4);
|
||||
color: var(--spark-500);
|
||||
}
|
||||
.probe-tag.bad {
|
||||
background: rgba(255, 48, 80, 0.15);
|
||||
border-color: rgba(255, 48, 80, 0.4);
|
||||
color: var(--danger-500);
|
||||
}
|
||||
.probe-detail {
|
||||
color: var(--ink-100);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 12px;
|
||||
}
|
||||
.probe-detail strong { color: var(--spark-500); }
|
||||
|
||||
.snippet-details {
|
||||
margin-top: 10px;
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
}
|
||||
.snippet-details summary {
|
||||
color: var(--ink-500);
|
||||
cursor: pointer;
|
||||
padding: 4px 0;
|
||||
}
|
||||
.snippet-details summary:hover { color: var(--ink-100); }
|
||||
.snippet {
|
||||
margin: 10px 0 0;
|
||||
padding: 12px 14px;
|
||||
background: var(--cherry-975);
|
||||
border: 1px solid var(--cherry-700);
|
||||
border-radius: var(--r-sm);
|
||||
color: var(--ink-300);
|
||||
font-family: var(--font-mono);
|
||||
font-size: 11px;
|
||||
line-height: 1.5;
|
||||
max-height: 400px;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: 200px 160px 100px 120px 1fr;
|
||||
|
||||
Reference in New Issue
Block a user