forked from shirof1re/OpenDocPy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
prod.py
102 lines (67 loc) · 2.99 KB
/
prod.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
import re
import json
from random import shuffle
from constants import CONFIG_PATH
from utils import read_json, write_json
from core.function.update import updateData
from flask import request
def randomHash():
hash = list("abcdef")
shuffle(hash)
return ''.join(hash)
def prodRefreshConfig():
data = {
"resVersion": None
}
return data, 200
def prodAndroidVersion():
server_config = read_json(CONFIG_PATH)
mode = server_config["server"]["mode"]
if mode == "cn":
version = server_config["version"]["android"]
elif mode == "global":
version = server_config["versionGlobal"]["android"]
if server_config["assets"]["enableMods"]:
version["resVersion"] = version["resVersion"][:18] + randomHash()
return version
def prodNetworkConfig():
server_config = read_json(CONFIG_PATH)
mode = server_config["server"]["mode"]
server = "http://" + server_config["server"]["host"] + ":" + str(server_config["server"]["port"])
if server_config["server"]["adaptive"]:
server = request.host_url[:-1]
network_config = server_config["networkConfig"][mode]
funcVer = network_config["content"]["funcVer"]
if server_config["assets"]["autoUpdate"]:
if mode == "cn":
version = updateData("https://ak-conf.hypergryph.com/config/prod/official/Android/version")
server_config["version"]["android"] = version
elif mode == "global":
version = updateData("https://ark-us-static-online.yo-star.com/assetbundle/official/Android/version")
server_config["versionGlobal"]["android"] = version
write_json(server_config, CONFIG_PATH)
for index in network_config["content"]["configs"][funcVer]["network"]:
url = network_config["content"]["configs"][funcVer]["network"][index]
if isinstance(url, str) and url.find("{server}") >= 0:
network_config["content"]["configs"][funcVer]["network"][index] = re.sub("{server}", server, url)
network_config["content"] = json.dumps(network_config["content"])
return json.dumps(network_config)
def prodRemoteConfig():
remote = read_json(CONFIG_PATH)["remote"]
return json.dumps(remote)
def prodPreAnnouncement():
server_config = read_json(CONFIG_PATH)
mode = server_config["server"]["mode"]
if mode == "cn":
data = updateData("https://ak-conf.hypergryph.com/config/prod/announce_meta/Android/preannouncement.meta.json")
elif mode == "global":
data = updateData("https://ark-us-static-online.yo-star.com/announce/Android/preannouncement.meta.json")
return data
def prodAnnouncement():
server_config = read_json(CONFIG_PATH)
mode = server_config["server"]["mode"]
if mode == "cn":
data = updateData("https://ak-conf.hypergryph.com/config/prod/announce_meta/Android/announcement.meta.json")
elif mode == "global":
data = updateData("https://ark-us-static-online.yo-star.com/announce/Android/announcement.meta.json")
return data