fix(remote-desktop): probe the saved host guacd endpoint (#1481)

* fix(remote-desktop): probe the saved host guacd endpoint

* test(css): exercise the configured PostCSS plugin chain

* test(identity): preserve full Ed25519 public keys in fixtures
This commit is contained in:
ZacharyZcR authored and GitHub committed 2026-09-27 00:11:09 -05:00
1 parent c98003f90e
commit 3b9a1bacf0
5 files changed
+194 -5

No files matched your search

+43 -1
View File
@@ -501,6 +501,16 @@ export function registerRoutes(router: Router, deps: RouteDeps): void {
* schema:
* type: string
* description: "0" skips dialing guacd.
* - in: query
* name: hostId
* schema:
* type: integer
* description: Saved host whose guacd settings should be checked; requires protocol and access to that host.
* - in: query
* name: protocol
* schema:
* type: string
* enum: [rdp, vnc, telnet]
* responses:
* 200:
* description: The status.
@@ -510,7 +520,39 @@ export function registerRoutes(router: Router, deps: RouteDeps): void {
router.get("/status", async (req: Request, res: Response) => {
try {
const enabled = await deps.enabled();
const guacd = deps.guacd();
let guacd = deps.guacd();
if (req.query.hostId !== undefined) {
const userId = actor(ctx, res);
if (!userId) return;
const hostId = Number(req.query.hostId);
const protocol = req.query.protocol;
if (
!Number.isSafeInteger(hostId) ||
hostId <= 0 ||
!isRemoteProtocol(protocol)
) {
return res.status(400).json({ error: "Invalid host ID or protocol" });
}
const target = await ctx.credentials.resolveHostProtocol(
hostId,
protocol,
);
if (!target) return res.status(404).json({ error: "Host not found" });
const settings = await readHostSettings(ctx, hostId);
if (!settings[ENABLE_KEY[protocol]]) {
return res
.status(400)
.json({ error: "Protocol is not enabled for this host" });
}
const { guacdOverrides } = cleanGuacConfig({
...(protocol === "rdp" ? await readUserDefaults(ctx, userId) : {}),
...settings.guacamoleConfig,
});
guacd = {
host: guacdOverrides.guacdHost || guacd.host,
port: guacdOverrides.guacdPort || guacd.port,
};
}
const probe = enabled && req.query.probe !== "0";
const reachable = probe ? await probeGuacd(guacd) : false;
res.json({
@@ -321,7 +321,11 @@ const GuacamoleAppInner = React.forwardRef<
stage: "guac_guacd",
message: t("remoteDesktop.checkingGuacd"),
});
const status = await getGuacdStatus(resolvedOrigin);
const status = await getGuacdStatus(resolvedOrigin, {
hostId,
protocol: resolvedProtocolForConnect,
syncId: hostConfig.syncId,
});
if (status.enabled === false) {
throw new Error(t("remoteDesktop.disabled"));
}
@@ -244,10 +244,29 @@ export interface RemoteDesktopStatus {
/** `probe: false` skips dialing guacd, for a caller that only needs `enabled`. */
export async function getGuacdStatus(
origin: ConnectionOrigin,
options: { probe?: boolean } = {},
options: {
probe?: boolean;
hostId?: number;
protocol?: "rdp" | "vnc" | "telnet";
syncId?: string | null;
} = {},
): Promise<RemoteDesktopStatus> {
const params = new URLSearchParams();
if (options.probe === false) params.set("probe", "0");
if (options.hostId) {
const useRemote = isElectron() && origin === "remote";
const remoteHostId = useRemote
? await resolveRemoteHostId(options.syncId)
: null;
if (useRemote && options.syncId && remoteHostId === null) {
throw new Error("The synced host does not exist on the remote server");
}
params.set("hostId", String(remoteHostId ?? options.hostId));
if (options.protocol) params.set("protocol", options.protocol);
}
const query = params.toString();
const response = await guacamoleApi(origin).get<RemoteDesktopStatus>(
options.probe === false ? "/status?probe=0" : "/status",
query ? `/status?${query}` : "/status",
);
return response.data;
}