Apply uniform Base64 encoding for RCON options and standardize operation names
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
RDB_OpPlayerGet = {}
|
RDB_OpPlayerGet = {}
|
||||||
|
|
||||||
function RDB_OpPlayerGet.register()
|
function RDB_OpPlayerGet.register()
|
||||||
RDB_OpRegistry.register("player.get", {
|
RDB_OpRegistry.register("get_player", {
|
||||||
argsSchema = { id = "string" },
|
argsSchema = { id = "string" },
|
||||||
handler = function(args)
|
handler = function(args)
|
||||||
local snapshot = RDB_PlayerSnapshot.get(args.id)
|
local snapshot = RDB_PlayerSnapshot.get(args.id)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ local DEFAULT_LIMIT = 50
|
|||||||
local MAX_LIMIT = 200
|
local MAX_LIMIT = 200
|
||||||
|
|
||||||
function RDB_OpPlayerList.register()
|
function RDB_OpPlayerList.register()
|
||||||
RDB_OpRegistry.register("player.list", {
|
RDB_OpRegistry.register("list_players", {
|
||||||
handler = function(args)
|
handler = function(args)
|
||||||
local all = RDB_PlayerSnapshot.listAll()
|
local all = RDB_PlayerSnapshot.listAll()
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
RDB_OpServerSave = {}
|
RDB_OpServerSave = {}
|
||||||
|
|
||||||
function RDB_OpServerSave.register()
|
function RDB_OpServerSave.register()
|
||||||
RDB_OpRegistry.register("server.save", {
|
RDB_OpRegistry.register("save_server", {
|
||||||
handler = function(_)
|
handler = function(_)
|
||||||
local ok = pcall(function() GameWindow.save(true) end)
|
local ok = pcall(function() GameWindow.save(true) end)
|
||||||
if not ok then
|
if not ok then
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
RDB_OpWorldGetStats = {}
|
RDB_OpWorldGetStats = {}
|
||||||
|
|
||||||
function RDB_OpWorldGetStats.register()
|
function RDB_OpWorldGetStats.register()
|
||||||
RDB_OpRegistry.register("world.get_stats", {
|
RDB_OpRegistry.register("get_world_stats", {
|
||||||
handler = function(_)
|
handler = function(_)
|
||||||
return true, RDB_WorldStats.collect()
|
return true, RDB_WorldStats.collect()
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -14,8 +14,19 @@
|
|||||||
-- quirk between the two OnServerStarted firings); addOption is wrapped in
|
-- quirk between the two OnServerStarted firings); addOption is wrapped in
|
||||||
-- pcall as a second, authoritative line of defense. Runtime state ends up
|
-- pcall as a second, authoritative line of defense. Runtime state ends up
|
||||||
-- correct either way.
|
-- 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_Log")
|
||||||
|
require("RconDataBridge.RDB_Base64")
|
||||||
|
|
||||||
RDB_OptionsRegistry = {}
|
RDB_OptionsRegistry = {}
|
||||||
|
|
||||||
@@ -25,7 +36,7 @@ function RDB_OptionsRegistry.register(name, defaultValue, maxLength)
|
|||||||
return
|
return
|
||||||
end
|
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)
|
local ok = pcall(function() so:addOption(opt) end)
|
||||||
if not ok then
|
if not ok then
|
||||||
return
|
return
|
||||||
@@ -44,5 +55,5 @@ end
|
|||||||
-- RCON-initiated config change but wasteful for our own frequent internal
|
-- RCON-initiated config change but wasteful for our own frequent internal
|
||||||
-- publishes (Response, WorldStats, etc. are runtime state, not persisted config).
|
-- publishes (Response, WorldStats, etc. are runtime state, not persisted config).
|
||||||
function RDB_OptionsRegistry.set(name, value)
|
function RDB_OptionsRegistry.set(name, value)
|
||||||
ServerOptions.instance:putOption(name, value)
|
ServerOptions.instance:putOption(name, RDB_Base64.encode(value))
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,10 +9,10 @@
|
|||||||
-- tokenization regardless of which token form matched. Base64 has no quote
|
-- tokenization regardless of which token form matched. Base64 has no quote
|
||||||
-- characters in its alphabet, so it survives changeoption intact.
|
-- characters in its alphabet, so it survives changeoption intact.
|
||||||
--
|
--
|
||||||
-- Only the request channel needs this: responses are written via
|
-- Applied uniformly to every RconDataBridge_* option in both directions
|
||||||
-- ServerOptions:putOption (a direct Lua/Java call, not the RCON text-command
|
-- (see RDB_OptionsRegistry.register/set), not just the request channel that
|
||||||
-- path) and read via showoptions, neither of which goes through the
|
-- strictly needs it: a client only ever has to deal with one rule ("every
|
||||||
-- tokenizer, so they carry raw JSON unmolested.
|
-- value is base64"), never a request-only exception to remember.
|
||||||
|
|
||||||
RDB_Base64 = {}
|
RDB_Base64 = {}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user