Add SCUM Source RCON transport

This commit is contained in:
npc0-hue
2026-07-23 10:55:31 +08:00
parent ec96c22e4c
commit 742f96ea02
33 changed files with 1297 additions and 19 deletions
+25
View File
@@ -0,0 +1,25 @@
import { describe, expect, it } from "vitest";
import { sourceRCONChatRequest, sourceRCONRawCommandRequest } from "./sourceRcon";
describe("Source RCON browser request schemas", () => {
it("builds a bounded typed chat request without connection material", () => {
expect(sourceRCONChatRequest("server-1", { chatType: 4, message: "hello", targetSteamId: "76561198000000001" }, 12)).toEqual({
kind: "chat",
chatType: 4,
message: "hello",
targetSteamId: "76561198000000001",
idempotencyKey: "web:source-rcon:chat:server-1:12"
});
});
it("rejects framed text and formats raw commands without chat fields", () => {
expect(() => sourceRCONChatRequest("server-1", { chatType: 2, message: "line one\nline two" }, 13)).toThrow("受限的单行文本");
expect(() => sourceRCONChatRequest("server-1", { chatType: 8, message: "hello" }, 13)).toThrow("聊天类型");
expect(sourceRCONRawCommandRequest("server-1", " SetTime 12 ", 14)).toEqual({
kind: "command",
command: "SetTime 12",
idempotencyKey: "web:source-rcon:command:server-1:14"
});
});
});