mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-06 20:29:50 +00:00
Add warning if we cant reach the vnc server
This commit is contained in:
@@ -116,6 +116,30 @@ export default function VncClient({
|
|||||||
|
|
||||||
disconnect();
|
disconnect();
|
||||||
|
|
||||||
|
const proxyAddress = `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host}/gateway/vnc`;
|
||||||
|
const base = proxyAddress.replace(/\/$/, "");
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
host: target.ip,
|
||||||
|
port: String(target.port),
|
||||||
|
authToken: target.authToken
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
const checkParams = new URLSearchParams(params);
|
||||||
|
checkParams.set("checkOnly", "1");
|
||||||
|
const response = await fetch(`${base}?${checkParams.toString()}`);
|
||||||
|
if (!response.ok) {
|
||||||
|
const detail = (await response.text()).trim();
|
||||||
|
setConnectError(detail || t("sshErrorConnectionClosed"));
|
||||||
|
setConnecting(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
setConnectError(t("sshErrorWebSocket"));
|
||||||
|
setConnecting(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let RFB: new (
|
let RFB: new (
|
||||||
target: HTMLElement,
|
target: HTMLElement,
|
||||||
url: string,
|
url: string,
|
||||||
@@ -136,13 +160,6 @@ export default function VncClient({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const proxyAddress = `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.host}/gateway/vnc`;
|
|
||||||
const base = proxyAddress.replace(/\/$/, "");
|
|
||||||
const params = new URLSearchParams({
|
|
||||||
host: target.ip,
|
|
||||||
port: String(target.port),
|
|
||||||
authToken: target.authToken
|
|
||||||
});
|
|
||||||
const wsUrl = `${base}?${params.toString()}`;
|
const wsUrl = `${base}?${params.toString()}`;
|
||||||
|
|
||||||
screenRef.current.innerHTML = "";
|
screenRef.current.innerHTML = "";
|
||||||
@@ -270,6 +287,13 @@ export default function VncClient({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
{connectError && (
|
||||||
|
<Alert variant="destructive">
|
||||||
|
<AlertDescription>
|
||||||
|
{connectError}
|
||||||
|
</AlertDescription>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="w-full"
|
className="w-full"
|
||||||
@@ -278,13 +302,6 @@ export default function VncClient({
|
|||||||
>
|
>
|
||||||
{t("browserGatewayConnect")}
|
{t("browserGatewayConnect")}
|
||||||
</Button>
|
</Button>
|
||||||
{connectError && (
|
|
||||||
<Alert variant="destructive">
|
|
||||||
<AlertDescription>
|
|
||||||
{connectError}
|
|
||||||
</AlertDescription>
|
|
||||||
</Alert>
|
|
||||||
)}
|
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user