mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-03 03:52:50 +08:00
feat(admin): manage WebRTC settings from console
This commit is contained in:
1 parent
ecff06e9a1
commit
5c3d1b7e5d
11 files changed
+163
-58
No files matched your search
+1
-20
@@ -8,7 +8,6 @@ import { WebSpeakDatabase } from "./persistence/database.js";
|
||||
import { loadOrCreateMasterSecret } from "./security/master-secret.js";
|
||||
import { AdminService } from "./admin/admin-service.js";
|
||||
import { JoinTicketStore } from "./server/join-ticket.js";
|
||||
import type { WebRtcAudioOptions } from "./server/webrtc-audio.js";
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const ROOT_DIR = path.resolve(__dirname, "..");
|
||||
@@ -20,7 +19,6 @@ const DATA_DIR = process.env.WEBSPEAK_DATA_DIR?.trim() || path.join(ROOT_DIR, "d
|
||||
const LOG_DIR = path.join(DATA_DIR, "logs");
|
||||
const STATIC_DIR = path.join(ROOT_DIR, "web", "dist");
|
||||
const APP_VERSION = readPackageVersion();
|
||||
const WEBRTC_OPTIONS = readWebRtcOptions();
|
||||
|
||||
async function main() {
|
||||
const logger = createLogger(LOG_DIR);
|
||||
@@ -50,7 +48,7 @@ async function main() {
|
||||
certDir: hasCert ? CERT_DIR : undefined,
|
||||
voiceBridgeOptions: {
|
||||
joinTickets,
|
||||
webRtc: WEBRTC_OPTIONS,
|
||||
webRtc: () => adminService.getWebRtcAudioOptions(),
|
||||
},
|
||||
adminService,
|
||||
logger,
|
||||
@@ -86,23 +84,6 @@ function removeObsoleteBootstrapFile(): void {
|
||||
}
|
||||
}
|
||||
|
||||
function readWebRtcOptions(): WebRtcAudioOptions {
|
||||
const enabled = /^(1|true|yes)$/i.test(process.env.WEBSPEAK_WEBRTC?.trim() ?? "");
|
||||
const publicHost = process.env.WEBSPEAK_WEBRTC_PUBLIC_HOST?.trim() || undefined;
|
||||
const start = parsePort(process.env.WEBSPEAK_WEBRTC_UDP_START, 40_000);
|
||||
const end = parsePort(process.env.WEBSPEAK_WEBRTC_UDP_END, 40_099);
|
||||
return {
|
||||
enabled,
|
||||
...(publicHost ? { publicHost } : {}),
|
||||
...(start <= end ? { icePortRange: [start, end] as [number, number] } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
function parsePort(value: string | undefined, fallback: number): number {
|
||||
const port = Number(value);
|
||||
return Number.isInteger(port) && port >= 1 && port <= 65_535 ? port : fallback;
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
console.error("Fatal error:", err);
|
||||
process.exit(1);
|
||||
|
||||
Reference in new issue
Block a user