mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-07-15 21:03:47 +00:00
feat: check guacd availability before RDP/VNC connection
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useEffect, useCallback } from "react";
|
import React, { useState, useEffect, useCallback } from "react";
|
||||||
import { GuacamoleDisplay } from "@/features/guacamole/GuacamoleDisplay.tsx";
|
import { GuacamoleDisplay } from "@/features/guacamole/GuacamoleDisplay.tsx";
|
||||||
import { FullScreenAppWrapper } from "@/features/FullScreenAppWrapper.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 { useTranslation } from "react-i18next";
|
||||||
import { AlertCircle, RefreshCw } from "lucide-react";
|
import { AlertCircle, RefreshCw } from "lucide-react";
|
||||||
import { Button } from "@/components/button.tsx";
|
import { Button } from "@/components/button.tsx";
|
||||||
@@ -75,8 +75,19 @@ const GuacamoleAppInner: React.FC<GuacamoleAppInnerProps> = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setToken(null);
|
setToken(null);
|
||||||
setError(null);
|
setError(null);
|
||||||
getGuacamoleTokenFromHost(hostId)
|
getGuacdStatus()
|
||||||
.then((result) => setToken(result.token))
|
.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")));
|
.catch((err) => setError(err?.message || t("guacamole.failedToConnect")));
|
||||||
}, [hostId, retryCount]);
|
}, [hostId, retryCount]);
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
// RBAC MANAGEMENT
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user