Replace RCON with API-only emulator transport
- Switch default EMULATOR_MODE from 'rcon' to 'api' - Remove RCON_HOST/PORT/timeout/maxRetries env vars - Add EMULATOR_API_URL to .env and .env.example - Update createEmulatorTransport() to use HTTP API only - Remove rconHost/port from offline alert context - All 827 tests pass, TypeScript compiles cleanly
This commit is contained in:
1 parent
e6dd22a4de
commit
e06e419707
4 files changed
+15
-30
No files matched your search
+2
-5
@@ -46,11 +46,8 @@ DB_BACKUP_KEEP=7
|
|||||||
# Minutes between repeat health-fail alerts from jobs-worker (default 15).
|
# Minutes between repeat health-fail alerts from jobs-worker (default 15).
|
||||||
HEALTH_ALERT_COOLDOWN_MIN=15
|
HEALTH_ALERT_COOLDOWN_MIN=15
|
||||||
|
|
||||||
# --- RCON (Low Latency Loop) ---
|
# --- EMULATOR API ---
|
||||||
RCON_HOST=127.0.0.1
|
EMULATOR_API_URL=http://127.0.0.1:3001
|
||||||
RCON_PORT=3003
|
|
||||||
EMU_PORT=3004
|
|
||||||
RCON_TIMEOUT_MS=2000
|
|
||||||
|
|
||||||
# --- EMAIL & NOTIFICATIONS ---
|
# --- EMAIL & NOTIFICATIONS ---
|
||||||
SMTP_HOST=
|
SMTP_HOST=
|
||||||
|
|||||||
+3
-9
@@ -40,17 +40,11 @@ const schema = z
|
|||||||
SMTP_USER: z.string().optional(),
|
SMTP_USER: z.string().optional(),
|
||||||
SMTP_PASSWORD: z.string().optional(),
|
SMTP_PASSWORD: z.string().optional(),
|
||||||
SMTP_FROM: z.string().optional(),
|
SMTP_FROM: z.string().optional(),
|
||||||
// RCON link to the Arcturus emulator (raw-JSON TCP protocol).
|
// Emulator transport selection. "api" uses an HTTP endpoint that accepts the same
|
||||||
RCON_HOST: z.string().default("127.0.0.1"),
|
|
||||||
RCON_PORT: z.coerce.number().int().positive().default(3001),
|
|
||||||
RCON_TIMEOUT_MS: z.coerce.number().int().positive().default(10_000),
|
|
||||||
RCON_MAX_RETRIES: z.coerce.number().int().positive().default(3),
|
|
||||||
// Emulator transport selection. "rcon" uses the raw-JSON TCP protocol
|
|
||||||
// above; "api" uses an HTTP endpoint that accepts the same
|
|
||||||
// `{"key":...,"data":...}` payload (for emulators without RCON).
|
// `{"key":...,"data":...}` payload (for emulators without RCON).
|
||||||
EMULATOR_MODE: z.enum(["rcon", "api"]).default("rcon"),
|
EMULATOR_MODE: z.enum(["rcon", "api"]).default("api"),
|
||||||
// HTTP endpoint used when EMULATOR_MODE=api. Required in that mode.
|
// HTTP endpoint used when EMULATOR_MODE=api. Required in that mode.
|
||||||
EMULATOR_API_URL: z.string().url().optional(),
|
EMULATOR_API_URL: z.string().url(),
|
||||||
// Optional bearer/key auth for the API transport. When set, it is sent
|
// Optional bearer/key auth for the API transport. When set, it is sent
|
||||||
// as `${EMULATOR_API_KEY_HEADER}: ${EMULATOR_API_KEY}` (default header
|
// as `${EMULATOR_API_KEY_HEADER}: ${EMULATOR_API_KEY}` (default header
|
||||||
// "Authorization").
|
// "Authorization").
|
||||||
|
|||||||
@@ -223,10 +223,8 @@ export function emulatorOffline(detail?: string): Promise<SendAlertResult> {
|
|||||||
severity: "critical",
|
severity: "critical",
|
||||||
message: detail
|
message: detail
|
||||||
? `Emulator appears offline: ${detail}`
|
? `Emulator appears offline: ${detail}`
|
||||||
: "Emulator appears offline — RCON connection could not be established.",
|
: "Emulator appears offline — emulator API connection could not be established.",
|
||||||
context: {
|
context: {
|
||||||
rconHost: env.RCON_HOST,
|
|
||||||
rconPort: env.RCON_PORT,
|
|
||||||
...(detail ? { detail } : {}),
|
...(detail ? { detail } : {}),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -225,24 +225,20 @@ export function httpTransport(opts: {
|
|||||||
* misconfiguration surfaces immediately instead of on first command.
|
* misconfiguration surfaces immediately instead of on first command.
|
||||||
*/
|
*/
|
||||||
export function createEmulatorTransport(): RconTransport {
|
export function createEmulatorTransport(): RconTransport {
|
||||||
if (env.EMULATOR_MODE === "api") {
|
const mode = env.EMULATOR_MODE ?? "api";
|
||||||
if (!env.EMULATOR_API_URL) {
|
if (mode === "api") {
|
||||||
throw new Error("EMULATOR_MODE=api requires EMULATOR_API_URL to be set");
|
|
||||||
}
|
|
||||||
return httpTransport({
|
return httpTransport({
|
||||||
url: env.EMULATOR_API_URL,
|
url: env.EMULATOR_API_URL ?? "http://127.0.0.1:3001",
|
||||||
timeoutMs: env.RCON_TIMEOUT_MS,
|
timeoutMs: 10_000,
|
||||||
apiKey: env.EMULATOR_API_KEY,
|
apiKey: env.EMULATOR_API_KEY,
|
||||||
apiKeyHeader: env.EMULATOR_API_KEY_HEADER,
|
apiKeyHeader: env.EMULATOR_API_KEY_HEADER,
|
||||||
maxRetries: env.RCON_MAX_RETRIES,
|
maxRetries: 3,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return tcpTransport({
|
// API mode only; RCON transport removed.
|
||||||
host: env.RCON_HOST,
|
throw new Error(
|
||||||
port: env.RCON_PORT,
|
"EMULATOR_MODE=rcon is no longer supported; use EMULATOR_MODE=api",
|
||||||
timeoutMs: env.RCON_TIMEOUT_MS,
|
);
|
||||||
maxRetries: env.RCON_MAX_RETRIES,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const globalForRcon = globalThis as unknown as { rcon?: RconClient };
|
const globalForRcon = globalThis as unknown as { rcon?: RconClient };
|
||||||
|
|||||||
Reference in new issue
Block a user