forked from Kourva/V2rayDoprax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getConfig.py
54 lines (38 loc) · 1.07 KB
/
getConfig.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
#!/usr/bin/env python3
# Get vmess config from vmess url
# Imports
import base64
import time
import json
import sys
def printer(message: str) -> None:
message = message.replace("'", '"')
parsed_json = json.loads(message)
pretty_json = json.dumps(parsed_json, indent=4)
for char in pretty_json:
sys.stdout.write(char)
sys.stdout.flush()
time.sleep(0.01)
print("\n")
def get_config(vmess_url):
target = vmess_url.split("vmess://")[1].strip()
tempvar = target.encode("ascii")
message = base64.b64decode(tempvar)
configs = message.decode("ascii")
return configs
# Run the program
if __name__ == "__main__":
if len(sys.argv) != 1:
if sys.argv[1] in ["-h", "--help"]:
print(
"""
Help: python getConfig.py [argumentss]
for extracting config -> python getConfig.py [vmess url]
for showing help message -> python getConfig.py [-h, --help]
"""
)
else:
printer(get_config(sys.argv[1]))
else:
print("No argument! run with -h")
# EOF