add coturn for test

This commit is contained in:
vorotamoroz
2026-06-05 09:39:39 +01:00
parent 369e62ee8d
commit 6b7816d334
7 changed files with 130 additions and 15 deletions
+15 -1
View File
@@ -1,5 +1,5 @@
import { runCli } from "./cli.ts";
import { isLocalP2pRelay, startP2pRelay, stopP2pRelay } from "./docker.ts";
import { isLocalP2pRelay, startP2pRelay, stopP2pRelay, startCoturn, stopCoturn } from "./docker.ts";
import { waitForPort } from "./net.ts";
export type PeerEntry = {
@@ -95,3 +95,17 @@ export async function stopLocalRelayIfStarted(started: boolean): Promise<void> {
await stopP2pRelay().catch(() => {});
}
}
export async function maybeStartCoturn(turnServers: string): Promise<boolean> {
if (turnServers.includes("localhost") || turnServers.includes("127.0.0.1")) {
await startCoturn();
return true;
}
return false;
}
export async function stopCoturnIfStarted(started: boolean): Promise<void> {
if (started) {
await stopCoturn().catch(() => {});
}
}