feat(admin): manage WebRTC settings from console

This commit is contained in:
illusia committed 2026-09-03 07:52:13 +08:00
1 parent ecff06e9a1
commit 5c3d1b7e5d
11 files changed
+163 -58

No files matched your search

+9 -1
View File
@@ -111,11 +111,19 @@ test("admin API requires the default password to be changed before administratio
accessMode: "open",
siteName: "Changed",
welcomeText: "Open access",
webRtcEnabled: true,
webRtcPublicHost: "voice.example.com",
webRtcUdpStart: 40000,
webRtcUdpEnd: 40099,
},
});
assert.equal(saved.body.ok, true);
assert.equal(saved.body.settings.accessMode, "open");
assert.equal(saved.body.settings.hasPassword, false);
assert.equal(saved.body.settings.webRtcEnabled, true);
assert.equal(saved.body.settings.webRtcPublicHost, "voice.example.com");
assert.equal(saved.body.settings.webRtcUdpStart, 40000);
assert.equal(saved.body.settings.webRtcUdpEnd, 40099);
const invite = await request(origin, "/api/admin/invites", {
method: "POST",
@@ -137,7 +145,7 @@ test("admin API requires the default password to be changed before administratio
const sessions = await request(origin, "/api/admin/sessions", { cookie });
assert.deepEqual(sessions.body.sessions, []);
const diagnostics = await request(origin, "/api/admin/diagnostics", { cookie });
assert.equal(diagnostics.body.database.schemaVersion, 2);
assert.equal(diagnostics.body.database.schemaVersion, 3);
assert.equal("target" in diagnostics.body.teamSpeak, true);
assert.equal("protocol" in diagnostics.body.teamSpeak, false);
+7 -1
View File
@@ -54,6 +54,10 @@ test("legacy config imports once, seeds the default admin, and allows password r
accessMode: "open",
siteName: "Open WebSpeak",
welcomeText: "Public gateway",
webRtcEnabled: true,
webRtcPublicHost: "voice.example.com",
webRtcUdpStart: 40000,
webRtcUdpEnd: 40099,
});
const publicConfig = service.getPublicConfig();
assert.equal(publicConfig.target, "public.example.com:9987");
@@ -61,6 +65,8 @@ test("legacy config imports once, seeds the default admin, and allows password r
assert.equal("serverPassword" in service.getAdminSettings(), false);
assert.equal(service.getAdminSettings().hasPassword, true);
assert.equal(service.getConnectionPolicy().serverPassword, "replacement-secret");
assert.equal(service.getAdminSettings().webRtcEnabled, true);
assert.deepEqual(service.getWebRtcAudioOptions(), { enabled: true, publicHost: "voice.example.com", icePortRange: [40000, 40099] });
database.close();
});
@@ -106,7 +112,7 @@ test("managed invites are opaque, bounded, revocable, and included in database b
assert.ok(backup.length > 100);
database.close();
const reopened = new WebSpeakDatabase(path.join(directory, "webspeak.db"));
assert.equal(reopened.schemaVersion, 2);
assert.equal(reopened.schemaVersion, 3);
assert.equal(reopened.listManagedInvites().length, 3);
reopened.close();
});
+13 -2
View File
@@ -23,6 +23,10 @@ test("SQLite persistence initializes schema and stores the single admin/settings
tsHost: "voice.example.com",
tsPort: 9988,
tsPasswordEncrypted: "v1:ciphertext",
webRtcEnabled: true,
webRtcPublicHost: "voice.example.com",
webRtcUdpStart: 40000,
webRtcUdpEnd: 40099,
});
assert.equal(database.hasAdmin(), true);
assert.equal(database.getAdminCredential()?.hash, credential.hash);
@@ -37,6 +41,10 @@ test("SQLite persistence initializes schema and stores the single admin/settings
lastTestAt: null,
lastTestLatencyMs: null,
lastTestError: null,
webRtcEnabled: true,
webRtcPublicHost: "voice.example.com",
webRtcUdpStart: 40000,
webRtcUdpEnd: 40099,
updatedAt: database.getSettings().updatedAt,
});
assert.equal(database.recentAudit()[0]?.event, "ADMIN_INITIALIZED");
@@ -48,7 +56,7 @@ test("SQLite persistence initializes schema and stores the single admin/settings
reopened.close();
});
test("SQLite schema v1 upgrades to v2 with a migration copy", () => {
test("SQLite schema v1 upgrades to v3 with a migration copy", () => {
const directory = mkdtempSync(path.join(tmpdir(), "webspeak-db-migration-"));
const dbPath = path.join(directory, "webspeak.db");
const legacy = new DatabaseSync(dbPath);
@@ -68,7 +76,10 @@ test("SQLite schema v1 upgrades to v2 with a migration copy", () => {
legacy.close();
const upgraded = new WebSpeakDatabase(dbPath);
assert.equal(upgraded.schemaVersion, 2);
assert.equal(upgraded.schemaVersion, 3);
assert.equal(upgraded.getSettings().webRtcEnabled, false);
assert.equal(upgraded.getSettings().webRtcUdpStart, 40000);
assert.equal(upgraded.getSettings().webRtcUdpEnd, 40099);
assert.equal(upgraded.listManagedInvites().length, 0);
assert.equal(existsSync(`${dbPath}.schema-1.bak`), true);
upgraded.close();