mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
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.
This commit is contained in:
1 parent
72c8b8426d
commit
2ae51a1e6a
2 files changed
+20
No files matched your search
@@ -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");
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in new issue
Block a user