forked from Jrohy/multi-v2ray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
v2ray
executable file
·410 lines (375 loc) · 11.6 KB
/
v2ray
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
#!/bin/bash
#######color code########
RED="31m" # Error message
GREEN="32m" # Success message
YELLOW="33m" # Warning message
BLUE="36m" # Info message
colorEcho(){
COLOR=$1
echo -e "\033[${COLOR}${@:2}\033[0m"
}
cleanLog() {
cat /dev/null > /var/log/v2ray/access.log
cat /dev/null > /var/log/v2ray/error.log
colorEcho ${GREEN} "清理v2ray日志成功!\n"
}
#Check Root
[ $(id -u) != "0" ] && { colorEcho ${RED} "Error: You must be root to run this script"; exit 1; }
help(){
echo "v2ray [-h|--help] [options]"
echo " -h, --help 查看帮助"
echo " start 启动 V2Ray"
echo " stop 停止 V2Ray"
echo " restart 重启 V2Ray"
echo " status 查看 V2Ray 运行状态"
echo " log 查看 V2Ray 运行日志"
echo " update 更新 V2Ray"
echo " update.sh 更新 multi-v2ray脚本"
echo " add 新增mkcp + 随机一种 (srtp | wechat-video | utp | dtls) header伪装的端口(Group)"
echo " add [wechat|utp|srtp|dtls|wireguard|socks|mtproto|ss] 新增一种协议的组,端口随机,如 v2ray add utp 为新增utp协议"
echo " del 删除端口组"
echo " info 查看配置"
echo " port 修改端口"
echo " tls 修改tls"
echo " tfo 修改tcpFastOpen"
echo " stream 修改传输协议"
echo " stats 流量统计"
echo " clean 清理日志"
echo " 更多功能 请输入 v2ray 回车进入服务管理程序"
return 0
}
PARAMS_NUM=$#
#######get params#########
while [[ $# > 0 ]];do
key="$1"
case $key in
-h|--help)
help
;;
start)
service v2ray start
colorEcho ${GREEN} "v2ray启动成功!"
;;
stop)
service v2ray stop
colorEcho ${GREEN} "v2ray已停止!"
;;
restart)
service v2ray restart
colorEcho ${GREEN} "v2ray重启成功!"
;;
status)
service v2ray status
;;
log)
colorEcho ${BLUE} "按Ctrl + C 可以退出日志功能\n"
tail -f /var/log/v2ray/access.log
;;
update)
bash <(curl -L -s https://install.direct/go.sh)
;;
update.sh)
source <(curl -sL https://git.io/fNgqx) -k
;;
info)
python3 /usr/local/multi-v2ray/server_info.py
;;
port)
python3 /usr/local/multi-v2ray/config_modify/port.py
python3 /usr/local/multi-v2ray/base_util/open_port.py
service v2ray restart
;;
tls)
python3 /usr/local/multi-v2ray/config_modify/tls.py
service v2ray restart
;;
tfo)
python3 /usr/local/multi-v2ray/config_modify/tfo.py
service v2ray restart
;;
stream)
python3 /usr/local/multi-v2ray/config_modify/stream.py
service v2ray restart
;;
stats)
python3 /usr/local/multi-v2ray/other_setting/stats_ctr.py
;;
clean)
cleanLog
;;
del)
python3 /usr/local/multi-v2ray/user_manage/del_port.py
service v2ray restart
;;
add)
EXTRA="$2"
python3 /usr/local/multi-v2ray/user_manage/create_new_port.py $EXTRA
python3 /usr/local/multi-v2ray/base_util/open_port.py
service v2ray restart
shift
;;
*)
colorEcho ${YELLOW} "传参有误! 输入-h 或者--help查看帮助" # unknown option
;;
esac
shift # past argument or value
done
#############################
##有参数输入操作一波后就结束
[[ $PARAMS_NUM > 0 ]] && exit
echo ""
colorEcho ${BLUE} "欢迎使用 multi-v2ray 管理程序"
echo -e ""
echo -e "1.服务管理 2.用户管理\n"
echo -e "3.更改配置 4.查看配置\n"
echo -e "5.其他功能 6.更新V2Ray\n"
echo -e "7.生成客户端配置文件"
while :; do echo
read -n1 -p "请输入数字选择功能(按回车键退出): " CHOICE
if [[ ! $CHOICE =~ ^[1-7]$ ]]; then
if [[ -z ${CHOICE} ]];then
exit 0
fi
colorEcho ${RED} "输入错误! 请输入正确的数字!"
else
echo -e "\n"
break
fi
done
if [[ ${CHOICE} == 1 ]]; then
echo -e "1.启动服务"
echo -e "2.停止服务"
echo -e "3.重启服务"
echo -e "4.运行状态"
echo -e "5.运行日志"
while :; do echo
read -n1 -p "请选择: " SERVICE_CHOICE
if [[ ! $SERVICE_CHOICE =~ ^[1-5]$ ]]; then
if [[ -z ${SERVICE_CHOICE} ]];then
bash /usr/local/bin/v2ray
exit 0
fi
colorEcho ${RED} "输入错误! 请输入正确的数字!"
else
echo -e "\n"
break
fi
done
if [[ ${SERVICE_CHOICE} == 1 ]]; then
service v2ray start
python3 /usr/local/multi-v2ray/base_util/open_port.py
echo "服务启动成功!"
bash /usr/local/bin/v2ray
fi
if [[ ${SERVICE_CHOICE} == 2 ]]; then
service v2ray stop
echo "服务停止成功!"
bash /usr/local/bin/v2ray
fi
if [[ ${SERVICE_CHOICE} == 3 ]]; then
service v2ray restart
python3 /usr/local/multi-v2ray/base_util/open_port.py
echo "服务已重启!"
bash /usr/local/bin/v2ray
fi
if [[ ${SERVICE_CHOICE} == 4 ]]; then
service v2ray status
bash /usr/local/bin/v2ray
fi
if [[ ${SERVICE_CHOICE} == 5 ]]; then
echo "按Ctrl + C 可以退出日志功能"
echo ""
tail -f /var/log/v2ray/access.log
bash /usr/local/bin/v2ray
fi
fi
if [[ ${CHOICE} == 2 ]]; then
echo -e "1.新增用户\n"
echo -e "2.新增端口\n"
echo -e "3.删除用户\n"
echo -e "4.删除端口\n"
while :; do echo
read -n1 -p "请输入数字选择功能: " USER_CHOICE
if [[ ! $USER_CHOICE =~ ^[1-4]$ ]]; then
if [[ -z ${USER_CHOICE} ]];then
bash /usr/local/bin/v2ray
exit 0
fi
colorEcho ${RED} "输入错误! 请输入正确的数字!"
else
echo -e "\n"
break
fi
done
if [[ ${USER_CHOICE} == 1 ]]; then
python3 /usr/local/multi-v2ray/user_manage/create_new_user.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${USER_CHOICE} == 2 ]]; then
python3 /usr/local/multi-v2ray/user_manage/create_new_port.py
python3 /usr/local/multi-v2ray/base_util/open_port.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${USER_CHOICE} == 3 ]]; then
python3 /usr/local/multi-v2ray/user_manage/del_user.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${USER_CHOICE} == 4 ]]; then
python3 /usr/local/multi-v2ray/user_manage/del_port.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
fi
if [[ ${CHOICE} == 3 ]]; then
echo ""
echo -e "1.更改email\n"
echo -e "2.更改UUID\n"
echo -e "3.更改alterID\n"
echo -e "4.更改主端口\n"
echo -e "5.更改传输方式\n"
echo -e "6.更改TLS设置\n"
echo -e "7.更改tcpFastOpen设置\n"
echo -e "8.更改广告拦截功能\n"
echo -e "9.更改动态端口\n"
echo -e "10.更改Shadowsocks加密方式\n"
echo -e "11.更改Shadowsocks密码\n"
while :; do echo
read -p "请输入数字选择功能: " CONFIG_CHOICE
if [[ ! $CONFIG_CHOICE =~ (^[1-9]$|10|11) ]]; then
if [[ -z ${CONFIG_CHOICE} ]];then
bash /usr/local/bin/v2ray
exit 0
fi
colorEcho ${RED} "输入错误! 请输入正确的数字!"
else
echo -e "\n"
break
fi
done
if [[ ${CONFIG_CHOICE} == 1 ]]; then
python3 /usr/local/multi-v2ray/config_modify/n_email.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${CONFIG_CHOICE} == 2 ]]; then
python3 /usr/local/multi-v2ray/config_modify/n_uuid.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${CONFIG_CHOICE} == 3 ]]; then
python3 /usr/local/multi-v2ray/config_modify/alterid.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${CONFIG_CHOICE} == 4 ]]; then
python3 /usr/local/multi-v2ray/config_modify/port.py
python3 /usr/local/multi-v2ray/base_util/open_port.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${CONFIG_CHOICE} == 5 ]]; then
python3 /usr/local/multi-v2ray/config_modify/stream.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${CONFIG_CHOICE} == 6 ]]; then
python3 /usr/local/multi-v2ray/config_modify/tls.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${CONFIG_CHOICE} == 7 ]]; then
python3 /usr/local/multi-v2ray/config_modify/tfo.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${CONFIG_CHOICE} == 8 ]]; then
python3 /usr/local/multi-v2ray/config_modify/ad.py
service v2ray restart
echo ""
echo "广告拦截功能设置成功!"
bash /usr/local/bin/v2ray
fi
if [[ ${CONFIG_CHOICE} == 9 ]]; then
python3 /usr/local/multi-v2ray/config_modify/dyn_port.py
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${CONFIG_CHOICE} == 10 ]]; then
python3 /usr/local/multi-v2ray/config_modify/ss.py method
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
if [[ ${CONFIG_CHOICE} == 11 ]]; then
python3 /usr/local/multi-v2ray/config_modify/ss.py password
service v2ray restart
echo ""
bash /usr/local/bin/v2ray
fi
fi
if [[ ${CHOICE} == 4 ]]; then
python3 /usr/local/multi-v2ray/server_info.py
bash /usr/local/bin/v2ray
fi
if [[ ${CHOICE} == 5 ]]; then
echo -e ""
echo -e "1.流量统计\n"
echo -e "2.定时更新V2ray\n"
echo -e "3.清理v2ray日志\n"
echo -e "4.脚本升级\n"
echo -e "请输入数字选择功能:\n"
while :; do echo
read -n1 -p "请选择: " EXTRA_CHOICE
if [[ ! $EXTRA_CHOICE =~ ^[1-4]$ ]]; then
if [[ -z ${EXTRA_CHOICE} ]];then
bash /usr/local/bin/v2ray
exit 0
fi
colorEcho ${RED} "输入错误! 请输入正确的数字!"
else
echo -e "\n"
break
fi
done
if [[ ${EXTRA_CHOICE} == 1 ]]; then
python3 /usr/local/multi-v2ray/other_setting/stats_ctr.py
bash /usr/local/bin/v2ray
fi
if [[ ${EXTRA_CHOICE} == 2 ]]; then
bash /usr/local/multi-v2ray/other_setting/update_timer.sh
bash /usr/local/bin/v2ray
fi
if [[ ${EXTRA_CHOICE} == 3 ]]; then
cleanLog
bash /usr/local/bin/v2ray
fi
if [[ ${EXTRA_CHOICE} == 4 ]]; then
echo -e "脚本正在以保留配置文件形式升级, 若失败请自行手动全新安装..\n"
source <(curl -sL https://git.io/fNgqx) -k
echo -e "\n脚本升级成功!!\n"
bash /usr/local/bin/v2ray
fi
fi
if [[ ${CHOICE} == 6 ]]; then
bash <(curl -L -s https://install.direct/go.sh)
bash /usr/local/bin/v2ray
fi
if [[ ${CHOICE} == 7 ]]; then
python3 /usr/local/multi-v2ray/base_util/gen_client.py
bash /usr/local/bin/v2ray
fi