From a1a442281ba275de580ced101d8a860e331a2cd7 Mon Sep 17 00:00:00 2001 From: ZacharyZcR Date: Wed, 13 May 2026 18:15:40 +0800 Subject: [PATCH] feat: check guacd availability before RDP/VNC connection --- src/ui/features/guacamole/GuacamoleApp.tsx | 17 ++++++++++++++--- src/ui/main-axios.ts | 7 +++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/ui/features/guacamole/GuacamoleApp.tsx b/src/ui/features/guacamole/GuacamoleApp.tsx index d09c6442..b5ae7380 100644 --- a/src/ui/features/guacamole/GuacamoleApp.tsx +++ b/src/ui/features/guacamole/GuacamoleApp.tsx @@ -1,7 +1,7 @@ import React, { useState, useEffect, useCallback } from "react"; import { GuacamoleDisplay } from "@/features/guacamole/GuacamoleDisplay.tsx"; import { FullScreenAppWrapper } from "@/features/FullScreenAppWrapper.tsx"; -import { getGuacamoleTokenFromHost } from "@/main-axios.ts"; +import { getGuacamoleTokenFromHost, getGuacdStatus } from "@/main-axios.ts"; import { useTranslation } from "react-i18next"; import { AlertCircle, RefreshCw } from "lucide-react"; import { Button } from "@/components/button.tsx"; @@ -75,8 +75,19 @@ const GuacamoleAppInner: React.FC = ({ useEffect(() => { setToken(null); setError(null); - getGuacamoleTokenFromHost(hostId) - .then((result) => setToken(result.token)) + getGuacdStatus() + .then((status) => { + if (status.guacd.status !== "connected") { + setError( + "Remote desktop service (guacd) is not available. Please ensure guacd is running and accessible.", + ); + return; + } + return getGuacamoleTokenFromHost(hostId); + }) + .then((result) => { + if (result) setToken(result.token); + }) .catch((err) => setError(err?.message || t("guacamole.failedToConnect"))); }, [hostId, retryCount]); diff --git a/src/ui/main-axios.ts b/src/ui/main-axios.ts index 88d0ee43..8529974c 100644 --- a/src/ui/main-axios.ts +++ b/src/ui/main-axios.ts @@ -4501,6 +4501,13 @@ export async function getGuacamoleTokenFromHost( } } +export async function getGuacdStatus(): Promise<{ + guacd: { status: string }; +}> { + const response = await authApi.get("/guacamole/status"); + return response.data; +} + // ============================================================================ // RBAC MANAGEMENT // ============================================================================