forked from fscarmen2/Argo-Xray-JS-PaaS
-
Notifications
You must be signed in to change notification settings - Fork 13
/
entrypoint.sh
491 lines (456 loc) · 15.2 KB
/
entrypoint.sh
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
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
#!/usr/bin/env bash
# 设置各变量,WS 路径前缀。(注意:伪装路径不需要 / 符号开始,为避免不必要的麻烦,请不要使用特殊符号.)
WSPATH=${WSPATH:-'argo'}
UUID=${UUID:-'de04add9-5c68-8bab-950c-08cd5320df18'}
WEB_USERNAME=${WEB_USERNAME:-'admin'}
WEB_PASSWORD=${WEB_PASSWORD:-'password'}
# 哪吒4个参数,ssl/tls 看是否需要,不需要的话可以留空,删除或在这4行最前面加 # 以注释
NEZHA_SERVER="$NEZHA_SERVER"
NEZHA_PORT="$NEZHA_PORT"
NEZHA_KEY="$NEZHA_KEY"
NEZHA_TLS="$NEZHA_TLS"
# Argo 固定域名隧道的两个参数,这个可以填 Json 内容或 Token 内容,不需要的话可以留空,删除或在这三行最前面加 # 以注释
ARGO_AUTH=''
ARGO_DOMAIN="$ARGO_DOMAIN"
# ttyd / filebrowser argo 域名
SSH_DOMAIN="$SSH_AUTH"
FTP_DOMAIN="$FTP_AUTH"
# 安装系统依赖
check_dependencies() {
DEPS_CHECK=("wget" "unzip" "ss" "tar")
DEPS_INSTALL=(" wget" " unzip" " iproute2" "tar")
for ((i=0;i<${#DEPS_CHECK[@]};i++)); do [[ ! $(type -p ${DEPS_CHECK[i]}) ]] && DEPS+=${DEPS_INSTALL[i]}; done
[ -n "$DEPS" ] && { apt-get update >/dev/null 2>&1; apt-get install -y $DEPS >/dev/null 2>&1; }
}
# 生成 X 配置文件
generate_config() {
cat > config.json << EOF
{
"log":{
"access":"/dev/null",
"error":"/dev/null",
"loglevel":"none"
},
"inbounds":[
{
"port":8080,
"protocol":"vless",
"settings":{
"clients":[
{
"id":"${UUID}",
"flow":"xtls-rprx-vision"
}
],
"decryption":"none",
"fallbacks":[
{
"dest":3001
},
{
"path":"/${WSPATH}-vless",
"dest":3002
},
{
"path":"/${WSPATH}-vmess",
"dest":3003
},
{
"path":"/${WSPATH}-trojan",
"dest":3004
},
{
"path":"/${WSPATH}-shadowsocks",
"dest":3005
}
]
},
"streamSettings":{
"network":"tcp"
}
},
{
"port":3001,
"listen":"127.0.0.1",
"protocol":"vless",
"settings":{
"clients":[
{
"id":"${UUID}"
}
],
"decryption":"none"
},
"streamSettings":{
"network":"ws",
"security":"none"
}
},
{
"port":3002,
"listen":"127.0.0.1",
"protocol":"vless",
"settings":{
"clients":[
{
"id":"${UUID}",
"level":0
}
],
"decryption":"none"
},
"streamSettings":{
"network":"ws",
"security":"none",
"wsSettings":{
"path":"/${WSPATH}-vless"
}
},
"sniffing":{
"enabled":true,
"destOverride":[
"http",
"tls",
"quic"
],
"metadataOnly":false
}
},
{
"port":3003,
"listen":"127.0.0.1",
"protocol":"vmess",
"settings":{
"clients":[
{
"id":"${UUID}",
"alterId":0
}
]
},
"streamSettings":{
"network":"ws",
"wsSettings":{
"path":"/${WSPATH}-vmess"
}
},
"sniffing":{
"enabled":true,
"destOverride":[
"http",
"tls",
"quic"
],
"metadataOnly":false
}
},
{
"port":3004,
"listen":"127.0.0.1",
"protocol":"trojan",
"settings":{
"clients":[
{
"password":"${UUID}"
}
]
},
"streamSettings":{
"network":"ws",
"security":"none",
"wsSettings":{
"path":"/${WSPATH}-trojan"
}
},
"sniffing":{
"enabled":true,
"destOverride":[
"http",
"tls",
"quic"
],
"metadataOnly":false
}
},
{
"port":3005,
"listen":"127.0.0.1",
"protocol":"shadowsocks",
"settings":{
"clients":[
{
"method":"chacha20-ietf-poly1305",
"password":"${UUID}"
}
],
"decryption":"none"
},
"streamSettings":{
"network":"ws",
"wsSettings":{
"path":"/${WSPATH}-shadowsocks"
}
},
"sniffing":{
"enabled":true,
"destOverride":[
"http",
"tls",
"quic"
],
"metadataOnly":false
}
}
],
"dns":{
"servers":[
"https+local://8.8.8.8/dns-query"
]
},
"outbounds":[
{
"protocol":"freedom"
},
{
"tag":"WARP",
"protocol":"wireguard",
"settings":{
"secretKey":"YFYOAdbw1bKTHlNNi+aEjBM3BO7unuFC5rOkMRAz9XY=",
"address":[
"172.16.0.2/32",
"2606:4700:110:8a36:df92:102a:9602:fa18/128"
],
"peers":[
{
"publicKey":"bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=",
"allowedIPs":[
"0.0.0.0/0",
"::/0"
],
"endpoint":"162.159.193.10:2408"
}
],
"reserved":[78, 135, 76],
"mtu":1280
}
}
],
"routing":{
"domainStrategy":"AsIs",
"rules":[
{
"type":"field",
"domain":[
"domain:openai.com",
"domain:ai.com"
],
"outboundTag":"WARP"
}
]
}
}
EOF
}
generate_argo() {
cat > argo.sh << ABC
#!/usr/bin/env bash
ARGO_AUTH=${ARGO_AUTH}
ARGO_DOMAIN=${ARGO_DOMAIN}
SSH_DOMAIN=${SSH_DOMAIN}
FTP_DOMAIN=${FTP_DOMAIN}
# 下载并运行 Argo
check_file() {
[ ! -e cloudflared ] && wget -O cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 && chmod +x cloudflared
}
run() {
if [[ -n "\${ARGO_AUTH}" && -n "\${ARGO_DOMAIN}" ]]; then
if [[ "\$ARGO_AUTH" =~ TunnelSecret ]]; then
echo "\$ARGO_AUTH" | sed 's@{@{"@g;s@[,:]@"\0"@g;s@}@"}@g' > tunnel.json
cat > tunnel.yml << EOF
tunnel: \$(sed "s@.*TunnelID:\(.*\)}@\1@g" <<< "\$ARGO_AUTH")
credentials-file: $(pwd)/tunnel.json
protocol: http2
ingress:
- hostname: \$ARGO_DOMAIN
service: http://localhost:8080
EOF
[ -n "\${SSH_DOMAIN}" ] && cat >> tunnel.yml << EOF
- hostname: \$SSH_DOMAIN
service: http://localhost:2222
EOF
[ -n "\${FTP_DOMAIN}" ] && cat >> tunnel.yml << EOF
- hostname: \$FTP_DOMAIN
service: http://localhost:3333
EOF
cat >> tunnel.yml << EOF
- service: http_status:404
EOF
nohup ./cloudflared tunnel --edge-ip-version auto --config tunnel.yml run 2>/dev/null 2>&1 &
elif [[ \$ARGO_AUTH =~ ^[A-Z0-9a-z=]{120,250}$ ]]; then
nohup ./cloudflared tunnel --edge-ip-version auto --protocol http2 run --token ${ARGO_AUTH} 2>/dev/null 2>&1 &
fi
else
nohup ./cloudflared tunnel --edge-ip-version auto --protocol http2 --no-autoupdate --url http://localhost:8080 2>/dev/null 2>&1 &
sleep 5
local LOCALHOST=\$(ss -nltp | grep '"cloudflared"' | awk '{print \$4}')
ARGO_DOMAIN=\$(wget -qO- http://\$LOCALHOST/quicktunnel | cut -d\" -f4)
fi
}
export_list() {
VMESS="{ \"v\": \"2\", \"ps\": \"Argo-Vmess\", \"add\": \"icook.hk\", \"port\": \"443\", \"id\": \"${UUID}\", \"aid\": \"0\", \"scy\": \"none\", \"net\": \"ws\", \"type\": \"none\", \"host\": \"\${ARGO_DOMAIN}\", \"path\": \"/${WSPATH}-vmess?ed=2048\", \"tls\": \"tls\", \"sni\": \"\${ARGO_DOMAIN}\", \"alpn\": \"\" }"
cat > list << EOF
*******************************************
V2-rayN:
----------------------------
vless://${UUID}@icook.hk:443?encryption=none&security=tls&sni=\${ARGO_DOMAIN}&type=ws&host=\${ARGO_DOMAIN}&path=%2F${WSPATH}-vless?ed=2048#Argo-Vless
----------------------------
vmess://\$(echo \$VMESS | base64 -w0)
----------------------------
trojan://${UUID}@icook.hk:443?security=tls&sni=\${ARGO_DOMAIN}&type=ws&host=\${ARGO_DOMAIN}&path=%2F${WSPATH}-trojan?ed=2048#Argo-Trojan
----------------------------
ss://$(echo "chacha20-ietf-poly1305:${UUID}@icook.hk:443" | base64 -w0)@icook.hk:443#Argo-Shadowsocks
由于该软件导出的链接不全,请自行处理如下: 传输协议: WS , 伪装域名: \${ARGO_DOMAIN} ,路径: /${WSPATH}-shadowsocks?ed=2048 , 传输层安全: tls , sni: \${ARGO_DOMAIN}
*******************************************
小火箭:
----------------------------
vless://${UUID}@icook.hk:443?encryption=none&security=tls&type=ws&host=\${ARGO_DOMAIN}&path=/${WSPATH}-vless?ed=2048&sni=\${ARGO_DOMAIN}#Argo-Vless
----------------------------
vmess://$(echo "none:${UUID}@icook.hk:443" | base64 -w0)?remarks=Argo-Vmess&obfsParam=\${ARGO_DOMAIN}&path=/${WSPATH}-vmess?ed=2048&obfs=websocket&tls=1&peer=\${ARGO_DOMAIN}&alterId=0
----------------------------
trojan://${UUID}@icook.hk:443?peer=\${ARGO_DOMAIN}&plugin=obfs-local;obfs=websocket;obfs-host=\${ARGO_DOMAIN};obfs-uri=/${WSPATH}-trojan?ed=2048#Argo-Trojan
----------------------------
ss://$(echo "chacha20-ietf-poly1305:${UUID}@icook.hk:443" | base64 -w0)?obfs=wss&obfsParam=\${ARGO_DOMAIN}&path=/${WSPATH}-shadowsocks?ed=2048#Argo-Shadowsocks
*******************************************
Clash:
----------------------------
- {name: Argo-Vless, type: vless, server: icook.hk, port: 443, uuid: ${UUID}, tls: true, servername: \${ARGO_DOMAIN}, skip-cert-verify: false, network: ws, ws-opts: {path: /${WSPATH}-vless?ed=2048, headers: { Host: \${ARGO_DOMAIN}}}, udp: true}
----------------------------
- {name: Argo-Vmess, type: vmess, server: icook.hk, port: 443, uuid: ${UUID}, alterId: 0, cipher: none, tls: true, skip-cert-verify: true, network: ws, ws-opts: {path: /${WSPATH}-vmess?ed=2048, headers: {Host: \${ARGO_DOMAIN}}}, udp: true}
----------------------------
- {name: Argo-Trojan, type: trojan, server: icook.hk, port: 443, password: ${UUID}, udp: true, tls: true, sni: \${ARGO_DOMAIN}, skip-cert-verify: false, network: ws, ws-opts: { path: /${WSPATH}-trojan?ed=2048, headers: { Host: \${ARGO_DOMAIN} } } }
----------------------------
- {name: Argo-Shadowsocks, type: ss, server: icook.hk, port: 443, cipher: chacha20-ietf-poly1305, password: ${UUID}, plugin: v2ray-plugin, plugin-opts: { mode: websocket, host: \${ARGO_DOMAIN}, path: /${WSPATH}-shadowsocks?ed=2048, tls: true, skip-cert-verify: false, mux: false } }
*******************************************
EOF
cat list
}
check_file
run
export_list
ABC
}
generate_nezha() {
cat > nezha.sh << EOF
#!/usr/bin/env bash
# 哪吒的4个参数
NEZHA_SERVER="$NEZHA_SERVER"
NEZHA_PORT="$NEZHA_PORT"
NEZHA_KEY="$NEZHA_KEY"
NEZHA_TLS="$NEZHA_TLS"
# 检测是否已运行
check_run() {
[[ \$(pgrep -laf nezha-agent) ]] && echo "哪吒客户端正在运行中!" && exit
}
# 三个变量不全则不安装哪吒客户端
check_variable() {
[[ -z "\${NEZHA_SERVER}" || -z "\${NEZHA_PORT}" || -z "\${NEZHA_KEY}" ]] && exit
}
# 下载最新版本 Nezha Agent
download_agent() {
if [ ! -e nezha-agent ]; then
URL=\$(wget -qO- -4 "https://api.github.com/repos/naiba/nezha/releases/latest" | grep -o "https.*linux_amd64.zip")
wget -t 2 -T 10 -N \${URL}
unzip -qod ./ nezha-agent_linux_amd64.zip && rm -f nezha-agent_linux_amd64.zip
fi
}
# 运行客户端
run() {
TLS=\${NEZHA_TLS:+'--tls'}
[[ ! \$PROCESS =~ nezha-agent && -e nezha-agent ]] && ./nezha-agent -s \${NEZHA_SERVER}:\${NEZHA_PORT} -p \${NEZHA_KEY} \${TLS} 2>&1 &
}
check_run
check_variable
download_agent
run
EOF
}
generate_ttyd() {
cat > ttyd.sh << EOF
#!/usr/bin/env bash
# ttyd 三个参数
WEB_USERNAME=${WEB_USERNAME}
WEB_PASSWORD=${WEB_PASSWORD}
SSH_DOMAIN=${SSH_DOMAIN}
# 检测是否已运行
check_run() {
[[ \$(pgrep -lafx ttyd) ]] && echo "ttyd 正在运行中" && exit
}
# ssh argo 域名不设置,则不安装 ttyd 服务端
check_variable() {
[ -z "\${SSH_DOMAIN}" ] && exit
}
# 下载最新版本 ttyd
download_ttyd() {
if [ ! -e ttyd ]; then
URL=\$(wget -qO- "https://api.github.com/repos/tsl0922/ttyd/releases/latest" | grep -o "https.*x86_64")
URL=\${URL:-https://github.com/tsl0922/ttyd/releases/download/1.7.3/ttyd.x86_64}
wget -O ttyd \${URL}
chmod +x ttyd
fi
}
# 运行 ttyd 服务端
run() {
[ -e ttyd ] && nohup ./ttyd -c \${WEB_USERNAME}:\${WEB_PASSWORD} -p 2222 bash >/dev/null 2>&1 &
}
check_run
check_variable
download_ttyd
run
EOF
}
generate_filebrowser () {
cat > filebrowser.sh << EOF
#!/usr/bin/env bash
# filebrowser 三个参数
WEB_USERNAME=${WEB_USERNAME}
WEB_PASSWORD=${WEB_PASSWORD}
FTP_DOMAIN=${FTP_DOMAIN}
# 检测是否已运行
check_run() {
[[ \$(pgrep -lafx filebrowser) ]] && echo "filebrowser 正在运行中" && exit
}
# 若 ftp argo 域名不设置,则不安装 filebrowser
check_variable() {
[ -z "\${FTP_DOMAIN}" ] && exit
}
# 下载最新版本 filebrowser
download_filebrowser() {
if [ ! -e filebrowser ]; then
URL=\$(wget -qO- "https://api.github.com/repos/filebrowser/filebrowser/releases/latest" | grep -o "https.*linux-amd64.*gz")
URL=\${URL:-https://github.com/filebrowser/filebrowser/releases/download/v2.23.0/linux-amd64-filebrowser.tar.gz}
wget -O filebrowser.tar.gz \${URL}
tar xzvf filebrowser.tar.gz filebrowser
rm -f filebrowser.tar.gz
chmod +x filebrowser
fi
}
# 运行 filebrowser 服务端
run() {
PASSWORD_HASH=\$(./filebrowser hash \$WEB_PASSWORD)
[ -e filebrowser ] && nohup ./filebrowser --port 3333 --username \${WEB_USERNAME} --password "\${PASSWORD_HASH}" >/dev/null 2>&1 &
}
check_run
check_variable
download_filebrowser
run
EOF
}
generate_config
generate_argo
generate_nezha
generate_ttyd
generate_filebrowser
[ -e nezha.sh ] && bash nezha.sh
[ -e argo.sh ] && bash argo.sh
[ -e ttyd.sh ] && bash ttyd.sh
[ -e filebrowser.sh ] && bash filebrowser.sh