feat: add mainland acceleration preview

This commit is contained in:
illusia committed 2026-09-10 14:27:33 +08:00
1 parent 45584810a2
commit b82c4fe0af
11 files changed
+494 -21

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
import { createAccelerationRelayServer } from "./server/acceleration-relay.js";
const token = process.env.WEBSPEAK_ACCELERATION_RELAY_TOKEN?.trim();
if (!token) throw new Error("WEBSPEAK_ACCELERATION_RELAY_TOKEN is required");
const server = await createAccelerationRelayServer({
host: process.env.WEBSPEAK_ACCELERATION_RELAY_HOST?.trim() || "0.0.0.0",
port: parsePort(process.env.WEBSPEAK_ACCELERATION_RELAY_PORT, 39087),
token,
});
console.log(`WebSpeak acceleration relay listening on ${server.host}:${server.port}`);
const shutdown = (): void => {
server.close();
process.exit(0);
};
process.once("SIGINT", shutdown);
process.once("SIGTERM", shutdown);
function parsePort(value: string | undefined, fallback: number): number {
const port = value ? Number(value) : fallback;
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("Invalid WEBSPEAK_ACCELERATION_RELAY_PORT");
return port;
}