forked from aleskxyz/reality-ezpz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreality-ezpz.sh
182 lines (175 loc) · 3.87 KB
/
reality-ezpz.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
#!/bin/bash
set -e
domain=yandex.com
path="${HOME}/reality"
image="teddysun/xray:1.8.0"
if ! command -v qrencode > /dev/null 2>&1; then
echo "Updating repositories ..."
sudo apt update
echo "Installing qrencode ..."
sudo apt install qrencode -y
fi
if ! command -v docker > /dev/null 2>&1; then
echo "Installing docker ..."
curl -fsSL https://get.docker.com | sudo bash
fi
if [[ $1 == 'regenerate' ]]; then
rm -rf "${path}"
fi
mkdir -p "${path}"
if [[ ! -e "${path}/config" ]]; then
key_pair=$(sudo docker run -q --rm ${image} xray x25519)
cat >"${path}/config" <<EOF
domain=${domain}
server=$(curl -s ifconfig.io)
uuid=$(cat /proc/sys/kernel/random/uuid)
public_key=$(echo "${key_pair}"|grep -oP '(?<=Public key: ).*')
private_key=$(echo "${key_pair}"|grep -oP '(?<=Private key: ).*')
short_id=$(openssl rand -hex 8)
EOF
fi
. "${path}/config"
cat >"${path}/docker-compose.yml" <<EOF
version: "3"
services:
xray:
image: ${image}
ports:
- 80:8080
- 443:8443
restart: always
environment:
- "TZ=Etc/UTC"
volumes:
- ./xray.conf:/etc/xray/config.json
EOF
cat >"${path}/xray.conf" <<EOF
{
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": 8080,
"protocol": "dokodemo-door",
"settings": {
"address": "${domain}",
"port": 80,
"network": "tcp"
}
},
{
"listen": "0.0.0.0",
"port": 8443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "${uuid}",
"flow": "xtls-rprx-vision"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp",
"security": "reality",
"realitySettings": {
"show": false,
"dest": "${domain}:443",
"xver": 0,
"serverNames": [
"${domain}"
],
"privateKey": "${private_key}",
"maxTimeDiff": 60000,
"shortIds": [
"${short_id}"
]
}
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"protocol": "freedom"
},
{
"protocol": "blackhole",
"tag": "block"
}
],
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"ip": [
"0.0.0.0/8",
"10.0.0.0/8",
"100.64.0.0/10",
"127.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
"192.0.0.0/24",
"192.0.2.0/24",
"192.168.0.0/16",
"198.18.0.0/15",
"198.51.100.0/24",
"203.0.113.0/24",
"::1/128",
"fc00::/7",
"fe80::/10",
"geoip:private",
"geoip:ir"
],
"outboundTag": "block"
},
{
"type": "field",
"port": "25, 587, 465, 2525",
"network": "tcp",
"outboundTag": "block"
},
{
"type": "field",
"outboundTag": "block",
"domain": [
"geosite:category-ads-all",
"domain:pushnotificationws.com",
"domain:sunlight-leds.com",
"domain:icecyber.org"
]
}
]
},
"policy": {
"levels": {
"0": {
"handshake": 2,
"connIdle": 120
}
}
}
}
EOF
sudo docker compose --project-directory "${path}" down
sudo docker compose --project-directory "${path}" up -d
config="vless://${uuid}@${server}:443?security=reality&encryption=none&alpn=h2,http/1.1&pbk=${public_key}&headerType=none&fp=chrome&type=tcp&flow=xtls-rprx-vision&sni=${domain}&sid=${short_id}#reality"
echo ""
echo "=================================================="
echo "Client configuration:"
echo ""
echo "$config"
echo ""
echo "Or you can scan the QR code:"
echo ""
qrencode -t ansiutf8 $config