feat: store rdp, vnc and telnet logins in a generic per-protocol table

This commit is contained in:
LukeGus committed 2026-09-29 12:33:09 -05:00
1 parent e0c30a4e6f
commit bba06f7ff6
107 files changed
+18750 -1224

No files matched your search

@@ -141,6 +141,42 @@ export function normalizeImportedHost(
return Object.keys(out).length > 0 ? out : null;
}
/**
* Registered as "remote-desktop.hostPayloadLegacy": each protocol's login
* in the flat 2.8 shape (rdpUser, rdpDomain, vncAuthType and so on), for
* Termix-Mobile until it reads protocolAuth. Built from the payload's own
* protocolAuth, which core already reduced for a shared recipient.
*/
export function hostPayloadLegacy(
_values: Record<string, unknown>,
host: Record<string, unknown>,
): Record<string, unknown> | null {
const logins = asObject(host.protocolAuth);
if (!logins) return null;
const out: Record<string, unknown> = {};
for (const protocol of ["rdp", "vnc", "telnet"] as const) {
const login = asObject(logins[protocol]);
if (!login) continue;
out[`${protocol}AuthType`] = login.authType;
if (login.credentialId !== undefined) {
out[`${protocol}CredentialId`] = login.credentialId;
}
if (typeof login.username === "string" && login.username) {
out[`${protocol}User`] = login.username;
}
if (typeof login.hasPassword === "boolean") {
const name = protocol.charAt(0).toUpperCase() + protocol.slice(1);
out[`has${name}Password`] = login.hasPassword;
}
const domain = asObject(login.fields)?.domain;
if (protocol === "rdp" && typeof domain === "string" && domain) {
out.rdpDomain = domain;
out.domain = domain;
}
}
return Object.keys(out).length > 0 ? out : null;
}
/** User setting key to the guacd parameter it sets. */
const USER_DEFAULT_PARAMS: Record<string, string> = {
colorDepth: "color-depth",
@@ -9,6 +9,7 @@ import { resolveGuacdOptions } from "./guacd-config.js";
import { registerRoutes } from "./routes.js";
import { createLiveSessions } from "./live-sessions.js";
import {
hostPayloadLegacy,
normalizeImportedHost,
PORT_KEY,
readHostSettings,
@@ -107,6 +108,7 @@ export async function activate(ctx: PluginContext) {
"remote-desktop.hostImportNormalizer",
normalizeImportedHost,
);
ctx.registry.provide("remote-desktop.hostPayloadLegacy", hostPayloadLegacy);
// Core's status dot pings these hosts on the protocol's own port.
for (const protocol of ["rdp", "vnc", "telnet"] as const) {
+1 -1
View File
@@ -337,7 +337,7 @@ export function registerRoutes(router: Router, deps: RouteDeps): void {
const domain = resolveRdpDomain(
target.auth.authType,
body.promptedDomain,
target.auth.domain,
target.auth.fields.domain ?? "",
);
let hostname = target.host.ip;