mirror of
https://github.com/EchoSixHIYA/WebSpeak-client-for-TeamSpeak.git
synced 2026-12-02 19:42:51 +08:00
Adopt the pinned published TeamSpeak SDK and direct relay routing. Add optional TeamSpeak Query administration with encrypted credentials and separate WebSpeak access, site, operations and skin management. Distribute Discord Voice through the GitHub skin index, preserve skin state during updates, and correct KAAK scaling and screen fullscreen. Validation: 831 tests; backend and frontend builds; five-language UI checks from narrow screens through 4K and local Query fixture actions.
55 lines
1.8 KiB
TypeScript
55 lines
1.8 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { resolveLocalTeamSpeakAlias } from "./teamspeak-resolver.js";
|
|
|
|
test("private short hostnames resolve locally before upstream discovery", async () => {
|
|
let lookedUp = "";
|
|
const address = await resolveLocalTeamSpeakAlias("teamspeak", {
|
|
lookup: async (hostname) => {
|
|
lookedUp = hostname;
|
|
return [
|
|
{ address: "203.0.113.4", family: 4 },
|
|
{ address: "172.18.0.6", family: 4 },
|
|
];
|
|
},
|
|
});
|
|
assert.equal(lookedUp, "teamspeak");
|
|
assert.equal(address, "172.18.0.6");
|
|
});
|
|
|
|
test("public and dotted names are left to the upstream resolver", async () => {
|
|
let lookupCalls = 0;
|
|
assert.equal(await resolveLocalTeamSpeakAlias("public-alias", {
|
|
lookup: async () => {
|
|
lookupCalls++;
|
|
return [{ address: "203.0.113.4", family: 4 }];
|
|
},
|
|
}), undefined);
|
|
assert.equal(await resolveLocalTeamSpeakAlias("voice.example.com", {
|
|
lookup: async () => {
|
|
lookupCalls++;
|
|
return [{ address: "10.0.0.2", family: 4 }];
|
|
},
|
|
}), undefined);
|
|
assert.equal(lookupCalls, 1);
|
|
});
|
|
|
|
test("a slow local lookup is bounded and falls through to upstream DNS", async () => {
|
|
const result = await resolveLocalTeamSpeakAlias("teamspeak", {
|
|
lookup: async () => new Promise(() => undefined),
|
|
timeoutMs: 20,
|
|
});
|
|
assert.equal(result, undefined);
|
|
});
|
|
|
|
test("aborting a local lookup preserves the connection cancellation", async () => {
|
|
const controller = new AbortController();
|
|
const failure = new Error("connect cancelled");
|
|
const pending = resolveLocalTeamSpeakAlias("teamspeak", {
|
|
lookup: async () => new Promise(() => undefined),
|
|
signal: controller.signal,
|
|
});
|
|
controller.abort(failure);
|
|
await assert.rejects(pending, failure);
|
|
});
|