From 2e5f3d5363b063c2cf99a4abcb58c085d9485150 Mon Sep 17 00:00:00 2001 From: Aleksandr Lobanov Date: Wed, 6 Nov 2024 04:37:24 +0700 Subject: [PATCH 1/2] feat: allow execution of raw RCON commands via WebSocket clients --- squad-server/rcon.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/squad-server/rcon.js b/squad-server/rcon.js index 2355d6d2..760c870f 100644 --- a/squad-server/rcon.js +++ b/squad-server/rcon.js @@ -223,4 +223,8 @@ export default class SquadRcon extends Rcon { async switchTeam(anyID) { await this.execute(`AdminForceTeamChange "${anyID}"`); } + + async executeCommand(command) { + return await this.execute(command); + } } From 13efbf6d56ca25be3cb17e3a4a7b0901cc88a21a Mon Sep 17 00:00:00 2001 From: Aleksandr Lobanov Date: Thu, 7 Nov 2024 10:03:14 +0700 Subject: [PATCH 2/2] feat: all funtions return responses for socket io --- core/rcon.js | 12 ------------ squad-server/rcon.js | 14 +++++++++----- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/core/rcon.js b/core/rcon.js index 685b8f0e..a15961a2 100644 --- a/core/rcon.js +++ b/core/rcon.js @@ -413,16 +413,4 @@ export default class Rcon extends EventEmitter { decodedPacketToString(decodedPacket) { return util.inspect(decodedPacket, { breakLength: Infinity }); } - - async warn(anyID, message) { - await this.execute(`AdminWarn "${anyID}" ${message}`); - } - - async kick(anyID, reason) { - await this.execute(`AdminKick "${anyID}" ${reason}`); - } - - async forceTeamChange(anyID) { - await this.execute(`AdminForceTeamChange "${anyID}"`); - } } diff --git a/squad-server/rcon.js b/squad-server/rcon.js index 760c870f..da14a1d5 100644 --- a/squad-server/rcon.js +++ b/squad-server/rcon.js @@ -204,24 +204,28 @@ export default class SquadRcon extends Rcon { } async broadcast(message) { - await this.execute(`AdminBroadcast ${message}`); + return await this.execute(`AdminBroadcast ${message}`); } async setFogOfWar(mode) { - await this.execute(`AdminSetFogOfWar ${mode}`); + return await this.execute(`AdminSetFogOfWar ${mode}`); } async warn(anyID, message) { - await this.execute(`AdminWarn "${anyID}" ${message}`); + return await this.execute(`AdminWarn "${anyID}" ${message}`); + } + + async kick(anyID, reason) { + return await this.execute(`AdminKick "${anyID}" ${reason}`); } // 0 = Perm | 1m = 1 minute | 1d = 1 Day | 1M = 1 Month | etc... async ban(anyID, banLength, message) { - await this.execute(`AdminBan "${anyID}" ${banLength} ${message}`); + return await this.execute(`AdminBan "${anyID}" ${banLength} ${message}`); } async switchTeam(anyID) { - await this.execute(`AdminForceTeamChange "${anyID}"`); + return await this.execute(`AdminForceTeamChange "${anyID}"`); } async executeCommand(command) {