mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-02 19:42:51 +08:00
feat: customize and lock WebRTC media ports
This commit is contained in:
1 parent
767bdea018
commit
baa09ad38c
10 files changed
+161
-23
No files matched your search
@@ -112,12 +112,34 @@ test("admin API requires the default password to be changed before administratio
|
||||
siteName: "Changed",
|
||||
welcomeText: "Open access",
|
||||
webRtcEnabled: true,
|
||||
webRtcUdpStart: 41000,
|
||||
webRtcUdpEnd: 41099,
|
||||
},
|
||||
});
|
||||
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.webRtcUdpStart, 41000);
|
||||
assert.equal(saved.body.settings.webRtcUdpEnd, 41099);
|
||||
|
||||
const lockedPorts = await request(origin, "/api/admin/server", {
|
||||
method: "PUT",
|
||||
cookie,
|
||||
csrf: login.body.csrfToken,
|
||||
body: {
|
||||
target: "voice.example.com:9988",
|
||||
passwordAction: "keep",
|
||||
accessMode: "open",
|
||||
siteName: "Changed",
|
||||
welcomeText: "Open access",
|
||||
webRtcEnabled: true,
|
||||
webRtcUdpStart: 42000,
|
||||
webRtcUdpEnd: 42099,
|
||||
},
|
||||
});
|
||||
assert.equal(lockedPorts.response.status, 400);
|
||||
assert.equal(lockedPorts.body.code, "WEBRTC_PORT_LOCKED");
|
||||
|
||||
const invite = await request(origin, "/api/admin/invites", {
|
||||
method: "POST",
|
||||
|
||||
@@ -55,6 +55,8 @@ test("legacy config imports once, seeds the default admin, and allows password r
|
||||
siteName: "Open WebSpeak",
|
||||
welcomeText: "Public gateway",
|
||||
webRtcEnabled: true,
|
||||
webRtcUdpStart: 41000,
|
||||
webRtcUdpEnd: 41099,
|
||||
});
|
||||
const publicConfig = service.getPublicConfig();
|
||||
assert.equal(publicConfig.target, "public.example.com:9987");
|
||||
@@ -63,7 +65,18 @@ test("legacy config imports once, seeds the default admin, and allows password r
|
||||
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 });
|
||||
assert.equal(service.getAdminSettings().webRtcUdpStart, 41000);
|
||||
assert.equal(service.getAdminSettings().webRtcUdpEnd, 41099);
|
||||
assert.deepEqual(service.getWebRtcAudioOptions(), { enabled: true, udpPortRange: [41000, 41099] });
|
||||
assert.throws(() => service.updateSettings({
|
||||
target: "public.example.com:9987",
|
||||
accessMode: "open",
|
||||
siteName: "Open WebSpeak",
|
||||
welcomeText: "Public gateway",
|
||||
webRtcEnabled: true,
|
||||
webRtcUdpStart: 42000,
|
||||
webRtcUdpEnd: 42099,
|
||||
}), /Disable WebRTC/);
|
||||
database.close();
|
||||
});
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ test("SQLite persistence initializes schema and stores the single admin/settings
|
||||
tsPort: 9988,
|
||||
tsPasswordEncrypted: "v1:ciphertext",
|
||||
webRtcEnabled: true,
|
||||
webRtcUdpStart: 41000,
|
||||
webRtcUdpEnd: 41099,
|
||||
});
|
||||
assert.equal(database.hasAdmin(), true);
|
||||
assert.equal(database.getAdminCredential()?.hash, credential.hash);
|
||||
@@ -39,6 +41,8 @@ test("SQLite persistence initializes schema and stores the single admin/settings
|
||||
lastTestLatencyMs: null,
|
||||
lastTestError: null,
|
||||
webRtcEnabled: true,
|
||||
webRtcUdpStart: 41000,
|
||||
webRtcUdpEnd: 41099,
|
||||
updatedAt: database.getSettings().updatedAt,
|
||||
});
|
||||
assert.equal(database.recentAudit()[0]?.event, "ADMIN_INITIALIZED");
|
||||
@@ -72,9 +76,8 @@ test("SQLite schema v1 upgrades to v3 with a migration copy", () => {
|
||||
const upgraded = new WebSpeakDatabase(dbPath);
|
||||
assert.equal(upgraded.schemaVersion, 3);
|
||||
assert.equal(upgraded.getSettings().webRtcEnabled, false);
|
||||
assert.equal("webRtcPublicHost" in upgraded.getSettings(), false);
|
||||
assert.equal("webRtcUdpStart" in upgraded.getSettings(), false);
|
||||
assert.equal("webRtcUdpEnd" in upgraded.getSettings(), 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();
|
||||
|
||||
Reference in new issue
Block a user