Apply uniform Base64 encoding for RCON options and standardize operation names
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user