-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNEKORAY-CLI.sh
255 lines (236 loc) · 6.74 KB
/
NEKORAY-CLI.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
#!/bin/bash
NEKOCLI_VER=1.5
clear
echo "EXTREME DOT - NEKORAY CLI V$NEKOCLI_VER"
echo "Enter [NEKORAY-CLI help] to see help and usage"
echo "127.0.0.1 2080"
echo
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit
fi
download() {
# DOWNLOADING NEKORAY FROM GIT-HUB
echo
echo "Removing Previous files"
echo
rm -rf /ExtremeDOT/nekoray
sleep 1
mkdir -p /ExtremeDOT/nekoray
cd /ExtremeDOT
wget https://github.com/MatsuriDayo/nekoray/releases/download/2.22/nekoray-2.22-2023-04-08-linux64.zip
unzip nekoray-2.22-2023-04-08-linux64.zip
#rm /ExtremeDOT/*.zip
cd /ExtremeDOT/nekoray
# /ExtremeDOT/nekoray/nekobox_core version
# cp /usr/local/etc/v2ray/config.json /ExtremeDOT/nekoray/config.json
}
singbox_json() {
echo
echo "Writing /ExtremeDOT/nekoray/sing-box-vpn.json file"
echo
cat <<EOF > /ExtremeDOT/nekoray/sing-box-vpn.json
{
"dns": {
"servers": [
{
"tag": "dns-direct",
"address": "underlying://0.0.0.0",
"detour": "direct"
}
]
},
"inbounds": [
{
"type": "tun",
"interface_name": "nekoray-tun",
"inet4_address": "172.19.0.1/28",
"inet6_address": "fdfe:dcba:9876::1/126",
"mtu": 9000,
"auto_route": true,
"strict_route": false,
"stack": "gvisor",
"endpoint_independent_nat": true,
"sniff": false
}
],
"outbounds": [
{
"type": "socks",
"tag": "nekoray-socks",
"udp_fragment": true,
"server": "127.0.0.1",
"server_port": 2080
},
{
"type": "block",
"tag": "block"
},
{
"type": "direct",
"tag": "direct"
},
{
"type": "dns",
"tag": "dns-out"
}
],
"route": {
"auto_detect_interface": true,
"rules": [
{
"inbound": "dns-in",
"outbound": "dns-out"
},
{
"network": "udp",
"port": [
135,
137,
138,
139,
5353
],
"outbound": "block"
},
{
"ip_cidr": [
"224.0.0.0/3",
"ff00::/8"
],
"outbound": "block"
},
{
"source_ip_cidr": [
"224.0.0.0/3",
"ff00::/8"
],
"outbound": "block"
},
{
"port": 53,
"process_name": [
"nekoray_core",
"nekoray_core.exe"
],
"outbound": "dns-out"
},
{
"process_name": [
"nekoray_core",
"nekoray_core.exe",
"nekobox_core",
"nekobox_core.exe"
],
"outbound": "direct"
}
]
}
}
EOF
chmod +x /ExtremeDOT/nekoray/sing-box-vpn.json
}
installing_core() {
echo
echo "Downloading files"
download
singbox_json
touch /ExtremeDOT/nekoray/config.json
touch /ExtremeDOT/nekoray/run1.sh
touch /ExtremeDOT/nekoray/run2.sh
echo "Start 1"
echo "#!/bin/bash" > /ExtremeDOT/nekoray/run1.sh
echo "\"/ExtremeDOT/nekoray/nekoray_core\" run -config \"/ExtremeDOT/nekoray/config.json\" " >> /ExtremeDOT/nekoray/run1.sh
chmod +x /ExtremeDOT/nekoray/run1.sh
echo "Start 2"
echo "#!/bin/bash" > /ExtremeDOT/nekoray/run2.sh
echo "\"/ExtremeDOT/nekoray/nekobox_core\" run -c \"/ExtremeDOT/nekoray/sing-box-vpn.json\" --protect-fwmark 514 " >> /ExtremeDOT/nekoray/run2.sh
chmod +x /ExtremeDOT/nekoray/run2.sh
}
pre_start_linux() {
# set bypass: fwmark
ip rule add pref 8999 fwmark 514 table main || return
ip -6 rule add pref 8999 fwmark 514 table main || return
# for Tun2Socket
iptables -I INPUT -s 172.19.0.2 -d 172.19.0.1 -p tcp -j ACCEPT
ip6tables -I INPUT -s fdfe:dcba:9876::2 -d fdfe:dcba:9876::1 -p tcp -j ACCEPT
}
start1() {
echo " RUNNING Start 1"
/ExtremeDOT/nekoray/run1.sh </dev/null &>/dev/null &
}
start2() {
echo " RUNNING Start 2"
/ExtremeDOT/nekoray/run2.sh </dev/null &>/dev/null &
}
if [ "$1" = "start" ]; then
echo
echo "Running Nekoray Client"
pre_start_linux
sleep 2
start1
sleep 3
start2
echo
echo "to test running connection please run command below"
echo "NEKORAY-CLI test"
else if [ "$1" = "edit" ]; then
echo
echo "Editing Config.json files"
nano /ExtremeDOT/nekoray/config.json
echo
echo "to start Nekoray config please using command below"
echo "NEKORAY-CLI start"
else if [ "$1" = "install" ]; then
echo
echo "Installing Core.. Nekoray"
installing_core
echo
echo "Please Update Config file using command"
echo "NEKORAY-CLI edit"
echo
else if [ "$1" = "stop" ]; then
echo
echo "Stopping Core.. Nekoray"
iptables -D INPUT -s 172.19.0.2 -d 172.19.0.1 -p tcp -j ACCEPT
ip6tables -D INPUT -s fdfe:dcba:9876::2 -d fdfe:dcba:9876::1 -p tcp -j ACCEPT
ip rule del fwmark 514
ip -6 rule del fwmark 514
killall -9 nekobox_core
killall -9 nekoray_core
else if [ "$1" = "test" ]; then
echo "TESTING IP Address"
echo
echo "------------------"
echo "nekoray-tun 127.0.0.1:2080"
echo
echo "Testing Localhost:2080 port"
curl --socks5 socks5://localhost:2080 https://myip.wtf/json -m 20
echo
echo "------------------"
echo "Testing nekoray-tun interface"
curl --interface nekoray-tun myip.wtf/json -m 20
else if [ "$1" = "help" ]; then
echo "Extreme Dot - NEKORAY CLI V$NEKOCLI_VER"
echo
echo "NEKORAY-CLI install"
echo "NEKORAY-CLI start"
echo "NEKORAY-CLI stop"
echo "NEKORAY-CLI test"
echo "NEKORAY-CLI edit"
echo "NEKORAY-CLI update"
echo "NEKORAY-CLI help"
echo
echo
else if [ "$1" = "update" ]; then
echo
echo "Updating the script.."
cd /tmp && curl -O https://raw.githubusercontent.com/ExtremeDot/vpn_setups/master/NEKORAY-CLI.sh
sleep 2
mv /tmp/NEKORAY-CLI.sh /bin/NEKORAY-CLI && chmod +x /bin/NEKORAY-CLI ; /bin/NEKORAY-CLI ; exit
else
echo
echo "Enter [NEKORAY-CLI help] to see help and usage"
echo
echo
fi; fi; fi; fi; fi; fi; fi