Files
teamspeak-music-bot/src/ts-protocol/protocol-detect.test.ts
T
Claude 9e51ba6cd4 Add dual TS3/TS6 protocol support with auto-detection
The @honeybbq/teamspeak-client library already handles TS6 license block
type 8 (Ts5Server) in its handshake, so voice connections work with both
TS3 and TS6 servers. This commit adds the surrounding infrastructure:

- protocol-detect.ts: Auto-detect server type by probing TS3 ServerQuery
  (port 10011) and TS6 HTTP Query (port 10080) in parallel
- http-query.ts: TS6 HTTP Query client replacing the raw-TCP ServerQuery
  that TS6 servers no longer support (ports 10080/10443)
- client.ts: Protocol-aware connection with auto-detection, TS6 HTTP
  Query setup, and forced protocol override option
- manager.ts: Pass through serverProtocol and ts6ApiKey config options
- connection.ts: Mark legacy TS3 ServerQuery as deprecated for TS6

https://claude.ai/code/session_016WhH58avUD9xy2dgADJgTh
2026-04-03 13:03:47 +00:00

24 lines
830 B
TypeScript

import { describe, it, expect } from "vitest";
import {
detectServerProtocol,
type ServerProtocol,
type ProtocolDetectResult,
} from "./protocol-detect.js";
describe("protocol-detect", () => {
it("returns unknown for unreachable hosts", async () => {
const result = await detectServerProtocol("192.0.2.1", 9987, 1000);
expect(result.protocol).toBe("unknown");
expect(result.queryPort).toBeNull();
expect(result.voicePort).toBe(9987);
});
it("result shape matches ProtocolDetectResult interface", async () => {
const result = await detectServerProtocol("127.0.0.1", 9987, 500);
expect(result).toHaveProperty("protocol");
expect(result).toHaveProperty("queryPort");
expect(result).toHaveProperty("voicePort");
expect(["ts3", "ts6", "unknown"]).toContain(result.protocol);
});
});