Skip to content

Commit b1eed65

Browse files
authored
Merge pull request #538 from leancloud/update-app-router
fix: update domains for cn-n1 apps
2 parents 1a7ad7f + f20e7f7 commit b1eed65

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

leancloud/app_router.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(self, app_id, region):
2222
self.expired_at = 0
2323

2424
prefix = app_id[:8].lower()
25-
domain = "lncld.net"
25+
is_cn_n1 = False
2626

2727
if region == "US":
2828
domain = "lncldglobal.com"
@@ -32,14 +32,19 @@ def __init__(self, app_id, region):
3232
elif app_id.endswith("-MdYXbMMI"):
3333
domain = "lncldglobal.com"
3434
else:
35-
domain = "lncld.net"
35+
domain = "{}.lc-cn-n1-shared.com".format(prefix)
36+
is_cn_n1 = True
3637
else:
3738
raise RuntimeError("invalid region: {}".format(region))
3839

39-
self.hosts["api"] = "{}.api.{}".format(prefix, domain)
40-
self.hosts["engine"] = "{}.engine.{}".format(prefix, domain)
41-
self.hosts["stats"] = "{}.stats.{}".format(prefix, domain)
42-
self.hosts["push"] = "{}.push.{}".format(prefix, domain)
40+
if is_cn_n1:
41+
self.hosts.update(dict.fromkeys(
42+
["api", "engine", "stats", "push"], domain))
43+
else:
44+
self.hosts["api"] = "{}.api.{}".format(prefix, domain)
45+
self.hosts["engine"] = "{}.engine.{}".format(prefix, domain)
46+
self.hosts["stats"] = "{}.stats.{}".format(prefix, domain)
47+
self.hosts["push"] = "{}.push.{}".format(prefix, domain)
4348

4449
def get(self, type_):
4550
with self.lock:

0 commit comments

Comments
 (0)