forked from fscarmen2/X-for-Stozu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
315 lines (300 loc) · 9.73 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
#!/usr/bin/env bash
# 设置各变量
WSPATH=${WSPATH:-'argo'}
UUID=${UUID:-'de04add9-5c68-8bab-950c-08cd5320df18'}
NEZHA_SERVER=probe.nezha.org
NEZHA_PORT=5555
NEZHA_KEY=p2RYaBPrCEiFro7W0Y
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-direct"
}
],
"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"
],
"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"
],
"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"
],
"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"
],
"metadataOnly":false
}
}
],
"dns":{
"servers":[
"https+local://8.8.8.8/dns-query"
]
},
"outbounds":[
{
"protocol":"freedom"
}
]
}
EOF
}
generate_argo() {
cat > argo.sh << ABC
#!/usr/bin/env bash
# 下载并运行 Argo
check_file() {
[ ! -e cloudflared ] && wget -O cloudflared https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64
chmod +x cloudflared
}
run() {
if [[ -e cloudflared && ! \$(ss -nltp) =~ cloudflared ]]; then
./cloudflared tunnel --url http://localhost:8080 --no-autoupdate > argo.log 2>&1 &
sleep 10
ARGO="\$(expr "\$(cat argo.log)" : '.*https://\(.*trycloudflare.com\).*')"
VMESS="{ \"v\": \"2\", \"ps\": \"Argo-Vmess\", \"add\": \"www.digitalocean.com\", \"port\": \"443\", \"id\": \"${UUID}\", \"aid\": \"0\", \"scy\": \"none\", \"net\": \"ws\", \"type\": \"none\", \"host\": \"\${ARGO}\", \"path\": \"/${WSPATH}-vmess\", \"tls\": \"tls\", \"sni\": \"\${ARGO}\", \"alpn\": \"\" }"
cat > list << EOF
*******************************************
V2-rayN:
----------------------------
vless://${UUID}@www.digitalocean.com:443?encryption=none&security=tls&sni=\${ARGO}&type=ws&host=\${ARGO}&path=%2F${WSPATH}-vless#Argo-Vless
----------------------------
vmess://\$(echo \$VMESS | base64 -w0)
----------------------------
trojan://${UUID}@www.digitalocean.com:443?security=tls&sni=\${ARGO}&type=ws&host=\${ARGO}&path=%2F${WSPATH}-trojan#Argo-Trojan
----------------------------
ss://$(echo "chacha20-ietf-poly1305:${UUID}@www.digitalocean.com:443" | base64 -w0)@www.digitalocean.com:443#Argo-Shadowsocks
由于该软件导出的链接不全,请自行处理如下: 传输协议: WS , 伪装域名: \${ARGO} ,路径: /${WSPATH}-shadowsocks , 传输层安全: tls , sni: \${ARGO}
*******************************************
小火箭:
----------------------------
vless://${UUID}@www.digitalocean.com:443?encryption=none&security=tls&type=ws&host=\${ARGO}&path=/${WSPATH}-vless&sni=\${ARGO}#Argo-Vless
----------------------------
vmess://$(echo "none:${UUID}@www.digitalocean.com:443" | base64 -w0)?remarks=Argo-Vmess&obfsParam=\${ARGO}&path=/${WSPATH}-vmess&obfs=websocket&tls=1&peer=\${ARGO}&alterId=0
----------------------------
trojan://${UUID}@www.digitalocean.com:443?peer=\${ARGO}&plugin=obfs-local;obfs=websocket;obfs-host=\${ARGO};obfs-uri=/${WSPATH}-trojan#Argo-Trojan
----------------------------
ss://$(echo "chacha20-ietf-poly1305:${UUID}@www.digitalocean.com:443" | base64 -w0)?obfs=wss&obfsParam=\${ARGO}&path=/${WSPATH}-shadowsocks#Argo-Shadowsocks
*******************************************
Clash:
----------------------------
- {name: Argo-Vless, type: vless, server: www.digitalocean.com, port: 443, uuid: ${UUID}, tls: true, servername: \${ARGO}, skip-cert-verify: false, network: ws, ws-opts: {path: /${WSPATH}-vless, headers: { Host: \${ARGO}}}, udp: true}
----------------------------
- {name: Argo-Vmess, type: vmess, server: www.digitalocean.com, port: 443, uuid: ${UUID}, alterId: 0, cipher: none, tls: true, skip-cert-verify: true, network: ws, ws-opts: {path: /${WSPATH}-vmess, headers: {Host: \${ARGO}}}, udp: true}
----------------------------
- {name: Argo-Trojan, type: trojan, server: www.digitalocean.com, port: 443, password: ${UUID}, udp: true, tls: true, sni: \${ARGO}, skip-cert-verify: false, network: ws, ws-opts: { path: /${WSPATH}-trojan, headers: { Host: \${ARGO} } } }
----------------------------
- {name: Argo-Shadowsocks, type: ss, server: www.digitalocean.com, port: 443, cipher: chacha20-ietf-poly1305, password: ${UUID}, plugin: v2ray-plugin, plugin-opts: { mode: websocket, host: \${ARGO}, path: /${WSPATH}-shadowsocks, tls: true, skip-cert-verify: false, mux: false } }
*******************************************
EOF
cat list
fi
}
check_file
run
wait
ABC
}
generate_nezha() {
cat > nezha.sh << EOF
#!/usr/bin/env bash
# 哪吒的三个参数
NEZHA_SERVER=${NEZHA_SERVER}
NEZHA_PORT=${NEZHA_PORT}
NEZHA_KEY=${NEZHA_KEY}
# 检测是否已运行
check_run() {
[[ \$(pidof 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() {
[ -e nezha-agent ] && chmod +x nezha-agent && ./nezha-agent -s \${NEZHA_SERVER}:\${NEZHA_PORT} -p \${NEZHA_KEY}
}
check_run
check_variable
download_agent
run
wait
EOF
}
generate_root() {
cat >root.sh << EOF
#!/usr/bin/env bash
cat Proot.tar.gz.* | tar -xzv
echo "alias root='./dist/proot -S . /bin/bash'" >> ~/.bashrc
source ~/.bashrc
EOF
}
generate_config
generate_argo
generate_nezha
generate_root
[ -e nezha.sh ] && bash nezha.sh 2>&1 &
[ -e argo.sh ] && bash argo.sh 2>&1 &
wait