From 2ae51a1e6a7ae279d710bd92dbec074f6ffe3b82 Mon Sep 17 00:00:00 2001 From: visail Date: Mon, 23 Nov 2026 10:50:58 +0800 Subject: [PATCH] fix(battlenet): install China products under their own uids The China client installs Diablo II, StarCraft II and Diablo III under the CN uids and products of its own repository instead of the global ones. Only an install request is remapped: an update or uninstall keeps using the uid the Agent already recorded. --- .../overlay/usr/local/bin/droiddeck-battlenet | 12 ++++++++++++ tools/tests/test_battlenet.py | 8 ++++++++ 2 files changed, 20 insertions(+) diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet b/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet index 0f426d9029..be1dfb6a18 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-battlenet @@ -135,6 +135,9 @@ function job(text) { return /"state"\s*:\s*\d+/.test(bare) || /"download_current"\s*:/.test(bare); } +var CHINA = {osi: "osic", s2: "s2_cn", anbs: "anbs_cn", diablo3: "d3cn"}; +var CHINA_PRODUCT = {osi: "osic", s2: "s2c", diablo3: "d3cn"}; + function install() { // Blizzard's China repository moved to cn.patch.battlenet.com.cn; cn.patch.battle.net only redirects away from it. var patch = zone == "cn" ? "cn.patch.battlenet.com.cn" : zone + ".patch.battle.net"; @@ -193,6 +196,15 @@ try { token = field(agent, "authorization"); zone = field(agent, "region") || "us"; if (!token) throw new Error("no authorization from the agent"); + // The China client installs these under uids of its own. s2_cn is served from s2c; anbs_cn shares anbs. + if (zone == "cn" && action == "install") { + country = "CHN"; + region = "CN"; + if (CHINA[uid]) { + product = CHINA_PRODUCT[uid] || product; + uid = CHINA[uid]; + } + } if (action == "install") install(); else if (action == "update") update(); else uninstall(); } catch (e) { save(".error", e.message || "the agent stopped answering"); diff --git a/tools/tests/test_battlenet.py b/tools/tests/test_battlenet.py index 06fdc779c4..8c737699ea 100644 --- a/tools/tests/test_battlenet.py +++ b/tools/tests/test_battlenet.py @@ -1493,6 +1493,14 @@ class AgentTest(Temp): self.assertIn('var patch = zone == "cn" ? "cn.patch.battlenet.com.cn" : zone + ".patch.battle.net";', script) self.assertIn("+ patch + ':1119/'", script) + def test_the_driver_installs_chinas_products_under_their_own_uids(self): + script = BNET["AGENT_SCRIPT"] + self.assertIn('var CHINA = {osi: "osic", s2: "s2_cn", anbs: "anbs_cn", diablo3: "d3cn"};', script) + self.assertIn('var CHINA_PRODUCT = {osi: "osic", s2: "s2c", diablo3: "d3cn"};', script) + self.assertIn('if (zone == "cn" && action == "install") {', script) + self.assertIn('country = "CHN";', script) + self.assertIn('region = "CN";', script) + class AgentJobTest(Harness): def setUp(self):