Relay pairing offer v2 (E2EE) + host connections

This commit is contained in:
Mohamed Boudra
2026-02-04 22:53:00 +07:00
parent 9ce4ad9758
commit 0218729316
59 changed files with 2022 additions and 1547 deletions
@@ -69,14 +69,14 @@ export function buildDaemonWebSocketUrl(endpoint: string): string {
export function buildRelayWebSocketUrl(params: {
endpoint: string;
sessionId: string;
serverId: string;
role: RelayRole;
}): string {
const { host, port, isIpv6 } = parseHostPort(params.endpoint);
const protocol = shouldUseSecureWebSocket(port) ? "wss" : "ws";
const hostPart = isIpv6 ? `[${host}]` : host;
const url = new URL(`${protocol}://${hostPart}:${port}/ws`);
url.searchParams.set("session", params.sessionId);
url.searchParams.set("serverId", params.serverId);
url.searchParams.set("role", params.role);
return url.toString();
}
@@ -108,10 +108,9 @@ export function isRelayClientWebSocketUrl(url: string): boolean {
const parsed = new URL(url);
return (
parsed.searchParams.get("role") === "client" &&
parsed.searchParams.has("session")
parsed.searchParams.has("serverId")
);
} catch {
return false;
}
}