@@ -20,31 +20,26 @@ def __init__(self, app_id, region):
2020 self .session = requests .Session ()
2121 self .lock = threading .Lock ()
2222 self .expired_at = 0
23+
24+ prefix = app_id [:8 ].lower ()
25+ domain = 'lncld.net'
26+
2327 if region == 'US' :
24- self .hosts ['api' ] = 'us-api.leancloud.cn'
25- self .hosts ['engine' ] = 'us-api.leancloud.cn'
26- self .hosts ['stats' ] = 'us-api.leancloud.cn'
27- self .hosts ['push' ] = 'us-api.leancloud.cn'
28+ domain = 'lncldglobal.com'
2829 elif region == 'CN' :
2930 if app_id .endswith ('-9Nh9j0Va' ):
30- self .hosts ['api' ] = 'e1-api.leancloud.cn'
31- self .hosts ['engine' ] = 'e1-api.leancloud.cn'
32- self .hosts ['stats' ] = 'e1-api.leancloud.cn'
33- self .hosts ['push' ] = 'e1-api.leancloud.cn'
31+ domain = 'lncldapi.com'
3432 else :
35- prefix = app_id [:8 ].lower ()
36- self .hosts ['api' ] = '{}.api.lncld.net' .format (prefix )
37- self .hosts ['engine' ] = '{}.engine.lncld.net' .format (prefix )
38- self .hosts ['stats' ] = '{}.stats.lncld.net' .format (prefix )
39- self .hosts ['push' ] = '{}.push.lncld.net' .format (prefix )
33+ domain = 'lncld.net'
4034 else :
4135 raise RuntimeError ('invalid region: {}' .format (region ))
4236
43- def get ( self , type_ ):
44- if self .region == 'US' :
45- # US region dose not support app router stuff
46- return self .hosts [type_ ]
37+ self . hosts [ 'api' ] = '{}.api.{}' . format ( prefix , domain )
38+ self .hosts [ 'engine' ] = '{}.engine.{}' . format ( prefix , domain )
39+ self . hosts [ 'stats' ] = '{}.stats.{}' . format ( prefix , domain )
40+ self .hosts ['push' ] = '{}.push.{}' . format ( prefix , domain )
4741
42+ def get (self , type_ ):
4843 with self .lock :
4944 if time .time () > self .expired_at :
5045 self .expired_at += 600
0 commit comments