From 3bebae73ed9c76a2ecd55bb324b519d0b8a252c9 Mon Sep 17 00:00:00 2001 From: Overlord Date: Wed, 26 Aug 2026 15:06:30 +0200 Subject: [PATCH] Apply uniform Base64 encoding for RCON options and standardize operation names --- .../server/RconDataBridge/Ops/RDB_OpPlayerGet.lua | 2 +- .../RconDataBridge/Ops/RDB_OpPlayerList.lua | 2 +- .../RconDataBridge/Ops/RDB_OpServerSave.lua | 2 +- .../RconDataBridge/Ops/RDB_OpWorldGetStats.lua | 2 +- .../server/RconDataBridge/RDB_OptionsRegistry.lua | 15 +++++++++++++-- .../lua/shared/RconDataBridge/RDB_Base64.lua | 8 ++++---- 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpPlayerGet.lua b/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpPlayerGet.lua index 342df36..363333e 100644 --- a/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpPlayerGet.lua +++ b/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpPlayerGet.lua @@ -4,7 +4,7 @@ RDB_OpPlayerGet = {} function RDB_OpPlayerGet.register() - RDB_OpRegistry.register("player.get", { + RDB_OpRegistry.register("get_player", { argsSchema = { id = "string" }, handler = function(args) local snapshot = RDB_PlayerSnapshot.get(args.id) diff --git a/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpPlayerList.lua b/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpPlayerList.lua index afdf048..3f760c6 100644 --- a/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpPlayerList.lua +++ b/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpPlayerList.lua @@ -11,7 +11,7 @@ local DEFAULT_LIMIT = 50 local MAX_LIMIT = 200 function RDB_OpPlayerList.register() - RDB_OpRegistry.register("player.list", { + RDB_OpRegistry.register("list_players", { handler = function(args) local all = RDB_PlayerSnapshot.listAll() diff --git a/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpServerSave.lua b/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpServerSave.lua index 02d7fdf..664b0fa 100644 --- a/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpServerSave.lua +++ b/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpServerSave.lua @@ -4,7 +4,7 @@ RDB_OpServerSave = {} function RDB_OpServerSave.register() - RDB_OpRegistry.register("server.save", { + RDB_OpRegistry.register("save_server", { handler = function(_) local ok = pcall(function() GameWindow.save(true) end) if not ok then diff --git a/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpWorldGetStats.lua b/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpWorldGetStats.lua index c0fd43a..dccfe74 100644 --- a/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpWorldGetStats.lua +++ b/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/Ops/RDB_OpWorldGetStats.lua @@ -9,7 +9,7 @@ RDB_OpWorldGetStats = {} function RDB_OpWorldGetStats.register() - RDB_OpRegistry.register("world.get_stats", { + RDB_OpRegistry.register("get_world_stats", { handler = function(_) return true, RDB_WorldStats.collect() end, diff --git a/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/RDB_OptionsRegistry.lua b/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/RDB_OptionsRegistry.lua index f804cc8..d2c7505 100644 --- a/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/RDB_OptionsRegistry.lua +++ b/Contents/mods/RconDataBridge/common/media/lua/server/RconDataBridge/RDB_OptionsRegistry.lua @@ -14,8 +14,19 @@ -- quirk between the two OnServerStarted firings); addOption is wrapped in -- pcall as a second, authoritative line of defense. Runtime state ends up -- correct either way. +-- +-- Every published value is base64-encoded here, uniformly, for both +-- directions: register()'s default and set()'s value both go through +-- RDB_Base64.encode before reaching ServerOptions. This isn't optional for +-- the request channel (changeoption strips every literal double-quote +-- character from its arguments, corrupting raw JSON and is applied to every +-- other option too so RCON clients deal with one rule, not request-only +-- encoding as a surprise exception. get() intentionally stays raw: +-- the request pipeline diffs the raw stored string for change detection +-- and needs to see it either way, decode failure included. require("RconDataBridge.RDB_Log") +require("RconDataBridge.RDB_Base64") RDB_OptionsRegistry = {} @@ -25,7 +36,7 @@ function RDB_OptionsRegistry.register(name, defaultValue, maxLength) return end - local opt = TextServerOption.new(so, name, defaultValue, maxLength) + local opt = TextServerOption.new(so, name, RDB_Base64.encode(defaultValue), maxLength) local ok = pcall(function() so:addOption(opt) end) if not ok then return @@ -44,5 +55,5 @@ end -- RCON-initiated config change but wasteful for our own frequent internal -- publishes (Response, WorldStats, etc. are runtime state, not persisted config). function RDB_OptionsRegistry.set(name, value) - ServerOptions.instance:putOption(name, value) + ServerOptions.instance:putOption(name, RDB_Base64.encode(value)) end diff --git a/Contents/mods/RconDataBridge/common/media/lua/shared/RconDataBridge/RDB_Base64.lua b/Contents/mods/RconDataBridge/common/media/lua/shared/RconDataBridge/RDB_Base64.lua index edaa01c..e081ae9 100644 --- a/Contents/mods/RconDataBridge/common/media/lua/shared/RconDataBridge/RDB_Base64.lua +++ b/Contents/mods/RconDataBridge/common/media/lua/shared/RconDataBridge/RDB_Base64.lua @@ -9,10 +9,10 @@ -- tokenization regardless of which token form matched. Base64 has no quote -- characters in its alphabet, so it survives changeoption intact. -- --- Only the request channel needs this: responses are written via --- ServerOptions:putOption (a direct Lua/Java call, not the RCON text-command --- path) and read via showoptions, neither of which goes through the --- tokenizer, so they carry raw JSON unmolested. +-- Applied uniformly to every RconDataBridge_* option in both directions +-- (see RDB_OptionsRegistry.register/set), not just the request channel that +-- strictly needs it: a client only ever has to deal with one rule ("every +-- value is base64"), never a request-only exception to remember. RDB_Base64 = {}