@norskvideo/ctl-test-harness 0.1.107 → 0.1.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/demo/run.d.ts +4 -0
- package/demo/run.js +24 -4
- package/package.json +1 -1
package/demo/run.d.ts
CHANGED
|
@@ -229,6 +229,10 @@ export interface MoqRelayHandle {
|
|
|
229
229
|
/** The relay's operator surface: the host's loopback, or the relay by name
|
|
230
230
|
* on norsk-net in direct reach. */
|
|
231
231
|
statusUrl: string;
|
|
232
|
+
/** Direct reach: where the daemon sends browsers for WebTransport, the relay
|
|
233
|
+
* by name on norsk-net (NORSK_CTL_MOQ_RELAY_PUBLIC_URL). Absent in publish
|
|
234
|
+
* reach, where ctl's default (advertised host, published port) is right. */
|
|
235
|
+
browserUrl?: string;
|
|
232
236
|
}
|
|
233
237
|
export interface SessionOptions {
|
|
234
238
|
mode: DemoMode;
|
package/demo/run.js
CHANGED
|
@@ -335,6 +335,8 @@ export function defaultDemoDeps(cwd) {
|
|
|
335
335
|
}
|
|
336
336
|
/** ctl's MOQ_RELAY_STATUS_INTERNAL_PORT: the relay's status surface inside its container. */
|
|
337
337
|
const MOQ_RELAY_STATUS_INTERNAL_PORT = 6791;
|
|
338
|
+
/** ctl's MOQ_RELAY_INTERNAL_PORT: the relay's WebTransport listener inside its container. */
|
|
339
|
+
const MOQ_RELAY_INTERNAL_PORT = 4443;
|
|
338
340
|
/** Where the store's config is: what `config set` with no daemon writes. */
|
|
339
341
|
const CONFIG_FILE = "config.yaml";
|
|
340
342
|
/** `config set` aimed at a port nothing listens on, so it takes its no-daemon
|
|
@@ -583,16 +585,28 @@ export class DemoSession {
|
|
|
583
585
|
* auth setting the daemon reads at boot. Returns the daemon's relay env. */
|
|
584
586
|
async prepareMoqRelay(opts) {
|
|
585
587
|
const auth = opts.auth ?? "off";
|
|
586
|
-
|
|
587
|
-
|
|
588
|
+
// The relay's fingerprint and WebSocket fallback are advertised on the
|
|
589
|
+
// proxy's base URL, i.e. the daemon's public host. In direct reach the
|
|
590
|
+
// browser is in this runner container and reaches the proxy at proxyHost
|
|
591
|
+
// (the host gateway), not the daemon's default of localhost.
|
|
592
|
+
const advertiseProxy = netReachMode() === "direct" && this.publicHost === undefined && this.proxyHost !== "localhost";
|
|
593
|
+
const settings = [
|
|
594
|
+
...(auth !== "off" ? [{ flag: "--moq-relay-auth", key: "moqRelayAuth", value: auth }] : []),
|
|
595
|
+
...(advertiseProxy ? [{ flag: "--public-host", key: "publicHost", value: this.proxyHost }] : []),
|
|
596
|
+
];
|
|
597
|
+
if (settings.length > 0) {
|
|
598
|
+
const argv = ["config", "set", ...settings.flatMap((x) => [x.flag, x.value])];
|
|
588
599
|
const r = await this.deps.cli(this.storeDir, ["--port", NO_DAEMON_PORT, ...argv]);
|
|
589
600
|
this.transcript.push({ argv, stdout: r.stdout, stderr: r.stderr, exitCode: r.exitCode });
|
|
590
601
|
if (r.exitCode !== 0) {
|
|
591
602
|
throw new Error(`norsk-ctl ${argv.join(" ")} failed (exit ${r.exitCode}):\n${r.stderr || r.stdout}`);
|
|
592
603
|
}
|
|
593
604
|
const config = this.deps.readFile(join(this.storeDir, CONFIG_FILE)) ?? "";
|
|
594
|
-
|
|
595
|
-
|
|
605
|
+
for (const x of settings) {
|
|
606
|
+
const escaped = x.value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
607
|
+
if (!new RegExp(`^${x.key}:\\s*["']?${escaped}["']?\\s*$`, "m").test(config)) {
|
|
608
|
+
throw new Error(`norsk-ctl ${argv.join(" ")} left no ${x.key}: ${x.value} in ${join(this.storeDir, CONFIG_FILE)} — the resolved ctl predates the ${x.key} setting`);
|
|
609
|
+
}
|
|
596
610
|
}
|
|
597
611
|
}
|
|
598
612
|
const freePort = this.deps.freePort ?? ((taken) => freeHostPort({ taken }));
|
|
@@ -608,6 +622,10 @@ export class DemoSession {
|
|
|
608
622
|
// Per run, not just per slug: the store dir is, and a relay a cancelled
|
|
609
623
|
// run left behind must not be adopted by the next one.
|
|
610
624
|
const container = `norsk-moq-relay-${this.slug}-${createHash("sha256").update(this.storeDir).digest("hex").slice(0, 8)}`;
|
|
625
|
+
// The relay's ports are published on the docker host, which a runner
|
|
626
|
+
// container cannot reach; on norsk-net with it, its browser reaches the
|
|
627
|
+
// relay by name. An older ctl ignores the variable.
|
|
628
|
+
const browserUrl = netReachMode() === "direct" ? `https://${container}:${MOQ_RELAY_INTERNAL_PORT}` : undefined;
|
|
611
629
|
this.moqRelay = {
|
|
612
630
|
auth,
|
|
613
631
|
container,
|
|
@@ -621,6 +639,7 @@ export class DemoSession {
|
|
|
621
639
|
statusUrl: netReachMode() === "direct"
|
|
622
640
|
? `http://${container}:${MOQ_RELAY_STATUS_INTERNAL_PORT}`
|
|
623
641
|
: `http://127.0.0.1:${statusPort}`,
|
|
642
|
+
...(browserUrl ? { browserUrl } : {}),
|
|
624
643
|
};
|
|
625
644
|
this.deps.log(`MoQ relay ${container}: :${port}, quic :${quicPort}, status :${statusPort}, auth ${auth}`);
|
|
626
645
|
return {
|
|
@@ -629,6 +648,7 @@ export class DemoSession {
|
|
|
629
648
|
NORSK_CTL_MOQ_RELAY_PORT: String(port),
|
|
630
649
|
NORSK_CTL_MOQ_RELAY_QUIC_PORT: String(quicPort),
|
|
631
650
|
NORSK_CTL_MOQ_RELAY_STATUS_PORT: String(statusPort),
|
|
651
|
+
...(browserUrl ? { NORSK_CTL_MOQ_RELAY_PUBLIC_URL: browserUrl } : {}),
|
|
632
652
|
};
|
|
633
653
|
}
|
|
634
654
|
/** The daemon never removes its relay, on shutdown or otherwise. */
|