-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathXrayr_Pro.sh
278 lines (248 loc) · 9.92 KB
/
Xrayr_Pro.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
#!/bin/bash
# Kiểm tra sự tồn tại của file xrayrpro.sh
if [ -e "xrayrpro.sh" ]; then
echo "Đã tìm thấy xrayrpro.sh. Đang xóa..."
rm xrayrpro.sh
echo "Đã xóa xrayrpro.sh"
else
echo "Không tìm thấy xrayrpro.sh"
fi
# Kiểm tra sự tồn tại của file xrayr.sh
if [ -e "xrayr.sh" ]; then
echo "Đã tìm thấy xrayr.sh. Đang xóa..."
rm xrayr.sh
echo "Đã xóa xrayr.sh"
else
echo "Không tìm thấy xrayr.sh"
fi
clear
echo ""
echo " 1. Cài đặt"
echo " 2. update config"
echo " 3. thêm node"
read -p " Lựa chọn của bạn là (mặc định Cài đặt): " num
[ -z "${num}" ] && num="1"
pre_install(){
clear
read -p " Nhập số Node cần cài (mặc định 1): " n
[ -z "${n}" ] && n="1"
a=0
while [ $a -lt $n ]
do
read -p " Nhập domain web (không cần https://): " api_host
[ -z "${api_host}" ] && api_host=0
echo "--------------------------------"
echo " Web của bạn là https://${api_host}"
echo "--------------------------------"
#key web
read -p " Nhập key của web: " api_key
[ -z "${api_key}" ] && api_key=0
echo "--------------------------------"
echo " Key của Web là ${api_key}"
echo "--------------------------------"
echo -e " [1] V2ray"
echo -e " [2] Trojan"
read -p " Nhập loại Node: " NodeType
if [ "$NodeType" == "1" ]; then
NodeType="V2ray"
elif [ "$NodeType" == "2" ]; then
NodeType="Trojan"
else
NodeType="V2ray"
fi
echo "-------------------------------"
echo -e " Loại Node là ${NodeType}"
echo "-------------------------------"
#node id
read -p " Nhập ID Node: " node_id
[ -z "${node_id}" ] && node_id=0
echo "-------------------------------"
echo -e " ID Node là ${node_id}"
echo "-------------------------------"
#giới hạn thiết bị
read -p " Nhập giới hạn thiết bị: " DeviceLimit
[ -z "${DeviceLimit}" ] && DeviceLimit="0"
echo "-------------------------------"
echo " Thiết bị tối đa là ${DeviceLimit}"
echo "-------------------------------"
#IP vps
read -p " Nhập địa chỉ Node: " CertDomain
[ -z "${CertDomain}" ] && CertDomain="0"
echo "-------------------------------"
echo " Địa chỉ Node là ${CertDomain}"
echo "-------------------------------"
config
a=$((a+1))
done
}
#clone node
clone_node(){
clear
read -p " Nhập số Node cần cài thêm (mặc định 1): " n
[ -z "${n}" ] && n="1"
a=0
while [ $a -lt $n ]
do
#link web
read -p " Nhập domain web (không cần https://): " api_host
[ -z "${api_host}" ] && api_host=0
echo "--------------------------------"
echo " Web của bạn là https://${api_host}"
echo "--------------------------------"
#key web
read -p " Nhập key của web: " api_key
[ -z "${api_key}" ] && api_key=0
echo "--------------------------------"
echo " Key của web là ${api_key}"
echo "--------------------------------"
echo -e " [1] V2ray"
echo -e " [2] Trojan"
read -p " Nhập loại Node: " NodeType
if [ "$NodeType" == "1" ]; then
NodeType="V2ray"
elif [ "$NodeType" == "2" ]; then
NodeType="Trojan"
else
NodeType="V2ray"
fi
echo "-------------------------------"
echo -e " Loại Node là ${NodeType}"
echo "-------------------------------"
#node id
read -p " Nhập ID Node: " node_id
[ -z "${node_id}" ] && node_id=0
echo "-------------------------------"
echo -e " ID Node là ${node_id}"
echo "-------------------------------"
#giới hạn thiết bị
read -p " Nhập giới hạn thiết bị: " DeviceLimit
[ -z "${DeviceLimit}" ] && DeviceLimit="0"
echo "-------------------------------"
echo " Thiết bị tối đa là ${DeviceLimit}"
echo "-------------------------------"
#IP vps
read -p " Nhập địa chỉ Node: " CertDomain
[ -z "${CertDomain}" ] && CertDomain="0"
echo "-------------------------------"
echo " Địa chỉ Node là ${CertDomain}"
echo "-------------------------------"
config
a=$((a+1))
done
}
config(){
cd /etc/XrayR
cat >>config.yml<<EOF
-
PanelType: "V2board" # Panel type: SSpanel, V2board, PMpanel, Proxypanel, V2RaySocks
ApiConfig:
ApiHost: "https://$api_host"
ApiKey: "$api_key"
NodeID: $node_id
NodeType: $NodeType # Node type: V2ray, Shadowsocks, Trojan, Shadowsocks-Plugin
Timeout: 30 # Timeout for the api request
EnableVless: false # Enable Vless for V2ray Type
EnableXTLS: false # Enable XTLS for V2ray and Trojan
SpeedLimit: 0 # Mbps, Local settings will replace remote settings, 0 means disable
DeviceLimit: $DeviceLimit # Local settings will replace remote settings, 0 means disable
RuleListPath: # /etc/XrayR/rulelist Path to local rulelist file
ControllerConfig:
ListenIP: 0.0.0.0 # IP address you want to listen
SendIP: 0.0.0.0 # IP address you want to send pacakage
UpdatePeriodic: 60 # Time to update the nodeinfo, how many sec.
EnableDNS: false # Use custom DNS config, Please ensure that you set the dns.json well
DNSType: AsIs # AsIs, UseIP, UseIPv4, UseIPv6, DNS strategy
DisableUploadTraffic: false # Disable Upload Traffic to the panel
DisableGetRule: false # Disable Get Rule from the panel
DisableIVCheck: false # Disable the anti-reply protection for Shadowsocks
DisableSniffing: True # Disable domain sniffing
EnableProxyProtocol: false # Only works for WebSocket and TCP
AutoSpeedLimitConfig:
Limit: 0 # Warned speed. Set to 0 to disable AutoSpeedLimit (mbps)
WarnTimes: 0 # After (WarnTimes) consecutive warnings, the user will be limited. Set to 0 to punish overspeed user immediately.
LimitSpeed: 0 # The speedlimit of a limited user (unit: mbps)
LimitDuration: 0 # How many minutes will the limiting last (unit: minute)
GlobalDeviceLimitConfig:
Limit: 0 # The global device limit of a user, 0 means disable
RedisAddr: 127.0.0.1:6379 # The redis server address
RedisPassword: YOUR PASSWORD # Redis password
RedisDB: 0 # Redis DB
Timeout: 5 # Timeout for redis request
Expiry: 60 # Expiry time (second)
EnableFallback: false # Only support for Trojan and Vless
FallBackConfigs: # Support multiple fallbacks
-
SNI: # TLS SNI(Server Name Indication), Empty for any
Alpn: # Alpn, Empty for any
Path: # HTTP PATH, Empty for any
Dest: 80 # Required, Destination of fallback, check https://xtls.github.io/config/features/fallback.html for details.
ProxyProtocolVer: 0 # Send PROXY protocol version, 0 for dsable
CertConfig:
CertMode: file # Option about how to get certificate: none, file, http, dns. Choose "none" will forcedly disable the tls config.
CertDomain: "$CertDomain" # Domain to cert
CertFile: /etc/XrayR/443.crt # Provided if the CertMode is file
KeyFile: /etc/XrayR/443.key
Provider: alidns # DNS cert provider, Get the full support list here: https://go-acme.github.io/lego/dns/
Email: [email protected]
DNSEnv: # DNS ENV option used by DNS provider
ALICLOUD_ACCESS_KEY: aaa
ALICLOUD_SECRET_KEY: bbb
EOF
# sed -i "s|ApiHost: \"https://domain.com\"|ApiHost: \"${api_host}\"|" ./config.yml
# sed -i "s|ApiKey:.*|ApiKey: \"${ApiKey}\"|"
# sed -i "s|NodeID: 41|NodeID: ${node_id}|" ./config.yml
# sed -i "s|DeviceLimit: 0|DeviceLimit: ${DeviceLimit}|" ./config.yml
# sed -i "s|SpeedLimit: 0|SpeedLimit: ${SpeedLimit}|" ./config.yml
# sed -i "s|CertDomain:\"node1.test.com\"|CertDomain: \"${CertDomain}\"|" ./config.yml
}
case "${num}" in
1) wget --no-check-certificate https://raw.githubusercontent.com/XrayR-project/XrayR-release/master/install.sh && bash install.sh -v 0.8.8
openssl req -newkey rsa:2048 -x509 -sha256 -days 365 -nodes -out /etc/XrayR/443.crt -keyout /etc/XrayR/443.key -subj "/C=JP/ST=Tokyo/L=Chiyoda-ku/O=Google Trust Services LLC/CN=google.com"
cd /etc/XrayR
cat >config.yml <<EOF
Log:
Level: none # Log level: none, error, warning, info, debug
AccessPath: # /etc/XrayR/access.Log
ErrorPath: # /etc/XrayR/error.log
DnsConfigPath: # /etc/XrayR/dns.json # Path to dns config, check https://xtls.github.io/config/dns.html for help
RouteConfigPath: # /etc/XrayR/route.json # Path to route config, check https://xtls.github.io/config/routing.html for help
OutboundConfigPath: # /etc/XrayR/custom_outbound.json # Path to custom outbound config, check https://xtls.github.io/config/outbound.html for help
ConnectionConfig:
Handshake: 4 # Handshake time limit, Second
ConnIdle: 30 # Connection idle time limit, Second
UplinkOnly: 2 # Time limit when the connection downstream is closed, Second
DownlinkOnly: 4 # Time limit when the connection is closed after the uplink is closed, Second
BufferSize: 64 # The internal cache size of each connection, kB
Nodes:
EOF
pre_install
cd /root
xrayr start
;;
2) cd /etc/XrayR
cat >config.yml <<EOF
Log:
Level: none # Log level: none, error, warning, info, debug
AccessPath: # /etc/XrayR/access.Log
ErrorPath: # /etc/XrayR/error.log
DnsConfigPath: # /etc/XrayR/dns.json # Path to dns config, check https://xtls.github.io/config/dns.html for help
RouteConfigPath: # /etc/XrayR/route.json # Path to route config, check https://xtls.github.io/config/routing.html for help
OutboundConfigPath: # /etc/XrayR/custom_outbound.json # Path to custom outbound config, check https://xtls.github.io/config/outbound.html for help
ConnectionConfig:
Handshake: 4 # Handshake time limit, Second
ConnIdle: 30 # Connection idle time limit, Second
UplinkOnly: 2 # Time limit when the connection downstream is closed, Second
DownlinkOnly: 4 # Time limit when the connection is closed after the uplink is closed, Second
BufferSize: 64 # The internal cache size of each connection, kB
Nodes:
EOF
pre_install
cd /root
xrayr restart
;;
3) cd /etc/XrayR
clone_node
cd /root
xrayr restart
;;
esac