[STYLING] Adjusted formatting for options
This commit is contained in:
parent
b45bfed63c
commit
2da6278ae7
12 changed files with 443 additions and 128 deletions
|
@ -3,6 +3,7 @@ import k8s from "@kubernetes/client-node";
|
|||
import { Rcon as RconClient } from "rcon-client";
|
||||
import stream from "stream";
|
||||
import { ERR, WARN } from "../../util/logging.js";
|
||||
import { getServerEntry } from "../../database/queries/server-queries.js";
|
||||
|
||||
// Kubernetes Configuration
|
||||
const kc = new k8s.KubeConfig();
|
||||
|
@ -12,8 +13,9 @@ const namespace = process.env.MCL_SERVER_NAMESPACE;
|
|||
|
||||
// Retrieves logs from the minecraft server container
|
||||
export async function webConsoleLogs(socket) {
|
||||
const { serverName } = socket.mcs;
|
||||
const podName = `mcl-${serverName}`;
|
||||
const { serverId } = socket.mcs;
|
||||
const server = await getServerEntry(serverId);
|
||||
const podName = `mcl-${server.mclName}`;
|
||||
const containerName = `${podName}-server`;
|
||||
const podResponse = await k8sCore.listNamespacedPod(namespace);
|
||||
const pods = podResponse.body.items.map((vp1) => vp1.metadata.name);
|
||||
|
@ -41,14 +43,15 @@ export async function webConsoleLogs(socket) {
|
|||
export async function webConsoleRcon(socket) {
|
||||
if (socket.rconClient)
|
||||
return VERB("RCON", "Socket already connected to RCON");
|
||||
const rconSecret = `mcl-${socket.mcs.serverName}-rcon-secret`;
|
||||
const { serverId } = socket.mcs;
|
||||
const server = await getServerEntry(serverId);
|
||||
const rconSecret = `mcl-${server.mclName}-rcon-secret`;
|
||||
const rconRes = await k8sCore.readNamespacedSecret(rconSecret, namespace);
|
||||
const rconPassword = Buffer.from(
|
||||
rconRes.body.data["rcon-password"],
|
||||
"base64",
|
||||
).toString("utf8");
|
||||
const { serverName } = socket.mcs;
|
||||
const rconHost = `mcl-${serverName}-rcon.${namespace}.svc.cluster.local`;
|
||||
const rconHost = `mcl-${server.mclName}-rcon.${namespace}.svc.cluster.local`;
|
||||
const rcon = new RconClient({
|
||||
host: rconHost,
|
||||
port: 25575,
|
||||
|
|
|
@ -18,7 +18,7 @@ async function rconSend(socket, m) {
|
|||
|
||||
const socketConnect = async (io, socket) => {
|
||||
VERB("WS", "Websocket connecting");
|
||||
socket.mcs = { serverName: socket.handshake.query.serverName };
|
||||
socket.mcs = { serverId: socket.handshake.query.serverId };
|
||||
try {
|
||||
await webConsoleLogs(socket);
|
||||
await webConsoleRcon(socket);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue