[FEATURE] Adjust server control

This commit is contained in:
Dunemask 2023-12-17 12:25:14 -07:00
parent 7348b07352
commit 62c966a6bd
8 changed files with 109 additions and 57 deletions

View file

@ -1,6 +1,6 @@
import k8s from "@kubernetes/client-node";
import { Rcon as RconClient } from "rcon-client";
import { ERR } from "../util/logging.js";
import { ERR, WARN } from "../util/logging.js";
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sCore = kc.makeApiClient(k8s.CoreV1Api);
@ -15,7 +15,8 @@ export default async function rconInterface(socket) {
rconRes.body.data["rcon-password"],
"base64",
).toString("utf8");
const rconHost = `mcl-${socket.mcs.serverName}-rcon`;
const { serverName } = socket.mcs;
const rconHost = `mcl-${serverName}-rcon.${namespace}.svc.cluster.local`;
const rcon = new RconClient({
host: rconHost,
port: 25575,
@ -25,7 +26,8 @@ export default async function rconInterface(socket) {
try {
await rcon.connect();
} catch (error) {
ERR("RCON", `Could not connect to 'mcl-${socket.mcs.serverName}-rcon'`);
socket.emit("push", "Could not connect RCON Input to server!");
WARN("RCON", `Could not connect to '${rconHost}'`);
}
socket.rconClient = rcon;
}