Fix public bank endpoint rollout (Refs josh/tws-zombies-scripts#13)
This commit is contained in:
+12
-7
@@ -35,7 +35,7 @@ import urllib.parse
|
||||
import urllib.request
|
||||
import uuid
|
||||
|
||||
VERSION = "1.9.0"
|
||||
VERSION = "1.9.1"
|
||||
LABEL = "io.electric-cherry"
|
||||
MAX_FILE = 32 * 1024 * 1024
|
||||
MANIFEST_MAX_ENTRIES = 10000
|
||||
@@ -48,6 +48,7 @@ PLUTONIUM_MANIFEST_URL = "https://cdn.plutoniummod.com/updater/prod/info.json"
|
||||
PLUTONIUM_MANIFEST_LIMIT = 2 * 1024 * 1024
|
||||
PLUTONIUM_FILE_LIMIT = 512 * 1024 * 1024
|
||||
PLUTONIUM_CACHE_LIMIT = 4 * 1024 * 1024 * 1024
|
||||
BANK_GAME_ENDPOINT = "https://ec.thewrightserver.net/api/bank"
|
||||
ID_RE = re.compile(r"^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$")
|
||||
AGENT_CONFIG = Path("/etc/electric-cherry/agent.json")
|
||||
AGENT_EXECUTABLE = Path("/usr/local/libexec/electric-cherry-agent.py")
|
||||
@@ -1957,10 +1958,9 @@ class Agent:
|
||||
scoped(self.root / "agent" / "validation", path)
|
||||
if PurePosixPath(path).name != "electric_cherry_bank.cfg":
|
||||
raise Rejected("Invalid private bank config path")
|
||||
controller = self.config["controller"].rstrip("/")
|
||||
if any(char in controller for char in ('"', "\\", "\n", "\r", "\x00")):
|
||||
raise Rejected("Invalid bank controller URL")
|
||||
content = f'set tws_bank_token "{bank["token"]}"\nset tws_bank_url "{controller}/api/bank"\n'.encode()
|
||||
# The game scripts use the public bank API; the host controller address
|
||||
# is only for agent transport and must not become a game URL override.
|
||||
content = f'set tws_bank_token "{bank["token"]}"\n'.encode()
|
||||
return files + [{"path": path, "contentBase64": base64.b64encode(content).decode()}]
|
||||
|
||||
def write_initial_files(self, root, files):
|
||||
@@ -2057,8 +2057,13 @@ class Agent:
|
||||
try:
|
||||
journal = json.loads(raw)
|
||||
reports = journal["reports"]
|
||||
if journal["endpoint"].rstrip("/") != self.config["controller"].rstrip("/") + "/api/bank":
|
||||
raise AgentError("Bank journal belongs to a different controller; runtime storage retained")
|
||||
# Accept the fixed game endpoint and this host's legacy generated
|
||||
# endpoint so rebuild/removal can drain pre-upgrade decisions.
|
||||
# Neither value controls transport: settlement still uses the
|
||||
# enrolled controller, host credential and immutable operation.
|
||||
endpoints = {BANK_GAME_ENDPOINT, self.config["controller"].rstrip("/") + "/api/bank"}
|
||||
if journal["endpoint"].rstrip("/") not in endpoints:
|
||||
raise AgentError("Bank journal has an unrecognized endpoint; runtime storage retained")
|
||||
if type(journal["version"]) is not int or journal["version"] != 1 or not isinstance(reports, list) or len(reports) > 4096:
|
||||
raise ValueError()
|
||||
# Controller independently binds this operation to the instance/server.
|
||||
|
||||
Reference in New Issue
Block a user