mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-08-29 18:31:33 +00:00
fix: support macOS VNC connections (#1311)
This commit is contained in:
@@ -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"));
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user