-
Notifications
You must be signed in to change notification settings - Fork 2
/
xray-manager.py
executable file
·278 lines (224 loc) · 14.4 KB
/
xray-manager.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/usr/bin/env python3
from stricker_watcher import StrickerWatcher
from user_managment import ClientHandler,OsTools
from consol import Argument
import json
import os
from network_manager import NetworkManager
from doc_generator import DocGenerator
from time import sleep
class Config:
def __init__(
self,
conf_dir:str
)->None :
self.conf_dir = conf_dir
with open(self.conf_dir,"r") as f :
self.conf_dict = json.loads(f.read())
self.xray_conf = self.conf_dict["XRAY_CONF"]
self.access_dir = self.conf_dict["ACCESS_DIR"]
self.banning_on = self.conf_dict["BANNING_ON"]
self.debug = self.conf_dict["DEBUG"]
self.stricker_connection_num = self.conf_dict["STRICKER_BANNING_CONNECTION_NUM"]
class XrayHandler:
def __init__(self):
self.system_conf = Config("/root/Xray-ClientManager/conf.json")
self.client_handler = ClientHandler(self.system_conf.xray_conf)
self.arguments = Argument()
self.doc = DocGenerator()
# Configuration For Stricker Watcher
self.watcher = StrickerWatcher(check_period=0,
access_dir= self.system_conf.access_dir,
bannig_on= self.system_conf.banning_on,
debug= self.system_conf.debug,
banning_connection_exceed= self.system_conf.stricker_connection_num
)
def _get_user_vmess_all_conf(self,email,domain,vpn_name,cdn):
print("----------------------------------------------------VMESS CDN URL-----------------------------------------------------------------\r\n")
url_vmess_cdn_non_tls = self.client_handler.get_client_url_vmess_cdn_none_tls(email,domain,vpn_name,cdn)
self.client_handler.get_client_qrcode(email,url_vmess_cdn_non_tls,"CDN")
print(url_vmess_cdn_non_tls)
print("-------------------------------------------------VMESS DIRECT TLS URL-------------------------------------------------------------\r\n")
url_vmess_direct_tls = self.client_handler.get_client_url_vmess_direct_tls(email,domain,vpn_name,cdn)
self.client_handler.get_client_qrcode(email,url_vmess_direct_tls,"TLS")
print(url_vmess_direct_tls)
print("--------------------------------------------------VMESS CDN TLS URL---------------------------------------------------------------\r\n")
url_vmess_cdn_tls = self.client_handler.get_client_url_vmess_cdn_tls(email,domain,vpn_name,cdn)
self.client_handler.get_client_qrcode(email,url_vmess_cdn_tls,"TLS"+"-"+"CDN")
print(url_vmess_cdn_tls)
print("----------------------------------------------------------------------------------------------------------------------------------\r\n\r\n")
def _get_user_vless_all_conf(self,email,domain,vpn_name,cdn):
print("----------------------------------------------------VLESS XTLS-----------------------------------------------------------------\r\n")
url_vless_xtls = self.client_handler.get_client_url_vless_tcp_tls(email,domain,vpn_name,cdn)
self.client_handler.get_client_qrcode(email,url_vless_xtls,"VLESS-TCP-XTLS")
print(url_vless_xtls)
print("-------------------------------------------------VLESS TCP URL-------------------------------------------------------------\r\n")
url_vless_tcp_none_tls = self.client_handler.get_client_url_vless_tcp_none_tls(email,domain,vpn_name,cdn)
self.client_handler.get_client_qrcode(email,url_vless_tcp_none_tls,"VLESS-TCP")
print(url_vless_tcp_none_tls)
print("-------------------------------------------------VLESS WS TLS URL-------------------------------------------------------------\r\n")
url_vless_WS_tls = self.client_handler.get_client_url_vless_ws_tls(email,domain,vpn_name,cdn)
self.client_handler.get_client_qrcode(email,url_vless_WS_tls,"VLESS-WS-TLS")
print(url_vless_WS_tls)
print("----------------------------------------------------------------------------------------------------------------------------------\r\n\r\n")
def _get_config_v1(self,email,domain,vpn_name,cdn):
print("----------------------------------------------------VMESS TCP OBFS-----------------------------------------------------------------\r\n")
url_vmess_tcp_obfs = self.client_handler.get_client_url_vmess_tcp_obfussification(email,domain,vpn_name,cdn)
self.client_handler.get_client_qrcode(email,url_vmess_tcp_obfs,"VMESS-TCP-OBFS")
print(url_vmess_tcp_obfs)
print("----------------------------------------------------VLESS XTLS-----------------------------------------------------------------\r\n")
url_vless_xtls = self.client_handler.get_client_url_vless_tcp_tls(email,domain,vpn_name,cdn)
self.client_handler.get_client_qrcode(email,url_vless_xtls,"VLESS-TCP-TLS")
print(url_vless_xtls)
print("-------------------------------------------------VLESS WS TLS URL-------------------------------------------------------------\r\n")
url_vless_WS_tls = self.client_handler.get_client_url_vless_ws_tls(email,domain,vpn_name,cdn)
self.client_handler.get_client_qrcode(email,url_vless_WS_tls,"VLESS-WS-TLS")
print(url_vless_WS_tls)
print("----------------------------------------------------------------------------------------------------------------------------------\r\n\r\n")
def _line(self):
print("----------------------------------------------------------------------------------------------------------------------------------\r\n\r\n")
def _get_config_v1_1(self,email):
# Getting The Profile
profile = self.client_handler.get_client_profile(email)
append_name_1 = "VMESS-WS-NGINX-TLS"
print("----------------------------------------------------VMESS WS NGINX TLS-----------------------------------------------------------------\r\n")
url_vmess_ws_nginx_tls = self.client_handler.v1_get_url_wmess_ws_nginx_tls(email)
self.client_handler.get_client_qrcode(email,url_vmess_ws_nginx_tls,append_name_1)
print(url_vmess_ws_nginx_tls)
self._line()
print("-------------------------------------------------VMESS WS NGINX TLS PROXY---------------------------------------------------------------\r\n")
append_name_2 = "VMESS-WS-NGINX-TLS-PROXY"
url_vmess_ws_nginx_tls_proxy = self.client_handler.v1_get_url_wmess_ws_nginx_tls_proxy(email)
self.client_handler.get_client_qrcode(email,url_vmess_ws_nginx_tls_proxy,append_name_2)
print(url_vmess_ws_nginx_tls_proxy)
self._line()
print("-------------------------------------------------------VMESS WS TLS----------------------------------------------------------------------\r\n")
append_name_3 = "VMESS-WS-TLS"
url_vmess_ws_tls = self.client_handler.v1_get_url_wmess_ws_tls(email)
self.client_handler.get_client_qrcode(email,url_vmess_ws_tls,append_name_3)
print(url_vmess_ws_tls)
self._line()
print("------------------------------------------------------VMESS TCP OBFS---------------------------------------------------------------------\r\n")
append_name_4 = "VMESS-TCP-OBFS"
url_vmess_tcp_obfs = self.client_handler.v1_get_url_wmess_tcp_obfs(email)
self.client_handler.get_client_qrcode(email,url_vmess_tcp_obfs,append_name_4)
print(url_vmess_tcp_obfs)
self._line()
print("----------------------------------------------------VLESS TCP TLS OFS--------------------------------------------------------------------\r\n")
append_name_5 = "VLESS-TCP-TLS-OFS"
url_vless_tcp_tls_obfs = self.client_handler.v1_get_url_vless_tcp_tls_obfs(email)
self.client_handler.get_client_qrcode(email,url_vless_tcp_tls_obfs,append_name_5)
print(url_vless_tcp_tls_obfs)
self._line()
print("---------------------------------------------------VLESS TCP XTLS VISION-----------------------------------------------------------------\r\n")
append_name_6 = "VLESS-TCP-XTLS-VISION"
url_vless_tcp_xtls_vision = self.client_handler.v1_get_url_vless_tcp_xtls_vision(email)
self.client_handler.get_client_qrcode(email,url_vless_tcp_xtls_vision,append_name_6)
print(url_vless_tcp_xtls_vision)
self._line()
print("------------------------------------------------------TROJAN GRPC TLS--------------------------------------------------------------------\r\n")
append_name_7 = "TROJAN-GRPC-TLS"
url_trojan_gprc_tls = self.client_handler.v1_get_url_trojan_tcp_grpc_tls(email)
self.client_handler.get_client_qrcode(email,url_trojan_gprc_tls,append_name_7)
print(url_trojan_gprc_tls)
self._line()
print("----------------------------------------------------TROJAN GRPC TLS PROXY-----------------------------------------------------------------\r\n")
append_name_8 = "TROJAN-GRPC-TLS-PROXY"
url_trojan_gprc_tls_proxy = self.client_handler.v1_get_url_trojan_tcp_grpc_tls_proxy(email)
self.client_handler.get_client_qrcode(email,url_trojan_gprc_tls_proxy,append_name_8)
print(url_trojan_gprc_tls_proxy)
self._line()
self.doc.generate_docx_v_1_1(email,profile["id"],append_name_1,append_name_2,append_name_3,append_name_4,append_name_5,append_name_6,append_name_7,append_name_8)
def consol_start(self):
#Ceating Log Direcotry
#self.creat_log_dir()
self.arguments.start()
# Here we Parse The Get User
if self.arguments.args.command :
command = self.arguments.args.command
if command == "get":
if self.arguments.args.domain == None :
print("error : Please Enter The Domain name with |-i domain-name|")
exit()
if self.arguments.args.name == None :
print("error : Please Enter The vpn name with |-n vpn-name|")
exit()
email:str = self.arguments.args.email
domain:str = self.arguments.args.domain
vpn_name:str = self.arguments.args.name
cdn: str = self.arguments.args.cdn
vpn_name = vpn_name.replace(" ","+")
profile = self.client_handler.get_client_profile(email)
if not profile :
print("Error : No user Found")
else :
self._get_config_v1(email,domain,vpn_name,cdn)
elif command == "add":
raw_user: str=self.arguments.args.raw
connection_profile: list = raw_user.split("@")
if len(connection_profile) == 1 :
print("Error Please Insert The User Device Connectivity |x@|")
exit()
self.client_handler.add_user(connection_profile[1],["vmess","vless"],connection_profile[0])
# Here we Apply Changes if The Users specify it
if self.arguments.args.apply :
self.client_handler.apply_changes()
elif command == "check":
interval= self.arguments.args.wait
# To make sure That the Time Has a deafault value
if interval == None :
interval = 50
self.watcher.check_period = interval
email_list = self.client_handler.get_clients_email_list()
self.watcher.stanalone_stricker_watcher(email_list, self.client_handler)
# here Parse The Command For Apply changes on Xray
elif command == "apply" :
self.client_handler.apply_changes()
elif command == "unvalidate" :
email = self.arguments.args.email
self.client_handler.unvalidate_user(email)
self.client_handler.apply_changes()
elif command == "validate":
email = self.arguments.args.email
self.client_handler.validate_user(email)
self.client_handler.apply_changes()
elif command == "del":
email = self.arguments.args.email
self.client_handler.del_user(email)
# Here we Apply Changes if The Users specify it
if self.arguments.args.apply :
self.client_handler.apply_changes()
elif command == "get-all" :
if self.arguments.args.domain == None :
print("error : Please Enter The Domain name with |-i domain-name|")
exit()
if self.arguments.args.name == None :
print("error : Please Enter The vpn name with |-n vpn-name|")
exit()
domain:str = self.arguments.args.domain
vpn_name:str = self.arguments.args.name
cdn: str = self.arguments.args.cdn
clients_email = self.client_handler.get_clients_email_list()
clients_uuid_list = self.client_handler.get_clients_uuid_list()
for index in range(len(clients_email)) :
print(f"\r\n\r\n--------------------------------------------------{clients_email[index]}-----------------------------------------------------------------\r\n")
self._get_config_v1(clients_email[index],domain,vpn_name,cdn)
for index in range(len(clients_email)) :
self.doc.generate_docx(
email=clients_email[index],
uuid= clients_uuid_list[index]
)
elif command == "get-auto" :
email = self.arguments.args.email
self._get_config_v1_1(email)
elif command == "get-auto-all" :
clients_email = self.client_handler.get_clients_email_list()
clients_uuid_list = self.client_handler.get_clients_uuid_list()
for index in range(len(clients_email)) :
print(f"\r\n\r\n--------------------------------------------------{clients_email[index]}-----------------------------------------------------------------\r\n")
self._get_config_v1_1(clients_email[index])
def main():
consol = XrayHandler()
consol.consol_start()
if __name__ == "__main__":
main()