fix: support macOS VNC connections (#1311)

This commit is contained in:
ZacharyZcR
2026-08-24 03:59:37 +08:00
committed by GitHub
parent ad266956cc
commit fa0fa7f836
6 changed files with 225 additions and 20 deletions
@@ -226,7 +226,7 @@ export const GuacamoleDisplay = forwardRef<
localPort: 30008,
localPath: "/guacamole/websocket/",
remotePath: "/guacamole/websocket/",
includeLocalJwt: false,
includeJwt: false,
});
if (!wsBase) {
onError?.(t("errors.remoteServerRequired"));
+6 -4
View File
@@ -80,17 +80,17 @@ export async function buildOriginWsUrl({
localPort,
localPath,
remotePath,
includeLocalJwt = true,
includeJwt = true,
}: {
origin: ConnectionOrigin;
localPort: number;
localPath: string;
remotePath: string;
includeLocalJwt?: boolean;
includeJwt?: boolean;
}): Promise<string | null> {
if (origin === "local") {
let url = `ws://127.0.0.1:${localPort}${localPath}`;
if (includeLocalJwt) {
if (includeJwt) {
const token = localStorage.getItem("jwt");
if (token) url += `?token=${encodeURIComponent(token)}`;
}
@@ -107,6 +107,8 @@ export async function buildOriginWsUrl({
.replace(/^https?:\/\//, "")
.replace(/\/$/, "");
let url = `${wsProtocol}${wsHost}${remotePath}`;
if (remote.jwt) url += `?token=${encodeURIComponent(remote.jwt)}`;
if (includeJwt && remote.jwt) {
url += `?token=${encodeURIComponent(remote.jwt)}`;
}
return url;
}
+23 -1
View File
@@ -132,12 +132,34 @@ describe("buildOriginWsUrl", () => {
localPort: 30009,
localPath: "/docker/console/",
remotePath: "/docker/console/",
includeLocalJwt: false,
includeJwt: false,
});
expect(url).toBe("ws://127.0.0.1:30009/docker/console/");
});
it("does not duplicate the Guacamole token on remote connections", async () => {
win.electronAPI = {
invoke: async (channel: string) => {
if (channel === "get-remote-sync-config") {
return { serverUrl: "https://termix.example" };
}
if (channel === "get-remote-sync-jwt") return "remote-jwt";
return null;
},
};
const url = await buildOriginWsUrl({
origin: "remote",
localPort: 30008,
localPath: "/guacamole/websocket/",
remotePath: "/guacamole/websocket/",
includeJwt: false,
});
expect(url).toBe("wss://termix.example/guacamole/websocket/");
});
it("leaves the URL alone when there is no token stored", async () => {
delete store.jwt;