Compare commits
387 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
156a24fa5a | ||
|
|
1b83ca2a39 | ||
|
|
35e998e697 | ||
|
|
77293e2463 | ||
|
|
19fe2f183e | ||
|
|
79b31af092 | ||
|
|
dca1e9a233 | ||
|
|
4b39cae099 | ||
|
|
cb732fd3d7 | ||
|
|
fc80994cc5 | ||
|
|
7604c6bbff | ||
|
|
5f1bd6accb | ||
|
|
c1d57536bd | ||
|
|
77c5d37076 | ||
|
|
2a2e1b546c | ||
|
|
1512e7b175 | ||
|
|
c7ad9ef52c | ||
|
|
7337d266aa | ||
|
|
652371aed2 | ||
|
|
52ec559100 | ||
|
|
fa9c890701 | ||
|
|
5bcd9b7bfc | ||
|
|
00ef3cb3a7 | ||
|
|
3832eec3a8 | ||
|
|
9b6fd10267 | ||
|
|
aa52bd83ce | ||
|
|
c7c249fe48 | ||
|
|
0d44abc82a | ||
|
|
713592068b | ||
|
|
c6623721d8 | ||
|
|
268e1d4823 | ||
|
|
c61d54a5a7 | ||
|
|
c0ee6d273f | ||
|
|
4323d8fb86 | ||
|
|
d067bb7ff0 | ||
|
|
608337ffb2 | ||
|
|
2c1dfada01 | ||
|
|
2789242931 | ||
|
|
d7dd915472 | ||
|
|
97cb5479b1 | ||
|
|
e6bc100326 | ||
|
|
c9d0bf2788 | ||
|
|
df29e3714a | ||
|
|
aa14a9ee01 | ||
|
|
2fd2259737 | ||
|
|
17ab8175e1 | ||
|
|
3c315f61a1 | ||
|
|
4e1a9d33bc | ||
|
|
8906077709 | ||
|
|
f0da10af6e | ||
|
|
e7a2fe648e | ||
|
|
9018f112a0 | ||
|
|
3b6e41221b | ||
|
|
d4ae7ae4b7 | ||
|
|
95dfaa0eec | ||
|
|
262edbf03b | ||
|
|
75740f5fa1 | ||
|
|
a2f7552e25 | ||
|
|
bc5d16f09c | ||
|
|
12aea19499 | ||
|
|
d1fb7370e6 | ||
|
|
9d067a673f | ||
|
|
0e9ef74727 | ||
|
|
1bc6b7726b | ||
|
|
fcfbc29219 | ||
|
|
734c8d3f4a | ||
|
|
64c50d3305 | ||
|
|
674c7872f3 | ||
|
|
ad251d858c | ||
|
|
d292c91032 | ||
|
|
3e7d70c7c3 | ||
|
|
adac4c669a | ||
|
|
be0392f240 | ||
|
|
8dbf58dc74 | ||
|
|
80c2a551d0 | ||
|
|
f780cc2c48 | ||
|
|
ca4873fbe8 | ||
|
|
15105dd07e | ||
|
|
7a40224fc3 | ||
|
|
9bf8569f23 | ||
|
|
ffeb43d127 | ||
|
|
6945287e11 | ||
|
|
8076b752f7 | ||
|
|
b75eddd710 | ||
|
|
282d0aa161 | ||
|
|
7a13de8439 | ||
|
|
e4ce1e48f8 | ||
|
|
5153ca84e1 | ||
|
|
7acac3c6e9 | ||
|
|
f6eb1577af | ||
|
|
30b98f7f64 | ||
|
|
925c4644bb | ||
|
|
4d7bd92381 | ||
|
|
6129b69588 | ||
|
|
47c938568e | ||
|
|
2328ed9616 | ||
|
|
0b6e84d767 | ||
|
|
b4fdcf8a27 | ||
|
|
36fcc884d6 | ||
|
|
1d1098b166 | ||
|
|
03dd3654b7 | ||
|
|
e668551fd0 | ||
|
|
285651915f | ||
|
|
be3eda32bc | ||
|
|
c57fd34063 | ||
|
|
a194980be6 | ||
|
|
8a71c3930c | ||
|
|
bfd188950b | ||
|
|
977efa7c00 | ||
|
|
c15bea9ae1 | ||
|
|
9e1fe84fec | ||
|
|
1c3430ed88 | ||
|
|
fe49bf4e52 | ||
|
|
82ba1447e1 | ||
|
|
5dc3b53e6e | ||
|
|
e5c4e65812 | ||
|
|
4285663e55 | ||
|
|
54b66f0925 | ||
|
|
cfd1b98bd2 | ||
|
|
862e5f54fc | ||
|
|
db43540735 | ||
|
|
e048261914 | ||
|
|
bfb57cd094 | ||
|
|
3cab521370 | ||
|
|
e76a62c76f | ||
|
|
75d121d01a | ||
|
|
6f978ac58f | ||
|
|
9772fdee87 | ||
|
|
2e3fefe854 | ||
|
|
d26fbe5046 | ||
|
|
e11e883ffd | ||
|
|
a8b485bd7d | ||
|
|
5f5d384d53 | ||
|
|
38efeb7aef | ||
|
|
fea5673384 | ||
|
|
7b3e38e4c6 | ||
|
|
cee0a10548 | ||
|
|
cf7ff363e0 | ||
|
|
eebffa662f | ||
|
|
41080fb146 | ||
|
|
c1379cde16 | ||
|
|
2ec1fd6e74 | ||
|
|
c5089f0277 | ||
|
|
872a84abc1 | ||
|
|
66cc65f239 | ||
|
|
2fa0840c6e | ||
|
|
5924a3ecf7 | ||
|
|
91ada9f49f | ||
|
|
67e8626e8a | ||
|
|
9f9d3c3dcb | ||
|
|
82cadd1aaf | ||
|
|
c12d59231d | ||
|
|
3ef6effe78 | ||
|
|
f72df657db | ||
|
|
89bca53889 | ||
|
|
656682be14 | ||
|
|
bdc84608d2 | ||
|
|
533f856b0b | ||
|
|
c87208983b | ||
|
|
5adb662ece | ||
|
|
0f4fbd8d68 | ||
|
|
15deb9a608 | ||
|
|
62c3566ac9 | ||
|
|
09432eee01 | ||
|
|
bb28742b86 | ||
|
|
f316957a64 | ||
|
|
2a2ee0b90d | ||
|
|
a5cbde33e1 | ||
|
|
893b6f1dae | ||
|
|
de571b58e3 | ||
|
|
7e528f5b2b | ||
|
|
c28eb1cbbc | ||
|
|
3a85ac1499 | ||
|
|
558a2ee6d8 | ||
|
|
aaa1228319 | ||
|
|
5cdf5a520e | ||
|
|
ff7f6e7dc0 | ||
|
|
ed30acdd7a | ||
|
|
1d38865e03 | ||
|
|
5cb5bfe5e0 | ||
|
|
286f043849 | ||
|
|
44940d3496 | ||
|
|
4bceb9af59 | ||
|
|
9c0440caaf | ||
|
|
8fbb88b707 | ||
|
|
6957d57f1f | ||
|
|
d0ecb222ab | ||
|
|
771082da78 | ||
|
|
4a371398cf | ||
|
|
b63a6c52a4 | ||
|
|
2fcbeb7655 | ||
|
|
7bb60f7aab | ||
|
|
9624b5456c | ||
|
|
fcc211a6a7 | ||
|
|
9687748b85 | ||
|
|
6949df4e3d | ||
|
|
7ee2085ce4 | ||
|
|
e62797205c | ||
|
|
5b7a31f044 | ||
|
|
33ca5f3969 | ||
|
|
56f588be92 | ||
|
|
3f8b3944bb | ||
|
|
797eb85e47 | ||
|
|
d39e52216b | ||
|
|
5d5ba2a2e1 | ||
|
|
1afe716ce3 | ||
|
|
e909bec1bb | ||
|
|
c43a927280 | ||
|
|
a0b31a4905 | ||
|
|
335c466520 | ||
|
|
d9bff51afc | ||
|
|
d4aba59988 | ||
|
|
f41440a118 | ||
|
|
af6922e2da | ||
|
|
81d97502e1 | ||
|
|
c98e69cce6 | ||
|
|
81159b6176 | ||
|
|
d6e532c639 | ||
|
|
78a3f1d68b | ||
|
|
0d65f13af9 | ||
|
|
1b39b2ebd4 | ||
|
|
0f6fc088d8 | ||
|
|
de920ddd8a | ||
|
|
7091319fcb | ||
|
|
4743965c58 | ||
|
|
c642ca4b8c | ||
|
|
f72bc273c7 | ||
|
|
a4b84dc55b | ||
|
|
9e7799981b | ||
|
|
e51069fc79 | ||
|
|
0106db9a92 | ||
|
|
eb094bd40e | ||
|
|
d7d9c6efa7 | ||
|
|
31160a6ef2 | ||
|
|
cbf1a47979 | ||
|
|
82c352973f | ||
|
|
d69dce0fb4 | ||
|
|
e60b0ad59b | ||
|
|
60bb6da692 | ||
|
|
6d79038393 | ||
|
|
4079d1525f | ||
|
|
0219fcd94e | ||
|
|
30b3a34d8e | ||
|
|
8dc3c3fdc2 | ||
|
|
68e7519fdf | ||
|
|
fd267e6316 | ||
|
|
c1ac05fd36 | ||
|
|
fc5dc18348 | ||
|
|
94c0ed99ef | ||
|
|
5598809f57 | ||
|
|
9ea1fb7df6 | ||
|
|
f607cfbc70 | ||
|
|
8484ffae3b | ||
|
|
87ae8b78be | ||
|
|
156d9193ee | ||
|
|
12f3babe47 | ||
|
|
1f00c32e5a | ||
|
|
cd8a885618 | ||
|
|
a33da9f15f | ||
|
|
cb413622eb | ||
|
|
420aeeba3d | ||
|
|
8827f2d561 | ||
|
|
23b8c2265e | ||
|
|
6dc8545ddd | ||
|
|
dea883c011 | ||
|
|
7baff049dc | ||
|
|
78d8c31f57 | ||
|
|
c4b8836b6e | ||
|
|
da80a6bba8 | ||
|
|
f0d2b7e16c | ||
|
|
3ad9294037 | ||
|
|
eaac6ea43f | ||
|
|
100a32f2a3 | ||
|
|
d5b1bfa0f5 | ||
|
|
0fec04488e | ||
|
|
ac2386be93 | ||
|
|
f16ba5a49d | ||
|
|
b83104a888 | ||
|
|
e9674a1ca6 | ||
|
|
29f7ba1518 | ||
|
|
baf0b1adc5 | ||
|
|
dbe7ca280a | ||
|
|
87e1d5773c | ||
|
|
e78b336edf | ||
|
|
aa2f16a7d9 | ||
|
|
7c18992e9b | ||
|
|
99af6fe1d9 | ||
|
|
38aeddd90d | ||
|
|
ddf17bf39a | ||
|
|
85af5ed310 | ||
|
|
84cda4034a | ||
|
|
8bc51d57eb | ||
|
|
cafef2f413 | ||
|
|
93e74b5579 | ||
|
|
b74ae6b114 | ||
|
|
60a01d0358 | ||
|
|
1194671896 | ||
|
|
1ab371b08e | ||
|
|
af50730d3a | ||
|
|
0abe34884e | ||
|
|
4c2222a75e | ||
|
|
bc5ca550fb | ||
|
|
95bc9d6d55 | ||
|
|
1c76af82aa | ||
|
|
cf621a47ac | ||
|
|
9dc284572b | ||
|
|
de77a9b821 | ||
|
|
78b8c0ac82 | ||
|
|
a21c767300 | ||
|
|
307e490dd4 | ||
|
|
d9003e50eb | ||
|
|
230fcb6649 | ||
|
|
3247a85a69 | ||
|
|
c702520e97 | ||
|
|
6434abcfdd | ||
|
|
4014f2ddc8 | ||
|
|
51c877de88 | ||
|
|
e394982270 | ||
|
|
d151100c25 | ||
|
|
248e85d7a5 | ||
|
|
33ef70e041 | ||
|
|
a2fced324e | ||
|
|
56e89cf9b6 | ||
|
|
1b0e620413 | ||
|
|
c604739456 | ||
|
|
2db14f7e2d | ||
|
|
7be54e1031 | ||
|
|
5b90f49c4f | ||
|
|
094489be69 | ||
|
|
1409f6e584 | ||
|
|
6652b918b9 | ||
|
|
e64194bf4b | ||
|
|
c111cdcfd3 | ||
|
|
0777cdf2e7 | ||
|
|
49803762b8 | ||
|
|
d47273ca01 | ||
|
|
bd7909d281 | ||
|
|
63be19b81d | ||
|
|
564c831c37 | ||
|
|
6aa9077907 | ||
|
|
b17200ae05 | ||
|
|
1f7ab1e88a | ||
|
|
0396957f42 | ||
|
|
6fc597847f | ||
|
|
6c7a999fc8 | ||
|
|
a30c958a6f | ||
|
|
ed6ec52e34 | ||
|
|
08243de4e4 | ||
|
|
e8876a17de | ||
|
|
7971101f16 | ||
|
|
d090e2d9a9 | ||
|
|
29c0516850 | ||
|
|
c61f8fa504 | ||
|
|
ee4ec97d32 | ||
|
|
e456baaad8 | ||
|
|
3a54ff8eb7 | ||
|
|
3903711218 | ||
|
|
82c5c7d185 | ||
|
|
2fc2c0f53e | ||
|
|
c809eaa26c | ||
|
|
763c1782ef | ||
|
|
9da9606c57 | ||
|
|
292cca30ee | ||
|
|
8ef22a2c34 | ||
|
|
8178a577df | ||
|
|
9ca638e3a4 | ||
|
|
b48f5c22bf | ||
|
|
235886c79c | ||
|
|
454f885f38 | ||
|
|
5cabf6559e | ||
|
|
be13387179 | ||
|
|
2aaeb8c12f | ||
|
|
c7e6f4a079 | ||
|
|
161e1c7602 | ||
|
|
233dd75a67 | ||
|
|
ab272e3a7c | ||
|
|
6d0162f65f | ||
|
|
a8f128106a | ||
|
|
85de9d0bbd | ||
|
|
d2d19e01ae | ||
|
|
ad34cda6e9 | ||
|
|
691964fe3b | ||
|
|
93f7ceb3c8 | ||
|
|
e4aa9d702d | ||
|
|
724968474f | ||
|
|
b5561d5e20 | ||
|
|
f09a7a7599 |
180
README.md
180
README.md
@@ -1,79 +1,123 @@
|
||||
# clash-for-Miwifi
|
||||
在小米AX3600/AX1800/AX5等路由器上使用clash做透明代理
|
||||
=====
|
||||
<h1 align="center">
|
||||
<img src="https://github.com/Dreamacro/clash/raw/master/docs/logo.png" alt="Clash" width="200">
|
||||
<br>ShellClash<br>
|
||||
</h1>
|
||||
|
||||
功能简介:
|
||||
|
||||
<p align="center">
|
||||
<a target="_blank" href="https://github.com/Dreamacro/clash/releases">
|
||||
<img src="https://img.shields.io/github/release/Dreamacro/Clash.svg?style=flat-square&label=Clash">
|
||||
</a>
|
||||
<a target="_blank" href="https://github.com/juewuy/ShellClash/releases">
|
||||
<img src="https://img.shields.io/github/release/juewuy/ShellClash.svg?style=flat-square&label=ShellClash&colorB=green">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
[中文](README_CN.md) | English
|
||||
|
||||
## Function introduction:
|
||||
|
||||
~Convenient use in Shell environment through management script [Clash](https://github.com/Dreamacro/clash)<br>~Support management of [Clash functions](https://lancellc.gitbook.io/clash)<br>~Support online import [Clash](https://github.com/Dreamacro/clash) supports sharing, subscription and configuration links<br>~Support configuration timing tasks, support configuration file timing updates<br>~Support online installation and Use local web panel to manage built-in rules<br>~Support routing mode, native mode and other mode switching<br>~Support GNOME, KDE desktop automatic configuration native mode<br>~Support online update<br>
|
||||
|
||||
## Equipment support:
|
||||
|
||||
~Support various router devices based on OpenWrt or secondary custom development using OpenWrt<br>~Support various devices running standard Linux systems (such as Debian/CenOS/Armbian, etc.)<br>~Compatible with Padavan firmware (conservative mode), Pandora firmware<br>~Compatible with various types of devices customized and developed using the Linux kernel<br>——————————<br>~For more device support, please submit an issue or go to the TG group for feedback (the device name and the device core information returned by running uname -a must be provided)<br>
|
||||
|
||||
How to use:
|
||||
--
|
||||
~支持小米AX系列路由器设备使用clash做透明代理,更多的设备支持可以前往TG群报名参与测试<br>
|
||||
~支持SS、SSR、v2ray、trojan、sock5等协议<br>
|
||||
~支持批量导入节点链接及订阅链接<br>
|
||||
~支持使用网页面板管理规则组<br>
|
||||
~支持多种模式切换,支持在线更新<br>
|
||||
~支持部署内置的管理面板<br>
|
||||
~更多功能可在使用中发掘<br>
|
||||
|
||||
更新日志:
|
||||
--
|
||||
* v0.9.0<br>
|
||||
~新增定时任务功能(实验性,欢迎测试)<br>
|
||||
~修复测试命令时一个报错的小bug<br>
|
||||
~Confirm that the router device has enabled SSH and obtained root privileges (Linux devices with GUI desktops can be installed using their own terminal)<br>~Use SSH connection tools (such as putty, JuiceSSH, system built-in terminal, etc.) router or Linux device SSH management interface or terminal interface, and switch to the root user<br>~Confirm that the curl or wget download tool has been installed on the device. If not installed, please [refer to here](https://www.howtoforge.com/install-curl-in-linux) for LInux devices to install curl. For devices based on OpenWrt (Xiaomi official system, Pandora, Gaoke, etc.), please Use the following command to install curl:<br>
|
||||
|
||||
* v0.8.7<br>
|
||||
~修复了脚本更新路径不正确的bug<br>
|
||||
~调整了geoip数据库下载源地址<br>
|
||||
~增加了自定义源输入检测<br>
|
||||
* v0.8.6<br>
|
||||
~新增CDN下载源和Github下载源,下载更新速度更快<br>
|
||||
~新增了切换下载源的选项菜单<br>
|
||||
~界面UI优化及bug修复<br>
|
||||
* v0.8.5<br>
|
||||
~新增了Tun/Redir混合模式<br>
|
||||
~新增是否支持ipv6的开关<br>
|
||||
~新增了更新核心时的版本检测<br>
|
||||
~新增了本地面板重复安装提示<br>
|
||||
~修复了部分报错提示<br>
|
||||
~修复了部分设定未及时更新的bug<br>
|
||||
* v0.8.4<br>
|
||||
~更新在线下载GeoIP数据库功能<br>
|
||||
~更新在线下载及部署Dashboard面板功能<br>
|
||||
~UI小幅度优化<br>
|
||||
|
||||
使用依赖:
|
||||
--
|
||||
~路由器或设备已经开启SSH并获取root权限<br>
|
||||
~SSH连接工具,例如putty,bitvise,JuiceSSH(支持安卓手机)等<br>
|
||||
|
||||
一键安装:
|
||||
--
|
||||
```Shell
|
||||
sh -c "$(curl -kfsSl https://juewuy.xyz/clash/install.sh)" && source /etc/profile &> /dev/null
|
||||
```sh
|
||||
opkg update && opkg install curl
|
||||
```
|
||||
|
||||
交流反馈:
|
||||
--
|
||||
### https://t.me/clashfm
|
||||
~ Then execute the following installation commands on the SSH interface, and follow the subsequent prompts to complete the installation<br>
|
||||
|
||||
已知问题:
|
||||
--
|
||||
~Tun模式下clash服务可能会和小米路由器内置的tx网游加速器冲突,请谨慎同时使用<br>
|
||||
~Redir模式无法转发udp流量,外服游戏可能会受影响,此功能是由官方系统阉割了Tproxy导致,暂时无解,外服游戏用户建议使用Tun模式<br>
|
||||
##### ~Use curl:<br>
|
||||
|
||||
ToDo:
|
||||
--
|
||||
~~增加订阅功能~~<br>
|
||||
~~添加一键安装脚本~~<br>
|
||||
~~增加屏蔽P2P流量功能~~<br>
|
||||
~~增加更新功能~~<br>
|
||||
~~修复redir-host DNS以及IPV6支持~~<br>
|
||||
~~增加定时功能~~<br>
|
||||
~增加屏蔽局域网设备<br>
|
||||
~增加更多设备支持<br>
|
||||
```Shell
|
||||
#By github
|
||||
export url='https://raw.githubusercontent.com/juewuy/ShellClash/master' && sh -c "$(curl -kfsSl $url/install.sh)" && source /etc/profile &> /dev/null
|
||||
#By jsdelivrCDN
|
||||
export url='https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master' && sh -c "$(curl -kfsSl $url/install.sh)" && source /etc/profile &> /dev/null
|
||||
```
|
||||
|
||||
感谢:
|
||||
--
|
||||
~https://lancellc.gitbook.io/clash/start-clash/clash-tun-mode<br>
|
||||
~https://comzyh.gitbook.io/clash/<br>
|
||||
~https://h-cheung.gitlab.io/post/使用_clash_和路由表实现透明代理<br>
|
||||
~https://www.right.com.cn/forum/thread-4042741-1-1.html<br>
|
||||
##### ~Use wget:<br>
|
||||
|
||||
```sh
|
||||
#By jsdelivrCDN
|
||||
export url='https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh && sh /tmp/install.sh && source /etc/profile &> /dev/null
|
||||
```
|
||||
|
||||
~**Use a low version of wget (prompt not to support https) local installation**:<br> First clone the project to the local under the window (or [click to download the project source code zip package](https://github.com/juewuy/ShellClash/archive/refs/heads/master.zip) to the local and decompress it)
|
||||
|
||||
```sh
|
||||
sh git clone https://github.com/juewuy/ShellClash.git
|
||||
```
|
||||
|
||||
Then open /project address/ShellClash/bin/hfs/hfs.exe Click menu-add directory from disk-{find the directory where ShellClash source code is located}-add as real directory Click on the menu-IP address-{choose the actual IP address of your LAN} Click ShellClash-click to copy to clipboard Then use the following command to install in SSH
|
||||
|
||||
```sh
|
||||
sh export url='Paste the copied address here' && wget -q -O /tmp/install.sh $url/install.sh && sh /tmp/install.sh && source /etc/profile &> /dev/null
|
||||
```
|
||||
|
||||
Later, when updating the version, you need to update the local version library and open the hfs service, and then update in the SSH menu, and then you can build a local server through hfs to realize the function of uploading and updating the yaml configuration file
|
||||
|
||||
~**After installation by non-root users**, please execute the following additional commands to read environment variables:<br>
|
||||
|
||||
```shell
|
||||
source ~/.bashrc &> /dev/null
|
||||
```
|
||||
|
||||
~After installing the management script, execute the following command to **run the management script**<br>
|
||||
|
||||
```Shell
|
||||
clash #normal mode
|
||||
clash -h #help
|
||||
clash -u #uninstall
|
||||
clash -t #test mode
|
||||
```
|
||||
|
||||
~**Additional dependencies at runtime**:<br>
|
||||
|
||||
```
|
||||
Most of the equipment/systems are pre-installed with most of the following dependencies, you can ignore them if there is no impact when you use them.
|
||||
```
|
||||
|
||||
```sh
|
||||
bash/ash necessary Cannot install and run scripts when all are missing
|
||||
curl/wget necessary When all are missing, it cannot be installed and updated online
|
||||
iptables important Only use pure mode when missing
|
||||
systemd/rc.common general Only use conservative mode when all are missing
|
||||
iptables-mod-nat general Cannot use redir mode, mixed mode when missing
|
||||
ip6tables-mod-nat lower Affects redir mode when missing, mixed mode support for ipv6
|
||||
crontab lower Cannot enable timing task function when missing
|
||||
net-tools minimal Cannot detect port occupancy normally when missing
|
||||
ubus/iproute-doc minimal The host address of the machine cannot be obtained normally when missing
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Update log:
|
||||
|
||||
### [Click to view](https://github.com/juewuy/ShellClash/releases)
|
||||
|
||||
## Exchange feedback:
|
||||
|
||||
### [TG Discussion Group](https://t.me/clashfm)
|
||||
|
||||
## Related Q&A:
|
||||
|
||||
### [See blog for details](https://juewuy.github.io)
|
||||
|
||||
## Donate:
|
||||
|
||||
Alipay WeChat
|
||||
|
||||
##### <img src="http://juewuy.github.io/post-images/1604390977172.png" style="zoom:50%;" /><img src="http://juewuy.github.io/post-images/1604391042406.png" style="zoom:50%;" />
|
||||
|
||||
## Friendly promotion:
|
||||
|
||||
### [Top 8K Airport-Dler](https://dler.best/auth/register?affid=89698)
|
||||
|
||||
|
||||
125
README_CN.md
Normal file
125
README_CN.md
Normal file
@@ -0,0 +1,125 @@
|
||||
<h1 align="center">
|
||||
<img src="https://github.com/Dreamacro/clash/raw/master/docs/logo.png" alt="Clash" width="200">
|
||||
<br>ShellClash<br>
|
||||
</h1>
|
||||
|
||||
|
||||
<p align="center">
|
||||
<a target="_blank" href="https://github.com/Dreamacro/clash/releases">
|
||||
<img src="https://img.shields.io/github/release/Dreamacro/Clash.svg?style=flat-square&label=Clash">
|
||||
</a>
|
||||
<a target="_blank" href="https://github.com/juewuy/ShellClash/releases">
|
||||
<img src="https://img.shields.io/github/release/juewuy/ShellClash.svg?style=flat-square&label=ShellClash&colorB=green">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
中文 | [English](README.md)
|
||||
|
||||
功能简介:
|
||||
--
|
||||
|
||||
~通过管理脚本在Shell环境下便捷使用[Clash](https://github.com/Dreamacro/clash)<br>
|
||||
~支持在Shell环境下管理[Clash各种功能](https://lancellc.gitbook.io/clash)<br>
|
||||
~支持在线导入[Clash](https://github.com/Dreamacro/clash)支持的分享、订阅及配置链接<br>~支持配置定时任务,支持配置文件定时更新<br>~支持在线安装及使用本地网页面板管理内置规则<br>
|
||||
~支持路由模式、本机模式等多种模式切换<br>~支持在线更新<br>
|
||||
|
||||
设备支持:
|
||||
--
|
||||
|
||||
~支持各种基于OpenWrt或使用OpenWrt二次定制开发的路由器设备<br>
|
||||
~支持各种运行标准Linux系统(如Debian/CenOS/Armbian等)的设备<br>~兼容Padavan固件(保守模式)、潘多拉固件以及华硕/梅林固件<br>~兼容各类使用Linux内核定制开发的各类型设备<br>
|
||||
|
||||
——————————<br>
|
||||
~更多设备支持,请提issue或前往TG群反馈(需提供设备名称及运行uname -a返回的设备核心信息)<br>
|
||||
|
||||
使用方式:
|
||||
--
|
||||
~确认路由器设备已经开启SSH并获取root权限(带GUI桌面的Linux设备可使用自带终端安装)<br>
|
||||
~使用SSH连接工具(如putty,JuiceSSH,系统自带终端等)路由器或Linux设备的SSH管理界面或终端界面,并切换到root用户<br>
|
||||
~确认设备已经安装curl或者wget下载工具。**如未安装**,LInux设备请[参考此处](https://www.howtoing.com/install-curl-in-linux)安装curl,基于OpenWrt(小米官方系统、潘多拉、高恪等)的设备请使用如下命令安装curl:<br>
|
||||
|
||||
```shell
|
||||
opkg update && opkg install curl #如已安装请忽略
|
||||
```
|
||||
|
||||
~之后在SSH界面执行如下安装命令,并按照后续提示完成安装<br>
|
||||
|
||||
~**使用curl安装**:<br>
|
||||
|
||||
```Shell
|
||||
#github直连
|
||||
export url='https://raw.githubusercontent.com/juewuy/ShellClash/master' && sh -c "$(curl -kfsSl $url/install.sh)" && source /etc/profile &> /dev/null
|
||||
#jsdelivrCDN源
|
||||
export url='https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master' && sh -c "$(curl -kfsSl $url/install.sh)" && source /etc/profile &> /dev/null
|
||||
```
|
||||
|
||||
~**使用wget安装**:<br>
|
||||
|
||||
```sh
|
||||
#Release版本-jsdelivrCDN源
|
||||
export url='https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master' && wget -q --no-check-certificate -O /tmp/install.sh $url/install.sh && sh /tmp/install.sh && source /etc/profile &> /dev/null
|
||||
```
|
||||
|
||||
~**使用低版本wget(提示不支持https)安装**:<br>
|
||||
|
||||
```sh
|
||||
#Test版本-酱紫表私人http源
|
||||
export url='http://sc.qust.me/' && wget -q -O /tmp/install.sh $url/install_n.sh && sh /tmp/install.sh && source /etc/profile &> /dev/null
|
||||
```
|
||||
|
||||
~**非root用户安装后**请额外执行以下命令以读取环境变量:<br>
|
||||
|
||||
```shell
|
||||
source ~/.bashrc &> /dev/null
|
||||
```
|
||||
|
||||
~安装完成管理脚本后,执行如下命令以**运行管理脚本**<br>
|
||||
|
||||
```Shell
|
||||
clash #正常模式运行
|
||||
clash -h #脚本帮助及说明
|
||||
clash -u #卸载脚本
|
||||
clash -t #测试模式运行
|
||||
```
|
||||
|
||||
~**运行时的额外依赖**:<br>
|
||||
|
||||
`大部分的设备/系统都已经预装了以下的大部分依赖,使用时如无影响可以无视之`
|
||||
|
||||
```sh
|
||||
bash/ash 必须 全部缺少时无法安装及运行脚本
|
||||
curl/wget 必须 全部缺少时无法在线安装及更新,无法使用节点保存功能
|
||||
iptables 重要 缺少时只能使用纯净模式
|
||||
systemd/rc.common 一般 全部缺少时只能使用保守模式
|
||||
iptables-mod-nat 一般 缺少时无法使用redir模式,混合模式
|
||||
ip6tables-mod-nat 较低 缺少时影响redir模式,混合模式对ipv6的支持
|
||||
crontab 较低 缺少时无法启用定时任务功能
|
||||
net-tools 极低 缺少时无法正常检测端口占用
|
||||
ubus/iproute-doc 极低 缺少时无法正常获取本机host地址
|
||||
```
|
||||
|
||||
|
||||
|
||||
更新日志:
|
||||
--
|
||||
|
||||
### [点击查看](https://github.com/juewuy/ShellClash/releases)
|
||||
|
||||
交流反馈:
|
||||
--
|
||||
### [TG讨论组](https://t.me/clashfm)
|
||||
|
||||
相关Q&A:
|
||||
--
|
||||
|
||||
### [详见博客](https://juewuy.github.io)
|
||||
|
||||
## 请喝杯茶:
|
||||
|
||||
支付宝 微信
|
||||
|
||||
##### <img src="http://juewuy.github.io/post-images/1604390977172.png" style="zoom:50%;" /><img src="http://juewuy.github.io/post-images/1604391042406.png" style="zoom:50%;" />
|
||||
|
||||
友情推广:
|
||||
--
|
||||
### [顶级8K专线机场-墙洞](https://dler.best/auth/register?affid=89698)
|
||||
BIN
bin/Country.mmdb
BIN
bin/Country.mmdb
Binary file not shown.
3138
bin/ca-certificates.crt
Normal file
3138
bin/ca-certificates.crt
Normal file
File diff suppressed because it is too large
Load Diff
6084
bin/china_ip_list.txt
Normal file
6084
bin/china_ip_list.txt
Normal file
File diff suppressed because it is too large
Load Diff
BIN
bin/clash/clash-linux-386
Normal file
BIN
bin/clash/clash-linux-386
Normal file
Binary file not shown.
BIN
bin/clash/clash-linux-amd64
Normal file
BIN
bin/clash/clash-linux-amd64
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/clash/clash-linux-mips-softfloat
Normal file
BIN
bin/clash/clash-linux-mips-softfloat
Normal file
Binary file not shown.
BIN
bin/clash/clash-linux-mipsle-hardfloat
Normal file
BIN
bin/clash/clash-linux-mipsle-hardfloat
Normal file
Binary file not shown.
BIN
bin/clash/clash-linux-mipsle-softfloat
Normal file
BIN
bin/clash/clash-linux-mipsle-softfloat
Normal file
Binary file not shown.
@@ -1 +0,0 @@
|
||||
version=1.0.0
|
||||
Binary file not shown.
Binary file not shown.
BIN
bin/clashpre/clash-linux-386
Normal file
BIN
bin/clashpre/clash-linux-386
Normal file
Binary file not shown.
BIN
bin/clashpre/clash-linux-amd64
Normal file
BIN
bin/clashpre/clash-linux-amd64
Normal file
Binary file not shown.
BIN
bin/clashpre/clash-linux-armv5
Normal file
BIN
bin/clashpre/clash-linux-armv5
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
bin/clashpre/clash-linux-mips-softfloat
Normal file
BIN
bin/clashpre/clash-linux-mips-softfloat
Normal file
Binary file not shown.
BIN
bin/clashpre/clash-linux-mipsle-hardfloat
Normal file
BIN
bin/clashpre/clash-linux-mipsle-hardfloat
Normal file
Binary file not shown.
BIN
bin/clashpre/clash-linux-mipsle-softfloat
Normal file
BIN
bin/clashpre/clash-linux-mipsle-softfloat
Normal file
Binary file not shown.
@@ -1 +0,0 @@
|
||||
version=1.0.0
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +0,0 @@
|
||||
version=1.0.0
|
||||
BIN
bin/cn_mini.mmdb
Normal file
BIN
bin/cn_mini.mmdb
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 112 KiB |
BIN
bin/hfs/hfs.exe
Normal file
BIN
bin/hfs/hfs.exe
Normal file
Binary file not shown.
8
bin/release_version
Normal file
8
bin/release_version
Normal file
@@ -0,0 +1,8 @@
|
||||
1.4.1
|
||||
1.3.0
|
||||
1.2.0
|
||||
1.1.0
|
||||
1.0.0beta17
|
||||
1.0.0beta11
|
||||
1.0.0beta5
|
||||
0.9.7
|
||||
@@ -1 +1,4 @@
|
||||
versionsh=0.9.0
|
||||
clash_v=1.6.0
|
||||
clashpre_v=2021.05.08
|
||||
GeoIP_v=20210623
|
||||
versionsh=1.4.1
|
||||
|
||||
BIN
bin/yacd.tar.gz
Normal file
BIN
bin/yacd.tar.gz
Normal file
Binary file not shown.
282
install.sh
282
install.sh
@@ -1,87 +1,225 @@
|
||||
#!/bin/sh
|
||||
#! /bin/bash
|
||||
# Copyright (C) Juewuy
|
||||
|
||||
echo='echo -e' && [ -n "$(echo -e|grep e)" ] && echo=echo
|
||||
#[ -z "$1" ] && test=0 || test=$1
|
||||
|
||||
echo "***********************************************"
|
||||
echo "** 欢迎使用 **"
|
||||
echo "** Clash for Miwifi **"
|
||||
echo "** ShellClash **"
|
||||
echo "** by Juewuy **"
|
||||
echo "***********************************************"
|
||||
|
||||
url="https://juewuy.xyz/clash/"
|
||||
result=$(curl -w %{http_code} -skLo /tmp/clashversion $url/bin/version)
|
||||
[ "$result" != "200" ] && echo "无法连接到服务器!" && exit 1
|
||||
source /tmp/clashversion
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo -e "~~~~版本:\033[32m$versionsh\033[0m"
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo -e "\033[44m使用中如遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
||||
echo -e "\033[37m目前仅支持小米AX系列3款路由器"
|
||||
echo -e "\033[44m其余型号可到TG群报名参与测试\033[0m"
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo -e "\033[32m 1 在默认目录(/etc)安装Clash for Miwifi"
|
||||
echo -e "\033[33m 2 手动设置安装目录(不明勿用!)"
|
||||
echo -e "\033[0m 0 退出安装"
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
[ -f "/etc/storage/started_script.sh" ] && systype=Padavan && initdir='/etc/storage/started_script.sh'
|
||||
[ -f "/jffs/.asusrouter" ] && systype=asusrouter && initdir='/jffs/.asusrouter'
|
||||
#检查root权限
|
||||
if [ "$USER" != "root" -a -z "$systype" ];then
|
||||
echo 当前用户:$USER
|
||||
$echo "\033[31m请尽量使用root用户(不要直接使用sudo命令!)执行安装!\033[0m"
|
||||
echo -----------------------------------------------
|
||||
read -p "仍要安装?可能会产生未知错误!(1/0) > " res
|
||||
[ "$res" != "1" ] && exit
|
||||
fi
|
||||
webget(){
|
||||
#参数【$1】代表下载目录,【$2】代表在线地址
|
||||
#参数【$3】代表输出显示,【$4】不启用重定向
|
||||
if curl --version > /dev/null 2>&1;then
|
||||
[ "$3" = "echooff" ] && progress='-s' || progress='-#'
|
||||
[ -z "$4" ] && redirect='-L' || redirect=''
|
||||
result=$(curl -w %{http_code} --connect-timeout 5 $progress $redirect -ko $1 $2)
|
||||
else
|
||||
if wget --version > /dev/null 2>&1;then
|
||||
[ "$3" = "echooff" ] && progress='-q' || progress='-q --show-progress'
|
||||
[ "$4" = "rediroff" ] && redirect='--max-redirect=0' || redirect=''
|
||||
certificate='--no-check-certificate'
|
||||
timeout='--timeout=3'
|
||||
fi
|
||||
[ "$3" = "echoon" ] && progress=''
|
||||
[ "$3" = "echooff" ] && progress='-q'
|
||||
wget $progress $redirect $certificate $timeout -O $1 $2
|
||||
[ $? -eq 0 ] && result="200"
|
||||
fi
|
||||
}
|
||||
#检查更新
|
||||
[ -z "$url" ] && url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
|
||||
#选择版本
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[33m请选择想要安装的版本:\033[0m"
|
||||
$echo " 1 \033[32mShellclash正式版\033[0m"
|
||||
$echo " 2 \033[31mShellclash测试版\033[0m"
|
||||
echo -----------------------------------------------
|
||||
read -p "请输入相应数字 > " num
|
||||
|
||||
if [ -z $num ];then
|
||||
echo 安装已取消
|
||||
exit;
|
||||
elif [[ $num == 1 ]];then
|
||||
dir=/etc
|
||||
elif [[ $num == 2 ]];then
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo '可用路径 剩余空间:'
|
||||
df -h | awk '{print $6,$2}'| sed 1d
|
||||
echo '路径是必须带 / 的格式,写入虚拟内存(/tmp,/sys,..)的文件会在重启后消失!!!'
|
||||
read -p "请输入自定义路径 > " dir
|
||||
if [ -z $dir ];then
|
||||
echo 路径错误!已取消安装!
|
||||
elif [ "$num" = "1" ];then
|
||||
webget /tmp/clashrelease $url/bin/release_version echoon rediroff 2>/tmp/clashrelease
|
||||
if [ "$result" = "200" ];then
|
||||
release_new=$(cat /tmp/clashrelease | head -1)
|
||||
url2="https://cdn.jsdelivr.net/gh/juewuy/ShellClash@$release_new"
|
||||
else
|
||||
echo "无法切换版本,尝试安装测试版!"
|
||||
fi
|
||||
fi
|
||||
[ -z "$url2" ] && url2=$url
|
||||
webget /tmp/clashversion "$url2/bin/version" echooff
|
||||
[ "$result" = "200" ] && versionsh=$(cat /tmp/clashversion | grep "versionsh" | awk -F "=" '{print $2}')
|
||||
[ -z "$release_new" ] && release_new=$versionsh
|
||||
rm -rf /tmp/clashversion
|
||||
rm -rf /tmp/clashrelease
|
||||
tarurl=$url2/bin/clashfm.tar.gz
|
||||
|
||||
gettar(){
|
||||
webget /tmp/clashfm.tar.gz $tarurl
|
||||
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
|
||||
#解压
|
||||
echo -----------------------------------------------
|
||||
echo 开始解压文件!
|
||||
mkdir -p $clashdir > /dev/null
|
||||
tar -zxvf '/tmp/clashfm.tar.gz' -C $clashdir/
|
||||
[ $? -ne 0 ] && echo "文件解压失败!" && rm -rf /tmp/clashfm.tar.gz && exit 1
|
||||
#初始化文件目录
|
||||
[ -f "$clashdir/mark" ] || echo '#标识clash运行状态的文件,不明勿动!' > $clashdir/mark
|
||||
#判断系统类型写入不同的启动文件
|
||||
if [ -f /etc/rc.common ];then
|
||||
#设为init.d方式启动
|
||||
mv $clashdir/clashservice /etc/init.d/clash
|
||||
chmod 777 /etc/init.d/clash
|
||||
else
|
||||
[ -w /etc/systemd/system ] && sysdir=/etc/systemd/system
|
||||
[ -w /usr/lib/systemd/system ] && sysdir=/usr/lib/systemd/system
|
||||
if [ -n "$sysdir" ];then
|
||||
#设为systemd方式启动
|
||||
mv $clashdir/clash.service $sysdir/clash.service
|
||||
sed -i "s%/etc/clash%$clashdir%g" $sysdir/clash.service
|
||||
systemctl daemon-reload
|
||||
else
|
||||
#设为保守模式启动
|
||||
sed -i '/start_old=*/'d $clashdir/mark
|
||||
echo start_old=已开启 >> $clashdir/mark
|
||||
fi
|
||||
fi
|
||||
#修饰文件及版本号
|
||||
shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash
|
||||
sed -i "s|/bin/sh|/bin/$shtype|" $clashdir/start.sh
|
||||
chmod 777 $clashdir/start.sh
|
||||
sed -i '/versionsh_l=*/'d $clashdir/mark
|
||||
echo versionsh_l=$release_new >> $clashdir/mark
|
||||
#设置更新地址
|
||||
sed -i '/update_url=*/'d $clashdir/mark
|
||||
echo update_url=$url >> $clashdir/mark
|
||||
#设置环境变量
|
||||
[ -w /opt/etc/profile ] && profile=/opt/etc/profile
|
||||
[ -w /jffs/configs/profile.add ] && profile=/jffs/configs/profile.add
|
||||
[ -w ~/.bashrc ] && profile=~/.bashrc
|
||||
[ -w /etc/profile ] && profile=/etc/profile
|
||||
if [ -n "$profile" ];then
|
||||
sed -i '/alias clash=*/'d $profile
|
||||
echo "alias clash=\"$shtype $clashdir/clash.sh\"" >> $profile #设置快捷命令环境变量
|
||||
sed -i '/export clashdir=*/'d $profile
|
||||
echo "export clashdir=\"$clashdir\"" >> $profile #设置clash路径环境变量
|
||||
else
|
||||
echo 无法写入环境变量!请检查安装权限!
|
||||
exit 1
|
||||
fi
|
||||
#华硕/Padavan额外设置
|
||||
[ -n "$systype" ] && sed -i '/ShellClash初始化/'d $initdir && echo "$clashdir/start.sh init #ShellClash初始化脚本" >> $initdir
|
||||
#删除临时文件
|
||||
rm -rf /tmp/clashfm.tar.gz
|
||||
rm -rf $clashdir/clashservice
|
||||
rm -rf $clashdir/clash.service
|
||||
}
|
||||
#下载及安装
|
||||
install(){
|
||||
echo -----------------------------------------------
|
||||
echo 开始从服务器获取安装文件!
|
||||
echo -----------------------------------------------
|
||||
gettar
|
||||
echo -----------------------------------------------
|
||||
echo ShellClash 已经安装成功!
|
||||
[ "$profile" = "~/.bashrc" ] && echo "请执行【source ~/.bashrc &> /dev/null】命令以加载环境变量!"
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理!!!\033[0m"
|
||||
echo -----------------------------------------------
|
||||
}
|
||||
setdir(){
|
||||
if [ -n "$systype" ];then
|
||||
[ "$systype" = "Padavan" ] && dir=/etc/storage
|
||||
[ "$systype" = "asusrouter" ] && dir=/jffs
|
||||
else
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[33m安装ShellClash至少需要预留约1MB的磁盘空间\033[0m"
|
||||
$echo " 1 在\033[32m/etc目录\033[0m下安装(适合root用户)"
|
||||
$echo " 2 在\033[32m/usr/share目录\033[0m下安装(适合Linux设备)"
|
||||
$echo " 3 在\033[32m当前用户目录\033[0m下安装(适合非root用户)"
|
||||
$echo " 4 手动设置安装目录"
|
||||
$echo " 0 退出安装"
|
||||
echo -----------------------------------------------
|
||||
read -p "请输入相应数字 > " num
|
||||
#设置目录
|
||||
if [ -z $num ];then
|
||||
echo 安装已取消
|
||||
exit;
|
||||
elif [ "$num" = "1" ];then
|
||||
dir=/etc
|
||||
elif [ "$num" = "2" ];then
|
||||
dir=/usr/share
|
||||
elif [ "$num" = "3" ];then
|
||||
dir=~/.local/share
|
||||
mkdir -p ~/.config/systemd/user
|
||||
elif [ "$num" = "4" ];then
|
||||
echo -----------------------------------------------
|
||||
echo '可用路径 剩余空间:'
|
||||
df -h | awk '{print $6,$4}'| sed 1d
|
||||
echo '路径是必须带 / 的格式,注意写入虚拟内存(/tmp,/opt,/sys...)的文件会在重启后消失!!!'
|
||||
read -p "请输入自定义路径 > " dir
|
||||
if [ -z "$dir" ];then
|
||||
$echo "\033[31m路径错误!请重新设置!\033[0m"
|
||||
setdir
|
||||
fi
|
||||
else
|
||||
echo 安装已取消!!!
|
||||
exit;
|
||||
fi
|
||||
fi
|
||||
if [ ! -w $dir ];then
|
||||
$echo "\033[31m没有$dir目录写入权限!请重新设置!\033[0m" && sleep 1 && setdir
|
||||
else
|
||||
$echo "目标目录\033[32m$dir\033[0m空间剩余:$(df -h $dir | awk '{print $4}' | sed 1d )"
|
||||
read -p "确认安装?(1/0) > " res
|
||||
[ "$res" = "1" ] && clashdir=$dir/clash || setdir
|
||||
fi
|
||||
}
|
||||
|
||||
#输出
|
||||
$echo "最新版本:\033[32m$release_new\033[0m"
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[44m如遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
||||
$echo "\033[37m支持各种基于openwrt的路由器设备"
|
||||
$echo "\033[33m支持Debian、Centos等标准Linux系统\033[0m"
|
||||
|
||||
if [ -n "$clashdir" ];then
|
||||
echo -----------------------------------------------
|
||||
$echo "检测到旧的安装目录\033[36m$clashdir\033[0m,是否覆盖安装?"
|
||||
$echo "\033[32m覆盖安装时不会移除配置文件!\033[0m"
|
||||
read -p "覆盖安装/卸载旧版本?(1/0) > " res
|
||||
if [ "$res" = "1" ];then
|
||||
install
|
||||
elif [ "$res" = "0" ];then
|
||||
rm -rf $clashdir
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[31m 旧版本文件已卸载!\033[0m"
|
||||
setdir
|
||||
install
|
||||
elif [ "$res" = "9" ];then
|
||||
echo 测试模式,变更安装位置
|
||||
setdir
|
||||
install
|
||||
else
|
||||
$echo "\033[31m输入错误!已取消安装!\033[0m"
|
||||
exit;
|
||||
fi
|
||||
else
|
||||
echo 安装已取消
|
||||
exit;
|
||||
setdir
|
||||
install
|
||||
fi
|
||||
#下载文件包
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo 开始从服务器获取安装文件!
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
tarurl=$url/bin/clashfm.tar.gz
|
||||
if command -v curl &> /dev/null; then
|
||||
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl)
|
||||
else $result
|
||||
wget-ssl -q --no-check-certificate --tries=1 --timeout=10 -O /tmp/clashfm.tar.gz $tarurl
|
||||
[ $? -eq 0 ] && result="200"
|
||||
fi
|
||||
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
|
||||
#解压
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo 开始解压文件!
|
||||
mkdir -p $dir/clash > /dev/null
|
||||
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/
|
||||
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
|
||||
#初始化文件目录
|
||||
mv $dir/clash/clashservice /etc/init.d/clash #将clash服务文件移动到系统目录
|
||||
chmod 777 $dir/clash/clash #授予权限
|
||||
chmod 777 /etc/init.d/clash #授予权限
|
||||
if [ ! -f "$dir/clash/mark" ]; then
|
||||
cat >$ccfg<<EOF
|
||||
#标识clash运行状态的文件,不明勿动!
|
||||
EOF
|
||||
fi
|
||||
sed -i '/versionsh_l=*/'d $dir/clash/mark
|
||||
sed -i "1i\versionsh_l=$versionsh" $dir/clash/mark
|
||||
#设置环境变量
|
||||
sed -i '/alias clash=*/'d /etc/profile
|
||||
echo "alias clash=\"sh $dir/clash/clash.sh\"" >> /etc/profile #设置快捷命令环境变量
|
||||
sed -i '/export clashdir=*/'d /etc/profile
|
||||
echo "export clashdir=\"$dir/clash\"" >> /etc/profile #设置clash路径环境变量
|
||||
#删除临时文件
|
||||
rm -rf /tmp/clashfm.tar.gz
|
||||
#提示
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo clash for Miwifi 已经安装成功!
|
||||
echo -e "\033[33m直接输入\033[30;47m clash \033[0;33m命令即可管理!!!\033[0m"
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
||||
87
install_c.sh
87
install_c.sh
@@ -1,87 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) Juewuy
|
||||
|
||||
echo "***********************************************"
|
||||
echo "** 欢迎使用 **"
|
||||
echo "** Clash for Miwifi **"
|
||||
echo "** by Juewuy **"
|
||||
echo "***********************************************"
|
||||
|
||||
url="https://cdn.jsdelivr.net/gh/juewuy/clash-for-Miwifi/"
|
||||
result=$(curl -w %{http_code} -skLo /tmp/clashversion $url/bin/version)
|
||||
[ "$result" != "200" ] && echo "无法连接到服务器!" && exit 1
|
||||
source /tmp/clashversion
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo -e "~~~~版本:\033[32m$versionsh\033[0m"
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo -e "\033[44m使用中如遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
||||
echo -e "\033[37m目前仅支持小米AX系列3款路由器"
|
||||
echo -e "\033[44m其余型号可到TG群报名参与测试\033[0m"
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo -e "\033[32m 1 在默认目录(/etc)安装Clash for Miwifi"
|
||||
echo -e "\033[33m 2 手动设置安装目录(不明勿用!)"
|
||||
echo -e "\033[0m 0 退出安装"
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
read -p "请输入相应数字 > " num
|
||||
|
||||
if [ -z $num ];then
|
||||
echo 安装已取消
|
||||
exit;
|
||||
elif [[ $num == 1 ]];then
|
||||
dir=/etc
|
||||
elif [[ $num == 2 ]];then
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo '可用路径 剩余空间:'
|
||||
df -h | awk '{print $6,$2}'| sed 1d
|
||||
echo '路径是必须带 / 的格式,写入虚拟内存(/tmp,/sys,..)的文件会在重启后消失!!!'
|
||||
read -p "请输入自定义路径 > " dir
|
||||
if [ -z $dir ];then
|
||||
echo 路径错误!已取消安装!
|
||||
exit;
|
||||
fi
|
||||
else
|
||||
echo 安装已取消
|
||||
exit;
|
||||
fi
|
||||
#下载文件包
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo 开始从服务器获取安装文件!
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
tarurl=$url/bin/clashfm.tar.gz
|
||||
if command -v curl &> /dev/null; then
|
||||
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl)
|
||||
else $result
|
||||
wget-ssl -q --no-check-certificate --tries=1 --timeout=10 -O /tmp/clashfm.tar.gz $tarurl
|
||||
[ $? -eq 0 ] && result="200"
|
||||
fi
|
||||
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
|
||||
#解压
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo 开始解压文件!
|
||||
mkdir -p $dir/clash > /dev/null
|
||||
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/
|
||||
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
|
||||
#初始化文件目录
|
||||
mv $dir/clash/clashservice /etc/init.d/clash #将clash服务文件移动到系统目录
|
||||
chmod 777 $dir/clash/clash #授予权限
|
||||
chmod 777 /etc/init.d/clash #授予权限
|
||||
if [ ! -f "$dir/clash/mark" ]; then
|
||||
cat >$ccfg<<EOF
|
||||
#标识clash运行状态的文件,不明勿动!
|
||||
EOF
|
||||
fi
|
||||
sed -i '/versionsh_l=*/'d $dir/clash/mark
|
||||
sed -i "1i\versionsh_l=$versionsh" $dir/clash/mark
|
||||
#设置环境变量
|
||||
sed -i '/alias clash=*/'d /etc/profile
|
||||
echo "alias clash=\"sh $dir/clash/clash.sh\"" >> /etc/profile #设置快捷命令环境变量
|
||||
sed -i '/export clashdir=*/'d /etc/profile
|
||||
echo "export clashdir=\"$dir/clash\"" >> /etc/profile #设置clash路径环境变量
|
||||
#删除临时文件
|
||||
rm -rf /tmp/clashfm.tar.gz
|
||||
#提示
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
echo clash for Miwifi 已经安装成功!
|
||||
echo -e "\033[33m直接输入\033[30;47m clash \033[0;33m命令即可管理!!!\033[0m"
|
||||
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
225
install_n.sh
Normal file
225
install_n.sh
Normal file
@@ -0,0 +1,225 @@
|
||||
#! /bin/bash
|
||||
# Copyright (C) Juewuy
|
||||
|
||||
echo='echo -e' && [ -n "$(echo -e|grep e)" ] && echo=echo
|
||||
#[ -z "$1" ] && test=0 || test=$1
|
||||
|
||||
echo "***********************************************"
|
||||
echo "** 欢迎使用 **"
|
||||
echo "** ShellClash **"
|
||||
echo "** by Juewuy **"
|
||||
echo "***********************************************"
|
||||
|
||||
[ -f "/etc/storage/started_script.sh" ] && systype=Padavan && initdir='/etc/storage/started_script.sh'
|
||||
[ -f "/jffs/.asusrouter" ] && systype=asusrouter && initdir='/jffs/.asusrouter'
|
||||
#检查root权限
|
||||
if [ "$USER" != "root" -a -z "$systype" ];then
|
||||
echo 当前用户:$USER
|
||||
$echo "\033[31m请尽量使用root用户(不要直接使用sudo命令!)执行安装!\033[0m"
|
||||
echo -----------------------------------------------
|
||||
read -p "仍要安装?可能会产生未知错误!(1/0) > " res
|
||||
[ "$res" != "1" ] && exit
|
||||
fi
|
||||
webget(){
|
||||
#参数【$1】代表下载目录,【$2】代表在线地址
|
||||
#参数【$3】代表输出显示,【$4】不启用重定向
|
||||
if curl --version > /dev/null 2>&1;then
|
||||
[ "$3" = "echooff" ] && progress='-s' || progress='-#'
|
||||
[ -z "$4" ] && redirect='-L' || redirect=''
|
||||
result=$(curl -w %{http_code} --connect-timeout 5 $progress $redirect -ko $1 $2)
|
||||
else
|
||||
if wget --version > /dev/null 2>&1;then
|
||||
[ "$3" = "echooff" ] && progress='-q' || progress='-q --show-progress'
|
||||
[ "$4" = "rediroff" ] && redirect='--max-redirect=0' || redirect=''
|
||||
certificate='--no-check-certificate'
|
||||
timeout='--timeout=3'
|
||||
fi
|
||||
[ "$3" = "echoon" ] && progress=''
|
||||
[ "$3" = "echooff" ] && progress='-q'
|
||||
wget $progress $redirect $certificate $timeout -O $1 $2
|
||||
[ $? -eq 0 ] && result="200"
|
||||
fi
|
||||
}
|
||||
#检查更新
|
||||
[ -z "$url" ] && url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
|
||||
#选择版本
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[33m请选择想要安装的版本:\033[0m"
|
||||
$echo " 1 \033[32mShellclash正式版\033[0m"
|
||||
$echo " 2 \033[31mShellclash测试版\033[0m"
|
||||
echo -----------------------------------------------
|
||||
read -p "请输入相应数字 > " num
|
||||
if [ -z $num ];then
|
||||
echo 安装已取消
|
||||
exit;
|
||||
elif [ "$num" = "1" ];then
|
||||
webget /tmp/clashrelease $url/bin/release_version echoon rediroff 2>/tmp/clashrelease
|
||||
if [ "$result" = "200" ];then
|
||||
release_new=$(cat /tmp/clashrelease | head -1)
|
||||
url2="https://cdn.jsdelivr.net/gh/juewuy/ShellClash@$release_new"
|
||||
else
|
||||
echo "无法切换版本,尝试安装测试版!"
|
||||
fi
|
||||
fi
|
||||
[ -z "$url2" ] && url2=$url
|
||||
webget /tmp/clashversion "$url2/bin/version" echooff
|
||||
[ "$result" = "200" ] && versionsh=$(cat /tmp/clashversion | grep "versionsh" | awk -F "=" '{print $2}')
|
||||
[ -z "$release_new" ] && release_new=$versionsh
|
||||
rm -rf /tmp/clashversion
|
||||
rm -rf /tmp/clashrelease
|
||||
tarurl=$url2/bin/clashfm.tar.gz
|
||||
|
||||
gettar(){
|
||||
webget /tmp/clashfm.tar.gz $tarurl
|
||||
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
|
||||
#解压
|
||||
echo -----------------------------------------------
|
||||
echo 开始解压文件!
|
||||
mkdir -p $clashdir > /dev/null
|
||||
tar -zxvf '/tmp/clashfm.tar.gz' -C $clashdir/
|
||||
[ $? -ne 0 ] && echo "文件解压失败!" && rm -rf /tmp/clashfm.tar.gz && exit 1
|
||||
#初始化文件目录
|
||||
[ -f "$clashdir/mark" ] || echo '#标识clash运行状态的文件,不明勿动!' > $clashdir/mark
|
||||
#判断系统类型写入不同的启动文件
|
||||
if [ -f /etc/rc.common ];then
|
||||
#设为init.d方式启动
|
||||
mv $clashdir/clashservice /etc/init.d/clash
|
||||
chmod 777 /etc/init.d/clash
|
||||
else
|
||||
[ -w /etc/systemd/system ] && sysdir=/etc/systemd/system
|
||||
[ -w /usr/lib/systemd/system ] && sysdir=/usr/lib/systemd/system
|
||||
if [ -n "$sysdir" ];then
|
||||
#设为systemd方式启动
|
||||
mv $clashdir/clash.service $sysdir/clash.service
|
||||
sed -i "s%/etc/clash%$clashdir%g" $sysdir/clash.service
|
||||
systemctl daemon-reload
|
||||
else
|
||||
#设为保守模式启动
|
||||
sed -i '/start_old=*/'d $clashdir/mark
|
||||
echo start_old=已开启 >> $clashdir/mark
|
||||
fi
|
||||
fi
|
||||
#修饰文件及版本号
|
||||
shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash
|
||||
sed -i "s|/bin/sh|/bin/$shtype|" $clashdir/start.sh
|
||||
chmod 777 $clashdir/start.sh
|
||||
sed -i '/versionsh_l=*/'d $clashdir/mark
|
||||
echo versionsh_l=$release_new >> $clashdir/mark
|
||||
#设置更新地址
|
||||
sed -i '/update_url=*/'d $clashdir/mark
|
||||
echo update_url=$url >> $clashdir/mark
|
||||
#设置环境变量
|
||||
[ -w /opt/etc/profile ] && profile=/opt/etc/profile
|
||||
[ -w /jffs/configs/profile.add ] && profile=/jffs/configs/profile.add
|
||||
[ -w ~/.bashrc ] && profile=~/.bashrc
|
||||
[ -w /etc/profile ] && profile=/etc/profile
|
||||
if [ -n "$profile" ];then
|
||||
sed -i '/alias clash=*/'d $profile
|
||||
echo "alias clash=\"$shtype $clashdir/clash.sh\"" >> $profile #设置快捷命令环境变量
|
||||
sed -i '/export clashdir=*/'d $profile
|
||||
echo "export clashdir=\"$clashdir\"" >> $profile #设置clash路径环境变量
|
||||
else
|
||||
echo 无法写入环境变量!请检查安装权限!
|
||||
exit 1
|
||||
fi
|
||||
#华硕/Padavan额外设置
|
||||
[ -n "$systype" ] && sed -i '/ShellClash初始化/'d $initdir && echo "$clashdir/start.sh init #ShellClash初始化脚本" >> $initdir
|
||||
#删除临时文件
|
||||
rm -rf /tmp/clashfm.tar.gz
|
||||
rm -rf $clashdir/clashservice
|
||||
rm -rf $clashdir/clash.service
|
||||
}
|
||||
#下载及安装
|
||||
install(){
|
||||
echo -----------------------------------------------
|
||||
echo 开始从服务器获取安装文件!
|
||||
echo -----------------------------------------------
|
||||
gettar
|
||||
echo -----------------------------------------------
|
||||
echo ShellClash 已经安装成功!
|
||||
[ "$profile" = "~/.bashrc" ] && echo "请执行【source ~/.bashrc &> /dev/null】命令以加载环境变量!"
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理!!!\033[0m"
|
||||
echo -----------------------------------------------
|
||||
}
|
||||
setdir(){
|
||||
if [ -n "$systype" ];then
|
||||
[ "$systype" = "Padavan" ] && dir=/etc/storage
|
||||
[ "$systype" = "asusrouter" ] && dir=/jffs
|
||||
else
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[33m安装ShellClash至少需要预留约1MB的磁盘空间\033[0m"
|
||||
$echo " 1 在\033[32m/etc目录\033[0m下安装(适合root用户)"
|
||||
$echo " 2 在\033[32m/usr/share目录\033[0m下安装(适合Linux设备)"
|
||||
$echo " 3 在\033[32m当前用户目录\033[0m下安装(适合非root用户)"
|
||||
$echo " 4 手动设置安装目录"
|
||||
$echo " 0 退出安装"
|
||||
echo -----------------------------------------------
|
||||
read -p "请输入相应数字 > " num
|
||||
#设置目录
|
||||
if [ -z $num ];then
|
||||
echo 安装已取消
|
||||
exit;
|
||||
elif [ "$num" = "1" ];then
|
||||
dir=/etc
|
||||
elif [ "$num" = "2" ];then
|
||||
dir=/usr/share
|
||||
elif [ "$num" = "3" ];then
|
||||
dir=~/.local/share
|
||||
mkdir -p ~/.config/systemd/user
|
||||
elif [ "$num" = "4" ];then
|
||||
echo -----------------------------------------------
|
||||
echo '可用路径 剩余空间:'
|
||||
df -h | awk '{print $6,$4}'| sed 1d
|
||||
echo '路径是必须带 / 的格式,注意写入虚拟内存(/tmp,/opt,/sys...)的文件会在重启后消失!!!'
|
||||
read -p "请输入自定义路径 > " dir
|
||||
if [ -z "$dir" ];then
|
||||
$echo "\033[31m路径错误!请重新设置!\033[0m"
|
||||
setdir
|
||||
fi
|
||||
else
|
||||
echo 安装已取消!!!
|
||||
exit;
|
||||
fi
|
||||
fi
|
||||
if [ ! -w $dir ];then
|
||||
$echo "\033[31m没有$dir目录写入权限!请重新设置!\033[0m" && sleep 1 && setdir
|
||||
else
|
||||
$echo "目标目录\033[32m$dir\033[0m空间剩余:$(df -h $dir | awk '{print $4}' | sed 1d )"
|
||||
read -p "确认安装?(1/0) > " res
|
||||
[ "$res" = "1" ] && clashdir=$dir/clash || setdir
|
||||
fi
|
||||
}
|
||||
|
||||
#输出
|
||||
$echo "最新版本:\033[32m$release_new\033[0m"
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[44m如遇问题请加TG群反馈:\033[42;30m t.me/clashfm \033[0m"
|
||||
$echo "\033[37m支持各种基于openwrt的路由器设备"
|
||||
$echo "\033[33m支持Debian、Centos等标准Linux系统\033[0m"
|
||||
|
||||
if [ -n "$clashdir" ];then
|
||||
echo -----------------------------------------------
|
||||
$echo "检测到旧的安装目录\033[36m$clashdir\033[0m,是否覆盖安装?"
|
||||
$echo "\033[32m覆盖安装时不会移除配置文件!\033[0m"
|
||||
read -p "覆盖安装/卸载旧版本?(1/0) > " res
|
||||
if [ "$res" = "1" ];then
|
||||
install
|
||||
elif [ "$res" = "0" ];then
|
||||
rm -rf $clashdir
|
||||
echo -----------------------------------------------
|
||||
$echo "\033[31m 旧版本文件已卸载!\033[0m"
|
||||
setdir
|
||||
install
|
||||
elif [ "$res" = "9" ];then
|
||||
echo 测试模式,变更安装位置
|
||||
setdir
|
||||
install
|
||||
else
|
||||
$echo "\033[31m输入错误!已取消安装!\033[0m"
|
||||
exit;
|
||||
fi
|
||||
else
|
||||
setdir
|
||||
install
|
||||
fi
|
||||
89
rules/ACL4SSR_Online_Full_Games.ini
Normal file
89
rules/ACL4SSR_Online_Full_Games.ini
Normal file
@@ -0,0 +1,89 @@
|
||||
[custom]
|
||||
;不要随意改变关键字,否则会导致出错
|
||||
;acl4SSR规则
|
||||
|
||||
;去广告:支持
|
||||
;自动测速:支持
|
||||
;微软分流:支持
|
||||
;苹果分流:支持
|
||||
;增强中国IP段:支持
|
||||
;增强国外GFW:支持
|
||||
|
||||
;设置规则标志位
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/LocalAreaNetwork.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/UnBan.list
|
||||
ruleset=🛑 广告拦截,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/BanAD.list
|
||||
ruleset=🍃 应用净化,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/BanProgramAD.list
|
||||
ruleset=📢 谷歌FCM,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/GoogleFCM.list
|
||||
ruleset=📢 谷歌🇨🇳Play下载,[]DOMAIN-SUFFIX,xn--ngstr-lra8j.com
|
||||
ruleset=📢 谷歌🇨🇳Play服务,[]DOMAIN-SUFFIX,services.googleapis.cn
|
||||
ruleset=📢 谷歌🇨🇳Play服务,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/GoogleCNProxyIP.list
|
||||
ruleset=📢 谷歌🇨🇳,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/GoogleCN.list
|
||||
ruleset=📹 油管视频,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/YouTube.list
|
||||
ruleset=📢 谷歌,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/Google.list
|
||||
ruleset=Ⓜ️ 微软云盘,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/OneDrive.list
|
||||
ruleset=Ⓜ️ 微软服务,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Microsoft.list
|
||||
ruleset=🍎 苹果服务,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Apple.list
|
||||
ruleset=📲 电报消息,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Telegram.list
|
||||
ruleset=🎶 网易音乐,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/NetEaseMusic.list
|
||||
ruleset=🎮 游戏平台,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/Epic.list
|
||||
ruleset=🎮 游戏平台,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/Sony.list
|
||||
ruleset=🎮 游戏平台,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/Steam.list
|
||||
ruleset=🎮 游戏服务,https://raw.githubusercontent.com/LM-Firefly/Rules/master/Game.list
|
||||
ruleset=🎥 奈飞视频,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/Netflix.list
|
||||
ruleset=📺 巴哈姆特,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/Bahamut.list
|
||||
ruleset=📺 哔哩哔哩,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/Bilibili.list
|
||||
ruleset=📺 哔哩哔哩,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/BilibiliHMT.list
|
||||
ruleset=🌏 国内媒体,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ChinaMedia.list
|
||||
ruleset=🌍 国外媒体,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ProxyMedia.list
|
||||
ruleset=🚀 节点选择,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ProxyGFWlist.list
|
||||
;ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ChinaIp.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ChinaDomain.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ChinaCompanyIp.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Download.list
|
||||
ruleset=🎯 全球直连,[]GEOIP,CN
|
||||
ruleset=🐟 漏网之鱼,[]FINAL
|
||||
;设置规则标志位
|
||||
|
||||
;设置分组标志位
|
||||
custom_proxy_group=🚀 节点选择`select`[]♻️ 自动选择`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇸🇬 狮城节点`[]🇯🇵 日本节点`[]🇺🇲 美国节点`[]🇰🇷 韩国节点`[]🚀 手动切换`[]DIRECT
|
||||
custom_proxy_group=🚀 手动切换`select`.*
|
||||
custom_proxy_group=♻️ 自动选择`url-test`.*`http://www.gstatic.com/generate_204`300,,50
|
||||
custom_proxy_group=📲 电报消息`select`[]🚀 节点选择`[]♻️ 自动选择`[]🇸🇬 狮城节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇯🇵 日本节点`[]🇺🇲 美国节点`[]🇰🇷 韩国节点`[]🚀 手动切换`[]DIRECT
|
||||
custom_proxy_group=📢 谷歌FCM`select`[]DIRECT`[]🚀 节点选择`[]🇺🇲 美国节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇸🇬 狮城节点`[]🇯🇵 日本节点`[]🇰🇷 韩国节点`[]🚀 手动切换
|
||||
custom_proxy_group=📢 谷歌🇨🇳Play下载`select`[]🚀 节点选择`[]DIRECT`[]♻️ 自动选择`[]🇸🇬 狮城节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇯🇵 日本节点`[]🇺🇲 美国节点`[]🇰🇷 韩国节点`[]🚀 手动切换
|
||||
custom_proxy_group=📢 谷歌🇨🇳Play服务`select`[]🚀 节点选择`[]DIRECT`[]♻️ 自动选择`[]🇸🇬 狮城节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇯🇵 日本节点`[]🇺🇲 美国节点`[]🇰🇷 韩国节点`[]🚀 手动切换
|
||||
custom_proxy_group=📢 谷歌🇨🇳`select`[]DIRECT`[]🚀 节点选择`[]🇺🇲 美国节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇸🇬 狮城节点`[]🇯🇵 日本节点`[]🇰🇷 韩国节点`[]🚀 手动切换
|
||||
custom_proxy_group=📢 谷歌`select`[]🚀 节点选择`[]DIRECT`[]♻️ 自动选择`[]🇸🇬 狮城节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇯🇵 日本节点`[]🇺🇲 美国节点`[]🇰🇷 韩国节点`[]🚀 手动切换
|
||||
custom_proxy_group=📹 油管视频`select`[]🚀 节点选择`[]♻️ 自动选择`[]🇸🇬 狮城节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇯🇵 日本节点`[]🇺🇲 美国节点`[]🇰🇷 韩国节点`[]🚀 手动切换`[]DIRECT
|
||||
custom_proxy_group=🎥 奈飞视频`select`[]🎥 奈飞节点`[]🚀 节点选择`[]♻️ 自动选择`[]🇸🇬 狮城节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇯🇵 日本节点`[]🇺🇲 美国节点`[]🇰🇷 韩国节点`[]🚀 手动切换`[]DIRECT
|
||||
custom_proxy_group=📺 巴哈姆特`select`[]🇨🇳 台湾节点`[]🚀 节点选择`[]🚀 手动切换`[]DIRECT
|
||||
custom_proxy_group=📺 哔哩哔哩`select`[]🎯 全球直连`[]🇨🇳 台湾节点`[]🇭🇰 香港节点
|
||||
custom_proxy_group=🌍 国外媒体`select`[]🚀 节点选择`[]♻️ 自动选择`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇸🇬 狮城节点`[]🇯🇵 日本节点`[]🇺🇲 美国节点`[]🇰🇷 韩国节点`[]🚀 手动切换`[]DIRECT
|
||||
custom_proxy_group=🌏 国内媒体`select`[]DIRECT`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇸🇬 狮城节点`[]🇯🇵 日本节点`[]🚀 手动切换
|
||||
custom_proxy_group=Ⓜ️ 微软云盘`select`[]DIRECT`[]🚀 节点选择`[]🇺🇲 美国节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇸🇬 狮城节点`[]🇯🇵 日本节点`[]🇰🇷 韩国节点`[]🚀 手动切换
|
||||
custom_proxy_group=Ⓜ️ 微软服务`select`[]DIRECT`[]🚀 节点选择`[]🇺🇲 美国节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇸🇬 狮城节点`[]🇯🇵 日本节点`[]🇰🇷 韩国节点`[]🚀 手动切换
|
||||
custom_proxy_group=🍎 苹果服务`select`[]DIRECT`[]🚀 节点选择`[]🇺🇲 美国节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇸🇬 狮城节点`[]🇯🇵 日本节点`[]🇰🇷 韩国节点`[]🚀 手动切换
|
||||
custom_proxy_group=🎮 游戏平台`select`[]DIRECT`[]🚀 节点选择`[]🇺🇲 美国节点`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇸🇬 狮城节点`[]🇯🇵 日本节点`[]🇰🇷 韩国节点`[]🚀 手动切换
|
||||
custom_proxy_group=🎮 游戏服务`select`[]🎮 游戏节点`[]🎯 全球直连`.*
|
||||
custom_proxy_group=🎶 网易音乐`select`[]DIRECT`[]🚀 节点选择`[]♻️ 自动选择`(网易|音乐|解锁|Music|NetEase)
|
||||
custom_proxy_group=🎯 全球直连`select`[]DIRECT`[]🚀 节点选择`[]♻️ 自动选择
|
||||
custom_proxy_group=🛑 广告拦截`select`[]REJECT`[]DIRECT
|
||||
custom_proxy_group=🍃 应用净化`select`[]REJECT`[]DIRECT
|
||||
custom_proxy_group=🐟 漏网之鱼`select`[]🚀 节点选择`[]♻️ 自动选择`[]DIRECT`[]🇭🇰 香港节点`[]🇨🇳 台湾节点`[]🇸🇬 狮城节点`[]🇯🇵 日本节点`[]🇺🇲 美国节点`[]🇰🇷 韩国节点`[]🚀 手动切换
|
||||
custom_proxy_group=🎮 游戏节点`select`(游戏|Game|game|加速)`
|
||||
custom_proxy_group=🇭🇰 香港节点`url-test`(港|HK|Hong Kong)`http://www.gstatic.com/generate_204`300,,50
|
||||
custom_proxy_group=🇯🇵 日本节点`url-test`(日本|川日|东京|大阪|泉日|埼玉|沪日|深日|[^-]日|JP|Japan)`http://www.gstatic.com/generate_204`300,,50
|
||||
custom_proxy_group=🇺🇲 美国节点`url-test`(美|波特兰|达拉斯|俄勒冈|凤凰城|费利蒙|硅谷|拉斯维加斯|洛杉矶|圣何塞|圣克拉拉|西雅图|芝加哥|US|United States)`http://www.gstatic.com/generate_204`300,,150
|
||||
custom_proxy_group=🇨🇳 台湾节点`url-test`(台|新北|彰化|TW|Taiwan)`http://www.gstatic.com/generate_204`300,,50
|
||||
custom_proxy_group=🇸🇬 狮城节点`url-test`(新加坡|坡|狮城|SG|Singapore)`http://www.gstatic.com/generate_204`300,,50
|
||||
custom_proxy_group=🇰🇷 韩国节点`url-test`(KR|Korea|KOR|首尔|韩|韓)`http://www.gstatic.com/generate_204`300,,50
|
||||
custom_proxy_group=🎥 奈飞节点`select`(NF|奈飞|解锁|Netflix|NETFLIX|Media)
|
||||
;设置分组标志位
|
||||
|
||||
enable_rule_generator=true
|
||||
overwrite_original_rules=true
|
||||
|
||||
;clash_rule_base=https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/GeneralClashConfig.yml
|
||||
|
||||
;luck
|
||||
45
rules/ACL4SSR_Online_Games.ini
Normal file
45
rules/ACL4SSR_Online_Games.ini
Normal file
@@ -0,0 +1,45 @@
|
||||
[custom]
|
||||
;不要随意改变关键字,否则会导致出错
|
||||
;acl4SSR规则-在线更新版
|
||||
|
||||
;去广告:支持
|
||||
;自动测速:支持
|
||||
;微软分流:支持
|
||||
;苹果分流:支持
|
||||
;增强中国IP段:不支持
|
||||
;增强国外GFW:不支持
|
||||
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/LocalAreaNetwork.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/UnBan.list
|
||||
ruleset=🛑 全球拦截,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/BanAD.list
|
||||
ruleset=🍃 应用净化,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/BanProgramAD.list
|
||||
ruleset=📢 谷歌FCM,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Ruleset/GoogleFCM.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/GoogleCN.list
|
||||
ruleset=Ⓜ️ 微软服务,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Microsoft.list
|
||||
ruleset=🍎 苹果服务,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Apple.list
|
||||
ruleset=📲 电报信息,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Telegram.list
|
||||
ruleset=🌍 国外媒体,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ProxyMedia.list
|
||||
ruleset=🚀 节点选择,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ProxyLite.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ChinaDomain.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ChinaCompanyIp.list
|
||||
ruleset=🎮 游戏服务,https://raw.githubusercontent.com/LM-Firefly/Rules/master/Game.list
|
||||
ruleset=🎯 全球直连,[]GEOIP,CN
|
||||
ruleset=🐟 漏网之鱼,[]FINAL
|
||||
|
||||
custom_proxy_group=🚀 节点选择`select`[]♻️ 自动选择`[]DIRECT`.*
|
||||
custom_proxy_group=♻️ 自动选择`url-test`.*`http://www.gstatic.com/generate_204`300,,50
|
||||
custom_proxy_group=🎮 游戏服务`select`[]🎮 游戏节点`[]🎯 全球直连`.*
|
||||
custom_proxy_group=🎮 游戏节点`select`(游戏|Game|game|加速)`
|
||||
custom_proxy_group=🌍 国外媒体`select`[]🚀 节点选择`[]♻️ 自动选择`[]🎯 全球直连`.*
|
||||
custom_proxy_group=📲 电报信息`select`[]🚀 节点选择`[]🎯 全球直连`.*
|
||||
custom_proxy_group=Ⓜ️ 微软服务`select`[]🎯 全球直连`[]🚀 节点选择`.*
|
||||
custom_proxy_group=🍎 苹果服务`select`[]🚀 节点选择`[]🎯 全球直连`.*
|
||||
custom_proxy_group=📢 谷歌FCM`select`[]🚀 节点选择`[]🎯 全球直连`[]♻️ 自动选择`.*
|
||||
custom_proxy_group=🎯 全球直连`select`[]DIRECT`[]🚀 节点选择`[]♻️ 自动选择
|
||||
custom_proxy_group=🛑 全球拦截`select`[]REJECT`[]DIRECT
|
||||
custom_proxy_group=🍃 应用净化`select`[]REJECT`[]DIRECT
|
||||
custom_proxy_group=🐟 漏网之鱼`select`[]🚀 节点选择`[]🎯 全球直连`[]♻️ 自动选择`.*
|
||||
|
||||
enable_rule_generator=true
|
||||
overwrite_original_rules=true
|
||||
|
||||
35
rules/ACL4SSR_Online_Mini_Games.ini
Normal file
35
rules/ACL4SSR_Online_Mini_Games.ini
Normal file
@@ -0,0 +1,35 @@
|
||||
[custom]
|
||||
;不要随意改变关键字,否则会导致出错
|
||||
;acl4SSR规则-在线版
|
||||
|
||||
;去广告:支持
|
||||
;自动测速:支持
|
||||
;微软分流:不支持
|
||||
;苹果分流:不支持
|
||||
;增强中国IP段:不支持
|
||||
;增强国外GFW:不支持
|
||||
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/LocalAreaNetwork.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/UnBan.list
|
||||
ruleset=🛑 全球拦截,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/BanAD.list
|
||||
ruleset=🛑 全球拦截,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/BanProgramAD.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/GoogleCN.list
|
||||
ruleset=🚀 节点选择,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/Telegram.list
|
||||
ruleset=🚀 节点选择,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ProxyMedia.list
|
||||
ruleset=🚀 节点选择,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ProxyLite.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ChinaDomain.list
|
||||
ruleset=🎯 全球直连,https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/ChinaCompanyIp.list
|
||||
ruleset=🎮 游戏服务,https://raw.githubusercontent.com/LM-Firefly/Rules/master/Game.list
|
||||
ruleset=🎯 全球直连,[]GEOIP,CN
|
||||
ruleset=🐟 漏网之鱼,[]FINAL
|
||||
|
||||
custom_proxy_group=🚀 节点选择`select`[]♻️ 自动选择`[]DIRECT`.*
|
||||
custom_proxy_group=♻️ 自动选择`url-test`.*`http://www.gstatic.com/generate_204`300,,50
|
||||
custom_proxy_group=🎮 游戏服务`select`[]🎮 游戏节点`[]🎯 全球直连`.*
|
||||
custom_proxy_group=🎮 游戏节点`select`(游戏|Game|game|加速)`
|
||||
custom_proxy_group=🎯 全球直连`select`[]DIRECT`[]🚀 节点选择`[]♻️ 自动选择
|
||||
custom_proxy_group=🛑 全球拦截`select`[]REJECT`[]DIRECT
|
||||
custom_proxy_group=🐟 漏网之鱼`select`[]🚀 节点选择`[]🎯 全球直连`[]♻️ 自动选择`.*
|
||||
|
||||
enable_rule_generator=true
|
||||
overwrite_original_rules=true
|
||||
15
scripts/clash.service
Normal file
15
scripts/clash.service
Normal file
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=clash
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
ExecStart=/etc/clash/clash -d /etc/clash
|
||||
ExecStartPost=/etc/clash/start.sh afstart
|
||||
Restart=on-failure
|
||||
RestartSec=3s
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
1971
scripts/clash.sh
1971
scripts/clash.sh
File diff suppressed because it is too large
Load Diff
@@ -1,146 +1,41 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Example script
|
||||
# Copyright (C) 2007 OpenWrt.org
|
||||
|
||||
START=101
|
||||
|
||||
SERVICE_DAEMONIZE=1
|
||||
SERVICE_WRITE_PID=1
|
||||
USE_PROCD=1
|
||||
START=99
|
||||
#获取目录
|
||||
DIR=$(cat /etc/profile | grep clashdir | awk -F "\"" '{print $2}')
|
||||
[ -z "$DIR" ] && DIR=$(cat ~/.bashrc | grep clashdir | awk -F "\"" '{print $2}')
|
||||
BINDIR=$(cat $DIR/mark | grep bindir | awk -F "=" '{print $2}')
|
||||
[ -z "$BINDIR" ] && BINDIR=$DIR
|
||||
|
||||
getconfig(){
|
||||
#开机加载环境变量保证找到文件路径
|
||||
source /etc/profile > /dev/null 2>&1
|
||||
ccfg=$clashdir/mark
|
||||
if [ ! -f "$ccfg" ]; then
|
||||
echo mark文件不存在,默认以Redir模式运行!
|
||||
cat >$ccfg<<EOF
|
||||
#标识clash运行状态的文件,不明勿动!
|
||||
EOF
|
||||
#指定一些默认状态
|
||||
redir_mod=redir模式
|
||||
common_ports=未开启
|
||||
dns_mod=redir-host
|
||||
modify_yaml=未开启
|
||||
ipv6_support=未开启
|
||||
fi
|
||||
source $ccfg #加载配置文件
|
||||
#是否代理常用端口
|
||||
if [ "$common_ports" = "已开启" ];then
|
||||
ports='-m multiport --dports 22,53,587,465,995,993,143,80,443 '
|
||||
fi
|
||||
#DNS模式
|
||||
if [ "$common_ports" = "已开启" ];then
|
||||
ports='-m multiport --dports 22,53,587,465,995,993,143,80,443 '
|
||||
fi
|
||||
}
|
||||
modify_yaml(){
|
||||
##########需要变更的配置###########
|
||||
mix='mixed-port: 7890'
|
||||
redir='redir-port: 7892'
|
||||
lan='allow-lan: true'
|
||||
mode='mode: Rule'
|
||||
log='log-level: info'
|
||||
if [ "$ipv6_support" = "已开启" ];then
|
||||
ipv6='ipv6: true'
|
||||
else
|
||||
ipv6='ipv6: false'
|
||||
fi
|
||||
external='external-controller: 0.0.0.0:9999'
|
||||
if [ "$dns_mod" = "fake-ip" ];then
|
||||
dns='dns: {enable: true, listen: 0.0.0.0:1053, fake-ip-range: 198.18.0.1/16, enhanced-mode: fake-ip, nameserver: [114.114.114.114, 127.0.0.1:53], fallback: [tcp://1.0.0.1, 8.8.4.4]}'
|
||||
else
|
||||
dns='dns: {enable: true, ipv6: true, listen: 0.0.0.0:1053, enhanced-mode: redir-host, nameserver: [114.114.114.114, 127.0.0.1:53], fallback: [1.0.0.1, 8.8.4.4]}'
|
||||
fi
|
||||
if [ "$redir_mod" != "Redir模式" ];then
|
||||
tun='tun: {enable: true, stack: system}'
|
||||
else
|
||||
tun='tun: {enable: false}'
|
||||
fi
|
||||
exper='experimental: {ignore-resolve-fail: true, interface-name: en0}'
|
||||
###################################
|
||||
#预删除需要添加的项目
|
||||
i=$(grep -n "^proxies:" $clashdir/config.yaml | head -1 | cut -d ":" -f 1)
|
||||
i=$(($i-1))
|
||||
sed -i '1,'$i'd' $clashdir/config.yaml
|
||||
#添加配置
|
||||
sed -i "1i$mix" $clashdir/config.yaml
|
||||
sed -i "1a$redir" $clashdir/config.yaml
|
||||
sed -i "2a$lan" $clashdir/config.yaml
|
||||
sed -i "3a$mode" $clashdir/config.yaml
|
||||
sed -i "4a$log" $clashdir/config.yaml
|
||||
sed -i "5a$ipv6" $clashdir/config.yaml
|
||||
sed -i "6a$external" $clashdir/config.yaml
|
||||
sed -i "7a$dns" $clashdir/config.yaml
|
||||
sed -i "8a$tun" $clashdir/config.yaml
|
||||
sed -i "9a$exper" $clashdir/config.yaml
|
||||
#跳过本地tls证书验证
|
||||
if [ "$skip_cert" != "未开启" ];then
|
||||
sed -i "10,99s/sni: \S*/\1skip-cert-verify: true}/" $clashdir/config.yaml #跳过trojan本地证书验证
|
||||
sed -i '10,99s/}}/}, skip-cert-verify: true}/' $clashdir/config.yaml #跳过v2+ssl本地证书验证
|
||||
fi
|
||||
#sed -i '/rules:/a \ - DOMAIN-SUFFIX,clash.razord.top,🎯 全球直连' $clashdir/config.yaml
|
||||
}
|
||||
mark_time(){
|
||||
start_time=`date +%s`
|
||||
sed -i '/start_time*/'d $ccfg
|
||||
sed -i "3i\start_time=$start_time" $ccfg
|
||||
}
|
||||
start_redir(){
|
||||
#修改iptables规则使流量进入clash
|
||||
iptables -t nat -N clash
|
||||
iptables -t nat -A clash -d 0.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A clash -d 10.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A clash -d 127.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A clash -d 169.254.0.0/16 -j RETURN
|
||||
iptables -t nat -A clash -d 172.16.0.0/12 -j RETURN
|
||||
iptables -t nat -A clash -d 192.168.0.0/16 -j RETURN
|
||||
iptables -t nat -A clash -d 224.0.0.0/4 -j RETURN
|
||||
iptables -t nat -A clash -d 240.0.0.0/4 -j RETURN
|
||||
iptables -t nat -A clash -p tcp $ports-j REDIRECT --to-ports 7892
|
||||
iptables -t nat -A PREROUTING -p tcp -j clash
|
||||
if [ "$ipv6_support" = "已开启" ];then
|
||||
ip6tables -t nat -N clashv6
|
||||
ip6tables -t nat -A clashv6 -p tcp $ports-j REDIRECT --to-ports 7892
|
||||
ip6tables -t nat -A PREROUTING -p tcp -j clashv6
|
||||
fi
|
||||
}
|
||||
stop_iptables(){
|
||||
#重置iptables规则
|
||||
iptables -t nat -D PREROUTING -p tcp -j clash > /dev/null 2>&1
|
||||
iptables -t nat -F clash > /dev/null 2>&1
|
||||
iptables -t nat -X clash > /dev/null 2>&1
|
||||
iptables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 > /dev/null 2>&1
|
||||
ip6tables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 > /dev/null 2>&1
|
||||
ip6tables -t nat -D PREROUTING -p tcp -j clashv6 > /dev/null 2>&1
|
||||
ip6tables -t nat -F clashv6 > /dev/null 2>&1
|
||||
ip6tables -t nat -X clashv6 > /dev/null 2>&1
|
||||
}
|
||||
start_dns(){
|
||||
#允许tun网卡接受流量
|
||||
iptables -I FORWARD -o utun -j ACCEPT
|
||||
#设置dns转发
|
||||
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||
ip6tables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
|
||||
}
|
||||
start_service() {
|
||||
getconfig
|
||||
#使用内置规则强行覆盖config配置文件
|
||||
if [ "$modify_yaml" != "已开启" ];then
|
||||
modify_yaml
|
||||
fi
|
||||
#创建clash后台进程
|
||||
#检测必须文件
|
||||
$DIR/start.sh bfstart
|
||||
#使用procd创建clash后台进程
|
||||
procd_open_instance
|
||||
procd_set_param respawn
|
||||
procd_set_param stderr 1
|
||||
procd_set_param stdout 1
|
||||
procd_set_param command $clashdir/clash -d $clashdir
|
||||
procd_set_param command $BINDIR/clash -d $BINDIR
|
||||
procd_close_instance
|
||||
#修改iptables规则使流量进入clash
|
||||
stop_iptables
|
||||
start_dns
|
||||
if [ "$redir_mod" != "Tun模式" ];then
|
||||
start_redir
|
||||
fi
|
||||
mark_time
|
||||
#其他设置
|
||||
$DIR/start.sh afstart
|
||||
}
|
||||
stop_service() {
|
||||
stop_iptables
|
||||
|
||||
start() {
|
||||
if [ -z "$(pidof procd)" ];then
|
||||
#检测必须文件
|
||||
$DIR/start.sh bfstart
|
||||
#创建后台进程
|
||||
service_start $BINDIR/clash -d $BINDIR
|
||||
#其他设置
|
||||
$DIR/start.sh afstart
|
||||
#设置守护进程
|
||||
$DIR/start.sh deamon
|
||||
else
|
||||
start_service
|
||||
fi
|
||||
}
|
||||
1416
scripts/getdate.sh
1416
scripts/getdate.sh
File diff suppressed because it is too large
Load Diff
840
scripts/start.sh
Normal file
840
scripts/start.sh
Normal file
@@ -0,0 +1,840 @@
|
||||
#!/bin/sh
|
||||
# Copyright (C) Juewuy
|
||||
|
||||
#脚本内部工具
|
||||
getconfig(){
|
||||
#加载配置文件
|
||||
[ -d "/etc/storage/clash" ] && clashdir=/etc/storage/clash
|
||||
[ -d "/jffs/clash" ] && clashdir=/jffs/clash
|
||||
[ -z "$clashdir" ] && clashdir=$(cat /etc/profile | grep clashdir | awk -F "\"" '{print $2}')
|
||||
[ -z "$clashdir" ] && clashdir=$(cat ~/.bashrc | grep clashdir | awk -F "\"" '{print $2}')
|
||||
ccfg=$clashdir/mark
|
||||
[ -f $ccfg ] && source $ccfg
|
||||
#默认设置
|
||||
[ -z "$bindir" ] && bindir=$clashdir
|
||||
[ -z "$redir_mod" ] && [ "$USER" = "root" -o "$USER" = "admin" ] && redir_mod=Redir模式
|
||||
[ -z "$redir_mod" ] && redir_mod=Redir模式
|
||||
[ -z "$skip_cert" ] && skip_cert=已开启
|
||||
[ -z "$common_ports" ] && common_ports=已开启
|
||||
[ -z "$dns_mod" ] && dns_mod=redir_host
|
||||
[ -z "$dns_over" ] && dns_over=已开启
|
||||
[ -z "$modify_yaml" ] && modify_yaml=未开启
|
||||
[ -z "$ipv6_support" ] && ipv6_support=未开启
|
||||
[ -z "$start_old" ] && start_old=未开启
|
||||
[ -z "$local_proxy" ] && local_proxy=未开启
|
||||
[ -z "$mix_port" ] && mix_port=7890
|
||||
[ -z "$redir_port" ] && redir_port=7892
|
||||
[ -z "$db_port" ] && db_port=9999
|
||||
[ -z "$dns_port" ] && dns_port=1053
|
||||
[ -z "$cn_ip_route" ] && cn_ip_route=未开启
|
||||
[ -z "$public_support" ] && public_support=未开启
|
||||
[ -z "$dns_nameserver" ] && dns_nameserver='114.114.114.114, 223.5.5.5'
|
||||
[ -z "$dns_fallback" ] && dns_fallback='1.0.0.1, 8.8.4.4'
|
||||
[ -z "$multiport" ] && multiport='22,53,587,465,995,993,143,80,443,8080'
|
||||
#是否代理常用端口
|
||||
[ "$common_ports" = "已开启" ] && ports="-m multiport --dports $multiport"
|
||||
}
|
||||
setconfig(){
|
||||
#参数1代表变量名,参数2代表变量值,参数3即文件路径
|
||||
[ -z "$3" ] && configpath=$clashdir/mark || configpath=$3
|
||||
[ -n "$(grep ${1} $configpath)" ] && sed -i "s#${1}=.*#${1}=${2}#g" $configpath || echo "${1}=${2}" >> $configpath
|
||||
}
|
||||
compare(){
|
||||
if [ ! -f $1 -o ! -f $2 ];then
|
||||
return 1
|
||||
elif command -v cmp >/dev/null 2>&1;then
|
||||
cmp -s $1 $2
|
||||
else
|
||||
[ "$(cat $1)" = "$(cat $2)" ] && return 0 || return 1
|
||||
fi
|
||||
}
|
||||
logger(){
|
||||
[ -n "$2" ] && echo -e "\033[$2m$1\033[0m"
|
||||
echo `date "+%G-%m-%d %H:%M:%S"` $1 >> $clashdir/log
|
||||
[ "$(wc -l $clashdir/log | awk '{print $1}')" -gt 30 ] && sed -i '1,5d' $clashdir/log
|
||||
}
|
||||
croncmd(){
|
||||
if [ -n "$(crontab -h 2>&1 | grep '\-l')" ];then
|
||||
crontab $1
|
||||
else
|
||||
crondir="$(crond -h 2>&1 | grep -oE 'Default:.*' | awk -F ":" '{print $2}')"
|
||||
[ ! -w "$crondir" ] && crondir="/etc/storage/cron/crontabs"
|
||||
[ ! -w "$crondir" ] && crondir="/var/spool/cron/crontabs"
|
||||
[ ! -w "$crondir" ] && crondir="/var/spool/cron"
|
||||
[ ! -w "$crondir" ] && echo "你的设备不支持定时任务配置,脚本大量功能无法启用,请前往 https://t.me/clashfm 申请适配!"
|
||||
[ "$1" = "-l" ] && cat $crondir/$USER 2>/dev/null
|
||||
[ -f "$1" ] && cat $1 > $crondir/$USER
|
||||
fi
|
||||
}
|
||||
cronset(){
|
||||
# 参数1代表要移除的关键字,参数2代表要添加的任务语句
|
||||
tmpcron=/tmp/cron_$USER
|
||||
croncmd -l > $tmpcron
|
||||
sed -i "/$1/d" $tmpcron
|
||||
sed -i '/^$/d' $tmpcron
|
||||
echo "$2" >> $tmpcron
|
||||
croncmd $tmpcron
|
||||
rm -f $tmpcron
|
||||
}
|
||||
mark_time(){
|
||||
start_time=`date +%s`
|
||||
sed -i '/start_time*/'d $clashdir/mark
|
||||
echo start_time=$start_time >> $clashdir/mark
|
||||
}
|
||||
gethost(){
|
||||
[ -z "$host" ] && host=$(ubus call network.interface.lan status 2>&1 | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';)
|
||||
[ -z "$host" ] && host=$(ip a 2>&1 | grep -w 'inet' | grep 'global' | grep -E '\ 1(92|0|72)\.' | sed 's/.*inet.//g' | sed 's/\/[0-9][0-9].*$//g' | head -n 1)
|
||||
[ -n "$host" ] && lanhost="-s $(echo $host | grep -oE '^1(92|0|72)\.')0.0.0/8"
|
||||
}
|
||||
#配置文件相关
|
||||
getyaml(){
|
||||
[ -z "$rule_link" ] && rule_link=1
|
||||
[ -z "$server_link" ] && server_link=1
|
||||
#前后端订阅服务器地址索引,可在此处添加!
|
||||
Server=`sed -n ""$server_link"p"<<EOF
|
||||
subcon.dlj.tf
|
||||
api.dler.io
|
||||
api.wcc.best
|
||||
api2.tsutsu.cc
|
||||
api.v1.mk
|
||||
EOF`
|
||||
Config=`sed -n ""$rule_link"p"<<EOF
|
||||
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_NoReject.ini
|
||||
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_MultiMode.ini
|
||||
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_AdblockPlus.ini
|
||||
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_AdblockPlus.ini
|
||||
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_Netflix.ini
|
||||
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_AdblockPlus.ini
|
||||
https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/lhie1_clash.ini
|
||||
https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/lhie1_dler.ini
|
||||
https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/connershua_pro.ini
|
||||
https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/connershua_backtocn.ini
|
||||
https://gist.githubusercontent.com/tindy2013/1fa08640a9088ac8652dbd40c5d2715b/raw/dlercloud_lige_platinum.ini
|
||||
https://subconverter.oss-ap-southeast-1.aliyuncs.com/Rules/RemoteConfig/special/basic.ini
|
||||
https://subconverter.oss-ap-southeast-1.aliyuncs.com/Rules/RemoteConfig/special/netease.ini
|
||||
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_Google.ini
|
||||
https://github.com/juewuy/ShellClash/raw/master/rules/ACL4SSR_Online_Games.ini
|
||||
https://github.com/juewuy/ShellClash/raw/master/rules/ACL4SSR_Online_Mini_Games.ini
|
||||
https://github.com/juewuy/ShellClash/raw/master/rules/ACL4SSR_Online_Full_Games.ini
|
||||
EOF`
|
||||
Https=$(echo ${Https//\%26/\&}) #将%26替换回&
|
||||
#如果传来的是Url链接则合成Https链接,否则直接使用Https链接
|
||||
if [ -z "$Https" ];then
|
||||
#[ -n "$(echo $Url | grep -o 'https://dler')" ] && Server='api.dler.io'
|
||||
Https="https://$Server/sub?target=clash&insert=true&new_name=true&scv=true&exclude=$exclude&include=$include&url=$Url&config=$Config"
|
||||
markhttp=1
|
||||
fi
|
||||
#输出
|
||||
echo -----------------------------------------------
|
||||
echo 正在连接服务器获取配置文件…………链接地址为:
|
||||
echo -e "\033[4;32m$Https\033[0m"
|
||||
echo 可以手动复制该链接到浏览器打开并查看数据是否正常!
|
||||
#获取在线yaml文件
|
||||
yaml=$clashdir/config.yaml
|
||||
yamlnew=/tmp/clash_config_$USER.yaml
|
||||
rm -rf $yamlnew
|
||||
$0 webget $yamlnew $Https 0 0 0 1
|
||||
if [ "$?" = "1" ];then
|
||||
if [ -z "$markhttp" ];then
|
||||
echo -----------------------------------------------
|
||||
logger "配置文件获取失败!" 31
|
||||
echo -e "\033[31m请尝试使用【在线生成配置文件】功能!\033[0m"
|
||||
echo -----------------------------------------------
|
||||
exit 1
|
||||
else
|
||||
if [ "$retry" -ge 5 ];then
|
||||
logger "无法获取配置文件,请检查链接格式以及网络连接状态!" 31
|
||||
exit 1
|
||||
else
|
||||
retry=$((retry+1))
|
||||
logger "配置文件获取失败!" 31
|
||||
echo -e "\033[32m尝试使用其他服务器获取配置!\033[0m"
|
||||
logger "正在重试第$retry次/共5次!" 33
|
||||
sed -i '/server_link=*/'d $ccfg
|
||||
if [ "$server_link" -ge 5 ]; then
|
||||
server_link=0
|
||||
fi
|
||||
server_link=$((server_link+1))
|
||||
echo server_link=$server_link >> $ccfg
|
||||
Https=""
|
||||
getyaml
|
||||
fi
|
||||
fi
|
||||
else
|
||||
Https=""
|
||||
#检测节点或providers
|
||||
if [ -z "$(cat $yamlnew | grep -E 'server|proxy-providers' | grep -v 'nameserver' | head -n 1)" ];then
|
||||
echo -----------------------------------------------
|
||||
logger "获取到了配置文件,但似乎并不包含正确的节点信息!" 31
|
||||
echo -----------------------------------------------
|
||||
sed -n '1,30p' $yamlnew
|
||||
echo -----------------------------------------------
|
||||
echo -e "\033[33m请检查如上配置文件信息:\033[0m"
|
||||
echo -----------------------------------------------
|
||||
exit 1
|
||||
fi
|
||||
#检测旧格式
|
||||
if cat $yamlnew | grep 'Proxy Group:' >/dev/null;then
|
||||
echo -----------------------------------------------
|
||||
logger "已经停止对旧格式配置文件的支持!!!" 31
|
||||
echo -e "请使用新格式或者使用【导入节点/链接】功能!"
|
||||
echo -----------------------------------------------
|
||||
exit 1
|
||||
fi
|
||||
#检测不支持的加密协议
|
||||
if cat $yamlnew | grep 'cipher: chacha20,' >/dev/null;then
|
||||
echo -----------------------------------------------
|
||||
logger "已停止支持chacha20加密,请更换更安全的节点加密协议!" 31
|
||||
echo -----------------------------------------------
|
||||
exit 1
|
||||
fi
|
||||
#检测是否存在高级版规则
|
||||
if [ "$clashcore" = "clash" -a -n "$(cat $yamlnew | grep -E '^script:|proxy-providers|rule-providers')" ];then
|
||||
echo -----------------------------------------------
|
||||
logger "检测到高级版核心专属规则!将改为使用premium核心启动!" 33
|
||||
rm -rf $bindir/clash
|
||||
setconfig clashcore clashpre
|
||||
echo -----------------------------------------------
|
||||
fi
|
||||
#使用核心内置test功能检测
|
||||
if [ -x $bindir/clash ];then
|
||||
$bindir/clash -t -d $bindir -f $yamlnew >/dev/null
|
||||
if [ "$?" != "0" ];then
|
||||
logger "配置文件加载失败!请查看报错信息!" 31
|
||||
$bindir/clash -t -d $bindir -f $yamlnew
|
||||
echo "$($bindir/clash -t -d $bindir -f $yamlnew)" >> $clashdir/log
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
#如果不同则备份并替换文件
|
||||
if [ -f $yaml ];then
|
||||
compare $yamlnew $yaml
|
||||
[ "$?" = 0 ] || mv -f $yaml $yaml.bak && mv -f $yamlnew $yaml
|
||||
else
|
||||
mv -f $yamlnew $yaml
|
||||
fi
|
||||
echo -e "\033[32m已成功获取配置文件!\033[0m"
|
||||
rm -rf $yamlnew
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
modify_yaml(){
|
||||
##########需要变更的配置###########
|
||||
lan='allow-lan: true'
|
||||
mode='mode: Rule'
|
||||
log='log-level: info'
|
||||
[ "$ipv6_support" = "已开启" ] && ipv6='ipv6: true' || ipv6='ipv6: false'
|
||||
external="external-controller: 0.0.0.0:$db_port"
|
||||
[ -d $clashdir/ui ] && db_ui=ui
|
||||
[ "$redir_mod" != "Redir模式" ] && tun='tun: {enable: true, stack: system}' || tun='tun: {enable: false}'
|
||||
exper='experimental: {ignore-resolve-fail: true, interface-name: en0}'
|
||||
#dns配置
|
||||
if [ "$dns_mod" = "fake-ip" ];then
|
||||
dns='dns: {enable: true, listen: 0.0.0.0:'$dns_port', use-hosts: true, fake-ip-range: 198.18.0.1/16, enhanced-mode: fake-ip, fake-ip-filter: ["*.lan", "time.windows.com", "time.nist.gov", "time.apple.com", "time.asia.apple.com", "*.ntp.org.cn", "*.openwrt.pool.ntp.org", "time1.cloud.tencent.com", "time.ustc.edu.cn", "pool.ntp.org", "ntp.ubuntu.com", "ntp.aliyun.com", "ntp1.aliyun.com", "ntp2.aliyun.com", "ntp3.aliyun.com", "ntp4.aliyun.com", "ntp5.aliyun.com", "ntp6.aliyun.com", "ntp7.aliyun.com", "time1.aliyun.com", "time2.aliyun.com", "time3.aliyun.com", "time4.aliyun.com", "time5.aliyun.com", "time6.aliyun.com", "time7.aliyun.com", "*.time.edu.cn", "time1.apple.com", "time2.apple.com", "time3.apple.com", "time4.apple.com", "time5.apple.com", "time6.apple.com", "time7.apple.com", "time1.google.com", "time2.google.com", "time3.google.com", "time4.google.com", "music.163.com", "*.music.163.com", "*.126.net", "musicapi.taihe.com", "music.taihe.com", "songsearch.kugou.com", "trackercdn.kugou.com", "*.kuwo.cn", "api-jooxtt.sanook.com", "api.joox.com", "joox.com", "y.qq.com", "*.y.qq.com", "streamoc.music.tc.qq.com", "mobileoc.music.tc.qq.com", "isure.stream.qqmusic.qq.com", "dl.stream.qqmusic.qq.com", "aqqmusic.tc.qq.com", "amobile.music.tc.qq.com", "*.xiami.com", "*.music.migu.cn", "music.migu.cn", "*.msftconnecttest.com", "*.msftncsi.com", "localhost.ptlogin2.qq.com", "*.*.*.srv.nintendo.net", "*.*.stun.playstation.net", "xbox.*.*.microsoft.com", "*.*.xboxlive.com", "proxy.golang.org","*.sgcc.com.cn","*.alicdn.com","*.aliyuncs.com"], nameserver: ['$dns_nameserver', 127.0.0.1:53], fallback: ['$dns_fallback'], fallback-filter: {geoip: true}}'
|
||||
else
|
||||
dns='dns: {enable: true, ipv6: true, listen: 0.0.0.0:'$dns_port', use-hosts: true, enhanced-mode: redir-host, nameserver: ['$dns_nameserver$dns_local'], fallback: ['$dns_fallback'], fallback-filter: {geoip: true}}'
|
||||
fi
|
||||
#设置目录
|
||||
yaml=$clashdir/config.yaml
|
||||
tmpdir=/tmp/clash_$USER
|
||||
#预删除需要添加的项目
|
||||
a=$(grep -n "port:" $yaml | head -1 | cut -d ":" -f 1)
|
||||
b=$(grep -n "^prox" $yaml | head -1 | cut -d ":" -f 1)
|
||||
b=$((b-1))
|
||||
mkdir -p $tmpdir > /dev/null
|
||||
[ "$b" != "0" ] && sed "${a},${b}d" $yaml > $tmpdir/proxy.yaml
|
||||
#跳过本地tls证书验证
|
||||
[ "$skip_cert" = "已开启" ] && sed -i '1,99s/skip-cert-verify: false/skip-cert-verify: true/' $tmpdir/proxy.yaml
|
||||
#检测是否使用script规则
|
||||
[ -n "$(cat $yaml | grep -E '^script:')" ] && mode='mode: Script'
|
||||
#添加配置
|
||||
###################################
|
||||
cat > $tmpdir/set.yaml <<EOF
|
||||
mixed-port: $mix_port
|
||||
redir-port: $redir_port
|
||||
authentication: ["$authentication"]
|
||||
$lan
|
||||
$mode
|
||||
$log
|
||||
$ipv6
|
||||
external-controller: :$db_port
|
||||
external-ui: $db_ui
|
||||
secret: $secret
|
||||
$tun
|
||||
$exper
|
||||
$dns
|
||||
store-selected: $restore
|
||||
EOF
|
||||
###################################
|
||||
[ -f $clashdir/user.yaml ] && yaml_user=$clashdir/user.yaml
|
||||
#合并文件
|
||||
cut -c 1- $tmpdir/set.yaml $yaml_user $tmpdir/proxy.yaml > $tmpdir/config.yaml
|
||||
#插入自定义规则
|
||||
sed -i "/#自定义规则/d" $tmpdir/config.yaml
|
||||
if [ -f $clashdir/rules.yaml ];then
|
||||
sed -i '/^$/d' $clashdir/rules.yaml && echo >> $clashdir/rules.yaml #处理换行
|
||||
space=$(sed -n '/^rules/{n;p}' $tmpdir/proxy.yaml | grep -oE '^\ *') #获取空格数
|
||||
while read line;do
|
||||
[ -z "$(echo "$line " | grep '#')" ] && \
|
||||
[ -n "$(echo "$line" | grep '\-\ ')" ] && \
|
||||
line=$(echo "$line" | sed 's#/#\\/#') && \
|
||||
sed -i "/^rules:/a\\$space$line #自定义规则" $tmpdir/config.yaml
|
||||
done < $clashdir/rules.yaml
|
||||
fi
|
||||
#如果没有使用小闪存模式
|
||||
if [ "$tmpdir" != "$bindir" ];then
|
||||
cmp -s $tmpdir/config.yaml $yaml >/dev/null 2>&1
|
||||
[ "$?" != 0 ] && mv -f $tmpdir/config.yaml $yaml || rm -f $tmpdir/config.yaml
|
||||
fi
|
||||
rm -f $tmpdir/set.yaml
|
||||
rm -f $tmpdir/proxy.yaml
|
||||
}
|
||||
#设置路由规则
|
||||
cn_ip_route(){
|
||||
if [ ! -f $bindir/cn_ip.txt ];then
|
||||
if [ -f $clashdir/cn_ip.txt ];then
|
||||
mv $clashdir/cn_ip.txt $bindir/cn_ip.txt
|
||||
else
|
||||
logger "未找到cn_ip列表,正在下载!" 33
|
||||
$0 webget $bindir/cn_ip.txt "$update_url/bin/china_ip_list.txt"
|
||||
[ "$?" = "1" ] && rm -rf $bindir/cn_ip.txt && logger "列表下载失败,已退出!" 31 && exit 1
|
||||
fi
|
||||
fi
|
||||
if [ -f $bindir/cn_ip.txt ];then
|
||||
echo "create cn_ip hash:net family inet hashsize 1024 maxelem 65536" > /tmp/cn_$USER.ipset
|
||||
awk '!/^$/&&!/^#/{printf("add cn_ip %s'" "'\n",$0)}' $bindir/cn_ip.txt >> /tmp/cn_$USER.ipset
|
||||
ipset -! flush cn_ip 2>/dev/null
|
||||
ipset -! restore < /tmp/cn_$USER.ipset
|
||||
rm -rf cn_$USER.ipset
|
||||
fi
|
||||
}
|
||||
start_redir(){
|
||||
#获取本地局域网地址段
|
||||
gethost
|
||||
#流量过滤规则
|
||||
iptables -t nat -N clash
|
||||
iptables -t nat -A clash -d 0.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A clash -d 10.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A clash -d 127.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A clash -d 169.254.0.0/16 -j RETURN
|
||||
iptables -t nat -A clash -d 172.16.0.0/12 -j RETURN
|
||||
iptables -t nat -A clash -d 192.168.0.0/16 -j RETURN
|
||||
iptables -t nat -A clash -d 224.0.0.0/4 -j RETURN
|
||||
iptables -t nat -A clash -d 240.0.0.0/4 -j RETURN
|
||||
[ "$dns_mod" = "redir_host" -a "$cn_ip_route" = "已开启" ] && iptables -t nat -A clash -m set --match-set cn_ip dst -j RETURN >/dev/null 2>&1 #绕过大陆IP
|
||||
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
|
||||
#mac白名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t nat -A clash -p tcp $ports -m mac --mac-source $mac -j REDIRECT --to-ports $redir_port
|
||||
done
|
||||
else
|
||||
#mac黑名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t nat -A clash -m mac --mac-source $mac -j RETURN
|
||||
done
|
||||
iptables -t nat -A clash -p tcp $ports -j REDIRECT --to-ports $redir_port
|
||||
fi
|
||||
iptables -t nat -A PREROUTING -p tcp $lanhost -j clash
|
||||
if [ "$public_support" = "已开启" ];then
|
||||
iptables -I INPUT -p tcp --dport $mix_port -j ACCEPT
|
||||
iptables -I INPUT -p tcp --dport $db_port -j ACCEPT
|
||||
fi
|
||||
#Google home DNS特殊处理
|
||||
iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 -j clash
|
||||
iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j clash
|
||||
#Docker特殊处理
|
||||
iptables -t nat -I PREROUTING -s 172.16.0.0/12 -j clash
|
||||
#设置ipv6转发
|
||||
ip6_nat=$(ip6tables -t nat -L 2>&1 | grep -o 'Chain')
|
||||
if [ -n "$ip6_nat" -a "$ipv6_support" = "已开启" ];then
|
||||
ip6tables -t nat -N clashv6
|
||||
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
|
||||
#mac白名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
ip6tables -t nat -A clashv6 -p tcp $ports -m mac --mac-source $mac -j REDIRECT --to-ports $redir_port
|
||||
done
|
||||
else
|
||||
#mac黑名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
ip6tables -t nat -A clashv6 -m mac --mac-source $mac -j RETURN
|
||||
done
|
||||
ip6tables -t nat -A clashv6 -p tcp $ports -j REDIRECT --to-ports $redir_port
|
||||
fi
|
||||
ip6tables -t nat -A PREROUTING -p tcp -j clashv6
|
||||
fi
|
||||
}
|
||||
start_dns(){
|
||||
#允许tun网卡接受流量
|
||||
if [ "$redir_mod" = "Tun模式" -o "$redir_mod" = "混合模式" ];then
|
||||
iptables -I FORWARD -o utun -j ACCEPT
|
||||
[ "$ipv6_support" = "已开启" ] && ip6tables -I FORWARD -o utun -j ACCEPT > /dev/null 2>&1
|
||||
fi
|
||||
#设置dns转发
|
||||
iptables -t nat -N clash_dns
|
||||
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
|
||||
#mac白名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t nat -A clash_dns -p udp --dport 53 -m mac --mac-source $mac -j REDIRECT --to $dns_port
|
||||
iptables -t nat -A clash_dns -p tcp --dport 53 -m mac --mac-source $mac -j REDIRECT --to $dns_port
|
||||
done
|
||||
else
|
||||
#mac黑名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t nat -A clash_dns -m mac --mac-source $mac -j RETURN
|
||||
done
|
||||
iptables -t nat -A clash_dns -p udp --dport 53 -j REDIRECT --to $dns_port
|
||||
iptables -t nat -A clash_dns -p tcp --dport 53 -j REDIRECT --to $dns_port
|
||||
fi
|
||||
iptables -t nat -A PREROUTING -p udp -j clash_dns
|
||||
#ipv6DNS
|
||||
ip6_nat=$(ip6tables -t nat -L 2>&1 | grep -o 'Chain')
|
||||
if [ -n "$ip6_nat" ];then
|
||||
ip6tables -t nat -N clashv6_dns > /dev/null 2>&1
|
||||
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
|
||||
#mac白名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
ip6tables -t nat -A clashv6_dns -p udp --dport 53 -m mac --mac-source $mac -j REDIRECT --to $dns_port
|
||||
ip6tables -t nat -A clashv6_dns -p tcp --dport 53 -m mac --mac-source $mac -j REDIRECT --to $dns_port
|
||||
done
|
||||
else
|
||||
#mac黑名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
ip6tables -t nat -A clashv6_dns -m mac --mac-source $mac -j RETURN
|
||||
done
|
||||
ip6tables -t nat -A clashv6_dns -p udp --dport 53 -j REDIRECT --to $dns_port
|
||||
ip6tables -t nat -A clashv6_dns -p tcp --dport 53 -j REDIRECT --to $dns_port
|
||||
fi
|
||||
ip6tables -t nat -A PREROUTING -p udp -j clashv6_dns
|
||||
else
|
||||
ip6tables -I INPUT -p tcp --dport 53 -j REJECT > /dev/null 2>&1
|
||||
ip6tables -I INPUT -p udp --dport 53 -j REJECT > /dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
start_udp(){
|
||||
gethost #获取本地局域网地址段
|
||||
ip rule add fwmark 1 table 100
|
||||
ip route add local default dev lo table 100
|
||||
iptables -t mangle -N clash
|
||||
iptables -t mangle -A clash -d 0.0.0.0/8 -j RETURN
|
||||
iptables -t mangle -A clash -d 10.0.0.0/8 -j RETURN
|
||||
iptables -t mangle -A clash -d 127.0.0.0/8 -j RETURN
|
||||
iptables -t mangle -A clash -d 169.254.0.0/16 -j RETURN
|
||||
iptables -t mangle -A clash -d 172.16.0.0/12 -j RETURN
|
||||
iptables -t mangle -A clash -d 192.168.0.0/16 -j RETURN
|
||||
iptables -t mangle -A clash -d 224.0.0.0/4 -j RETURN
|
||||
iptables -t mangle -A clash -d 240.0.0.0/4 -j RETURN
|
||||
[ "$dns_mod" = "redir_host" -a "$cn_ip_route" = "已开启" ] && iptables -t mangle -A clash -m set --match-set cn_ip dst -j RETURN >/dev/null 2>&1 #绕过大陆IP
|
||||
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
|
||||
#mac白名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t mangle -A clash -p udp -m mac --mac-source $mac -j TPROXY --on-port $redir_port --tproxy-mark 1
|
||||
done
|
||||
else
|
||||
#mac黑名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t mangle -A clash -m mac --mac-source $mac -j RETURN
|
||||
done
|
||||
iptables -t mangle -A clash -p udp -j TPROXY --on-port $redir_port --tproxy-mark 1
|
||||
fi
|
||||
iptables -t mangle -A PREROUTING -p udp $lanhost -j clash
|
||||
}
|
||||
start_output(){
|
||||
#流量过滤规则
|
||||
iptables -t nat -N clash_out
|
||||
iptables -t nat -A clash_out -m owner --gid-owner 7890 -j RETURN
|
||||
iptables -t nat -A clash_out -d 0.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A clash_out -d 10.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A clash_out -d 127.0.0.0/8 -j RETURN
|
||||
iptables -t nat -A clash_out -d 169.254.0.0/16 -j RETURN
|
||||
iptables -t nat -A clash_out -d 172.16.0.0/12 -j RETURN
|
||||
iptables -t nat -A clash_out -d 192.168.0.0/16 -j RETURN
|
||||
iptables -t nat -A clash_out -d 224.0.0.0/4 -j RETURN
|
||||
iptables -t nat -A clash_out -d 240.0.0.0/4 -j RETURN
|
||||
[ "$dns_mod" = "redir_host" -a "$cn_ip_route" = "已开启" ] && iptables -t nat -A clash_out -m set --match-set cn_ip dst -j RETURN >/dev/null 2>&1 #绕过大陆IP
|
||||
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
|
||||
#mac白名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t nat -A clash_out -p tcp $ports -m mac --mac-source $mac -j REDIRECT --to-ports $redir_port
|
||||
done
|
||||
else
|
||||
#mac黑名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t nat -A clash_out -m mac --mac-source $mac -j RETURN
|
||||
done
|
||||
iptables -t nat -A clash_out -p tcp $ports -j REDIRECT --to-ports $redir_port
|
||||
fi
|
||||
iptables -t nat -A OUTPUT -p tcp -j clash_out
|
||||
#设置dns转发
|
||||
iptables -t nat -N clash_dns_out
|
||||
iptables -t nat -A clash_dns_out -m owner --gid-owner 7890 -j RETURN
|
||||
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
|
||||
#mac白名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t nat -A clash_dns_out -p udp --dport 53 -m mac --mac-source $mac -j REDIRECT --to $dns_port
|
||||
iptables -t nat -A clash_dns_out -p tcp --dport 53 -m mac --mac-source $mac -j REDIRECT --to $dns_port
|
||||
done
|
||||
else
|
||||
#mac黑名单
|
||||
for mac in $(cat $clashdir/mac); do
|
||||
iptables -t nat -A clash_dns_out -m mac --mac-source $mac -j RETURN
|
||||
done
|
||||
iptables -t nat -A clash_dns_out -p udp --dport 53 -j REDIRECT --to $dns_port
|
||||
iptables -t nat -A clash_dns_out -p tcp --dport 53 -j REDIRECT --to $dns_port
|
||||
fi
|
||||
iptables -t nat -A OUTPUT -p udp -j clash_dns_out
|
||||
}
|
||||
stop_iptables(){
|
||||
gethost #获取本地局域网地址段
|
||||
#重置iptables规则
|
||||
ip rule del fwmark 1 table 100 2> /dev/null
|
||||
ip route del local default dev lo table 100 2> /dev/null
|
||||
iptables -t nat -D PREROUTING -p tcp $lanhost -j clash 2> /dev/null
|
||||
iptables -D INPUT -p tcp --dport $mix_port -j ACCEPT 2> /dev/null
|
||||
iptables -D INPUT -p tcp --dport $db_port -j ACCEPT 2> /dev/null
|
||||
iptables -t nat -D PREROUTING -p udp -j clash_dns 2> /dev/null
|
||||
iptables -t nat -D PREROUTING -p tcp -d 8.8.8.8 -j clash 2> /dev/null
|
||||
iptables -t nat -D PREROUTING -p tcp -d 8.8.4.4 -j clash 2> /dev/null
|
||||
iptables -t nat -D PREROUTING -s 172.16.0.0/12 -j clash 2> /dev/null
|
||||
iptables -t nat -F clash 2> /dev/null
|
||||
iptables -t nat -X clash 2> /dev/null
|
||||
iptables -t nat -F clash_dns 2> /dev/null
|
||||
iptables -t nat -X clash_dns 2> /dev/null
|
||||
iptables -D FORWARD -o utun -j ACCEPT 2> /dev/null
|
||||
#重置output规则
|
||||
iptables -t nat -D OUTPUT -p tcp -j clash_out 2> /dev/null
|
||||
iptables -t nat -F clash_out 2> /dev/null
|
||||
iptables -t nat -X clash_out 2> /dev/null
|
||||
iptables -t nat -D OUTPUT -p udp -j clash_dns_out 2> /dev/null
|
||||
iptables -t nat -F clash_dns_out 2> /dev/null
|
||||
iptables -t nat -X clash_dns_out 2> /dev/null
|
||||
#重置udp规则
|
||||
iptables -t mangle -D PREROUTING -p udp $lanhost -j clash 2> /dev/null
|
||||
iptables -t mangle -F clash 2> /dev/null
|
||||
iptables -t mangle -X clash 2> /dev/null
|
||||
#重置ipv6规则
|
||||
ip6tables -t nat -D PREROUTING -p tcp -j clashv6 2> /dev/null
|
||||
ip6tables -t nat -D PREROUTING -p udp -j clashv6_dns 2> /dev/null
|
||||
ip6tables -t nat -F clashv6 2> /dev/null
|
||||
ip6tables -t nat -X clashv6 2> /dev/null
|
||||
ip6tables -t nat -F clashv6_dns 2> /dev/null
|
||||
ip6tables -t nat -X clashv6_dns 2> /dev/null
|
||||
ip6tables -D FORWARD -o utun -j ACCEPT 2> /dev/null
|
||||
#清理ipset规则
|
||||
ipset destroy cn_ip >/dev/null 2>&1
|
||||
}
|
||||
#面板配置保存相关
|
||||
web_save(){
|
||||
get_save(){
|
||||
if curl --version > /dev/null 2>&1;then
|
||||
curl -s -H "Authorization: Bearer ${secret}" -H "Content-Type:application/json" "$1"
|
||||
elif [ -n "$(wget --help 2>&1|grep '\-\-method')" ];then
|
||||
wget -q --header="Authorization: Bearer ${secret}" --header="Content-Type:application/json" -O - "$1"
|
||||
fi
|
||||
}
|
||||
#使用get_save获取面板节点设置
|
||||
get_save http://localhost:${db_port}/proxies | awk -F "{" '{for(i=1;i<=NF;i++) print $i}' | grep -E '^"all".*"Selector"' > /tmp/clash_web_check_$USER
|
||||
while read line ;do
|
||||
def=$(echo $line | awk -F "[[,]" '{print $2}')
|
||||
now=$(echo $line | grep -oE '"now".*",' | sed 's/"now"://g'| sed 's/,//g')
|
||||
[ "$def" != "$now" ] && echo $line | grep -oE '"name".*"now".*",' | sed 's/"name"://g' | sed 's/"now"://g'| sed 's/"//g' >> /tmp/clash_web_save_$USER
|
||||
done < /tmp/clash_web_check_$USER
|
||||
rm -rf /tmp/clash_web_check_$USER
|
||||
#对比文件,如果有变动且不为空则写入磁盘,否则清除缓存
|
||||
if [ -s /tmp/clash_web_save_$USER ];then
|
||||
compare /tmp/clash_web_save_$USER $clashdir/web_save
|
||||
[ "$?" = 0 ] && rm -rf /tmp/clash_web_save_$USER || mv -f /tmp/clash_web_save_$USER $clashdir/web_save
|
||||
fi
|
||||
}
|
||||
web_restore(){
|
||||
put_save(){
|
||||
if curl --version > /dev/null 2>&1;then
|
||||
curl -sS -X PUT -H "Authorization: Bearer ${secret}" -H "Content-Type:application/json" "$1" -d "$2" >/dev/null
|
||||
elif wget --version > /dev/null 2>&1;then
|
||||
wget -q --method=PUT --header="Authorization: Bearer ${secret}" --header="Content-Type:application/json" --body-data="$2" "$1" >/dev/null
|
||||
fi
|
||||
}
|
||||
#设置循环检测clash面板端口
|
||||
i=1
|
||||
while [ $i -lt 10 ];do
|
||||
sleep 1
|
||||
if curl --version > /dev/null 2>&1;then
|
||||
test=$(curl -s http://localhost:${db_port})
|
||||
else
|
||||
test=$(wget -q -O - http://localhost:${db_port})
|
||||
fi
|
||||
[ -n "$test" ] && i=10
|
||||
done
|
||||
#发送数据
|
||||
num=$(cat $clashdir/web_save | wc -l)
|
||||
for i in `seq $num`;
|
||||
do
|
||||
group_name=$(awk -F ',' 'NR=="'${i}'" {print $1}' $clashdir/web_save | sed 's/ /%20/g')
|
||||
now_name=$(awk -F ',' 'NR=="'${i}'" {print $2}' $clashdir/web_save)
|
||||
put_save http://localhost:${db_port}/proxies/${group_name} "{\"name\":\"${now_name}\"}"
|
||||
done
|
||||
}
|
||||
#启动相关
|
||||
catpac(){
|
||||
gethost
|
||||
cat > /tmp/clash_pac <<EOF
|
||||
function FindProxyForURL(url, host) {
|
||||
if (
|
||||
isInNet(host, "0.0.0.0", "255.0.0.0")||
|
||||
isInNet(host, "10.0.0.0", "255.0.0.0")||
|
||||
isInNet(host, "127.0.0.0", "255.0.0.0")||
|
||||
isInNet(host, "224.0.0.0", "224.0.0.0")||
|
||||
isInNet(host, "240.0.0.0", "240.0.0.0")||
|
||||
isInNet(host, "172.16.0.0", "255.240.0.0")||
|
||||
isInNet(host, "192.168.0.0", "255.255.0.0")||
|
||||
isInNet(host, "169.254.0.0", "255.255.0.0")
|
||||
)
|
||||
return "DIRECT";
|
||||
else
|
||||
return "PROXY $host:$mix_port; DIRECT; SOCKS5 $host:$mix_port"
|
||||
}
|
||||
EOF
|
||||
compare /tmp/clash_pac $bindir/ui/pac
|
||||
[ "$?" = 0 ] && rm -rf /tmp/clash_pac || mv -f /tmp/clash_pac $bindir/ui/pac
|
||||
}
|
||||
bfstart(){
|
||||
#读取配置文件
|
||||
getconfig
|
||||
[ ! -d $bindir/ui ] && mkdir -p $bindir/ui
|
||||
[ -z "$update_url" ] || [ -n "$(echo $update_url | grep 'github')" ] && update_url=https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master
|
||||
#检查clash核心
|
||||
if [ ! -f $bindir/clash ];then
|
||||
if [ -f $clashdir/clash ];then
|
||||
mv $clashdir/clash $bindir/clash && chmod +x $bindir/clash
|
||||
else
|
||||
logger "未找到clash核心,正在下载!" 33
|
||||
if [ -z "$clashcore" ];then
|
||||
[ "$redir_mod" = "混合模式" -o "$redir_mod" = "Tun模式" ] && clashcore=clashpre || clashcore=clash
|
||||
fi
|
||||
[ -z "$cpucore" ] && source $clashdir/getdate.sh && getcpucore
|
||||
[ -z "$cpucore" ] && logger 找不到设备的CPU信息,请手动指定处理器架构类型! 31 && setcpucore
|
||||
$0 webget $bindir/clash "$update_url/bin/$clashcore/clash-linux-$cpucore"
|
||||
[ "$?" = "1" ] && rm -rf $bindir/clash && logger "核心下载失败,已退出!" 31 && exit 1
|
||||
[ ! -x $bindir/clash ] && chmod +x $bindir/clash #检测可执行权限
|
||||
clashv=$($bindir/clash -v | awk '{print $2}')
|
||||
setconfig clashv $clashv
|
||||
fi
|
||||
fi
|
||||
#检查数据库文件
|
||||
if [ ! -f $bindir/Country.mmdb ];then
|
||||
if [ -f $clashdir/Country.mmdb ];then
|
||||
mv $clashdir/Country.mmdb $bindir/Country.mmdb
|
||||
else
|
||||
logger "未找到GeoIP数据库,正在下载!" 33
|
||||
[ -z "$geotype" ] && geotype=cn_mini.mmdb
|
||||
$0 webget $bindir/Country.mmdb $update_url/bin/$geotype
|
||||
[ "$?" = "1" ] && rm -rf $bindir/Country.mmdb && logger "数据库下载失败,已退出!" 31 && exit 1
|
||||
Geo_v=$(date +"%Y%m%d")
|
||||
setconfig Geo_v $Geo_v
|
||||
fi
|
||||
fi
|
||||
#检查dashboard文件
|
||||
if [ -f $clashdir/ui/index.html -a ! -f $bindir/ui/index.html ];then
|
||||
cp -rf $clashdir/ui $bindir
|
||||
fi
|
||||
#检查curl或wget支持
|
||||
curl --version > /dev/null 2>&1
|
||||
[ "$?" = 1 ] && wget --version > /dev/null 2>&1
|
||||
[ "$?" = 1 ] && restore=true || restore=false
|
||||
#生成pac文件
|
||||
catpac
|
||||
#检查yaml配置文件
|
||||
if [ ! -f $clashdir/config.yaml ];then
|
||||
if [ -n "$Url" -o -n "$Https" ];then
|
||||
logger "未找到配置文件,正在下载!" 33
|
||||
getyaml
|
||||
exit 0
|
||||
else
|
||||
logger "未找到配置文件链接,请先导入配置文件!" 31
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
#本机代理准备
|
||||
if [ "$local_proxy" = "已开启" -a "$local_type" = "iptables增强模式" ];then
|
||||
if [ -z "$(id shellclash 2>/dev/null | grep 'root')" ];then
|
||||
userdel shellclash 2>/dev/null
|
||||
useradd shellclash -u 7890
|
||||
sed -Ei s/7890:7890/0:7890/g /etc/passwd
|
||||
fi
|
||||
if [ "$start_old" != "已开启" ];then
|
||||
[ -w /etc/systemd/system/clash.service ] && servdir=/etc/systemd/system/clash.service
|
||||
[ -w /usr/lib/systemd/system/clash.service ] && servdir=/usr/lib/systemd/system/clash.service
|
||||
setconfig ExecStart "/bin/su\ shellclash\ -c\ \"$bindir/clash\ -d\ $bindir\"" $servdir
|
||||
systemctl daemon-reload >/dev/null
|
||||
fi
|
||||
fi
|
||||
}
|
||||
afstart(){
|
||||
|
||||
#读取配置文件
|
||||
getconfig
|
||||
$bindir/clash -t -d $bindir >/dev/null
|
||||
if [ "$?" = 0 ];then
|
||||
#设置iptables转发规则
|
||||
[ "$dns_mod" = "redir_host" ] && [ "$cn_ip_route" = "已开启" ] && cn_ip_route
|
||||
[ "$redir_mod" != "纯净模式" ] && [ "$dns_no" != "已禁用" ] && start_dns
|
||||
[ "$redir_mod" != "纯净模式" ] && [ "$redir_mod" != "Tun模式" ] && start_redir
|
||||
[ "$redir_mod" = "Redir模式" ] && [ "$tproxy_mod" = "已开启" ] && start_udp
|
||||
[ "$local_proxy" = "已开启" ] && [ "$local_type" = "iptables增强模式" ] && start_output
|
||||
#标记启动时间
|
||||
mark_time
|
||||
#设置本机代理
|
||||
[ "$local_proxy" = "已开启" ] && $0 set_proxy $mix_port $db_port
|
||||
#加载定时任务
|
||||
[ -f $clashdir/cron ] && croncmd $clashdir/cron
|
||||
#启用面板配置自动保存
|
||||
if [ "$restore" = false ];then
|
||||
cronset '#每10分钟保存节点配置' "*/10 * * * * test -n \"\$(pidof clash)\" && $clashdir/start.sh web_save #每10分钟保存节点配置"
|
||||
[ -f $clashdir/web_save ] && web_restore & #后台还原面板配置
|
||||
fi
|
||||
else
|
||||
logger "clash服务启动失败!请查看报错信息!" 31
|
||||
$bindir/clash -t -d $bindir
|
||||
echo "$($bindir/clash -t -d $bindir)" >> $clashdir/log
|
||||
$0 stop
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
start_old(){
|
||||
#使用传统后台执行二进制文件的方式执行
|
||||
if [ "$local_proxy" = "已开启" -a "$local_type" = "iptables增强模式" ];then
|
||||
su shellclash -c "$bindir/clash -d $bindir >/dev/null" &
|
||||
else
|
||||
$bindir/clash -d $bindir >/dev/null &
|
||||
fi
|
||||
afstart
|
||||
$0 daemon
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
|
||||
bfstart)
|
||||
bfstart
|
||||
;;
|
||||
afstart)
|
||||
afstart
|
||||
;;
|
||||
start)
|
||||
[ -n "$(pidof clash)" ] && $0 stop #禁止多实例
|
||||
getconfig
|
||||
#检测必须文件并下载
|
||||
bfstart
|
||||
stop_iptables #清理iptables
|
||||
#使用内置规则强行覆盖config配置文件
|
||||
[ "$modify_yaml" != "已开启" ] && modify_yaml
|
||||
#使用不同方式启动clash服务
|
||||
if [ "$start_old" = "已开启" ];then
|
||||
start_old
|
||||
elif [ -f /etc/rc.common ];then
|
||||
/etc/init.d/clash start
|
||||
elif [ "$USER" = "root" ];then
|
||||
systemctl start clash.service
|
||||
else
|
||||
start_old
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
getconfig
|
||||
[ -n "$(pidof clash)" ] && [ "$restore" = false ] && web_save #保存面板配置
|
||||
#删除守护进程&面板配置自动保存
|
||||
cronset "clash保守模式守护进程"
|
||||
cronset "保存节点配置"
|
||||
#多种方式结束进程
|
||||
if [ -f /etc/rc.common ];then
|
||||
/etc/init.d/clash stop >/dev/null 2>&1
|
||||
elif [ "$USER" = "root" ];then
|
||||
systemctl stop clash.service >/dev/null 2>&1
|
||||
fi
|
||||
PID=$(pidof clash) && [ -n "$PID" ] && kill -9 $PID >/dev/null 2>&1
|
||||
stop_iptables #清理iptables
|
||||
$0 unset_proxy #禁用本机代理
|
||||
;;
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
init)
|
||||
[ -d "/etc/storage/clash" ] && clashdir=/etc/storage/clash && profile=/opt/etc/profile
|
||||
[ -d "/jffs/clash" ] && clashdir=/jffs/clash && profile=/jffs/configs/profile.add
|
||||
echo "alias clash=\"$clashdir/clash.sh\"" >> $profile
|
||||
echo "export clashdir=\"$clashdir\"" >> $profile
|
||||
$0 start
|
||||
;;
|
||||
getyaml)
|
||||
getconfig
|
||||
getyaml
|
||||
;;
|
||||
updateyaml)
|
||||
$0 getyaml
|
||||
$0 restart
|
||||
;;
|
||||
webget)
|
||||
#设置临时http代理
|
||||
[ -n "$(pidof clash)" ] && getconfig && export all_proxy="http://$authentication@127.0.0.1:$mix_port"
|
||||
#参数【$2】代表下载目录,【$3】代表在线地址
|
||||
#参数【$4】代表输出显示,【$4】不启用重定向
|
||||
#参数【$6】代表验证证书,【$7】使用clash文件头
|
||||
if curl --version > /dev/null 2>&1;then
|
||||
[ "$4" = "echooff" ] && progress='-s' || progress='-#'
|
||||
[ "$5" = "rediroff" ] && redirect='' || redirect='-L'
|
||||
[ "$6" = "skipceroff" ] && certificate='' || certificate='-k'
|
||||
#[ -n "$7" ] && agent='-A "clash"'
|
||||
result=$(curl $agent -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o "$2" "$3")
|
||||
[ "$?" != "0" ] && export all_proxy="" && result=$(curl $agent -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o "$2" "$3")
|
||||
else
|
||||
if wget --version > /dev/null 2>&1;then
|
||||
[ "$4" = "echooff" ] && progress='-q' || progress='-q --show-progress'
|
||||
[ "$5" = "rediroff" ] && redirect='--max-redirect=0' || redirect=''
|
||||
[ "$6" = "skipceroff" ] && certificate='' || certificate='--no-check-certificate'
|
||||
timeout='--timeout=3 -t 2'
|
||||
#[ -n "$7" ] && agent='--user-agent="clash"'
|
||||
fi
|
||||
[ "$4" = "echoon" ] && progress=''
|
||||
[ "$4" = "echooff" ] && progress='-q'
|
||||
wget -Y on $agent $progress $redirect $certificate $timeout -O "$2" "$3"
|
||||
if [ "$?" != "0" ];then
|
||||
wget -Y off $agent $progress $redirect $certificate $timeout -O "$2" "$3"
|
||||
[ "$?" = "0" ] && result="200"
|
||||
else
|
||||
result="200"
|
||||
fi
|
||||
fi
|
||||
[ "$result" = "200" ] && exit 0 || exit 1
|
||||
;;
|
||||
web_save)
|
||||
getconfig
|
||||
web_save
|
||||
;;
|
||||
web_restore)
|
||||
getconfig
|
||||
web_restore
|
||||
;;
|
||||
daemon)
|
||||
getconfig
|
||||
cronset '#clash保守模式守护进程' "*/1 * * * * test -z \"\$(pidof clash)\" && $clashdir/start.sh restart #clash保守模式守护进程"
|
||||
;;
|
||||
cronset)
|
||||
cronset $2 $3
|
||||
;;
|
||||
set_proxy)
|
||||
getconfig
|
||||
if [ "$local_type" = "环境变量" ];then
|
||||
[ -w ~/.bashrc ] && profile=~/.bashrc
|
||||
[ -w /etc/profile ] && profile=/etc/profile
|
||||
echo 'export all_proxy=http://127.0.0.1:'"$mix_port" >> $profile
|
||||
echo 'export ALL_PROXY=$all_proxy' >> $profile
|
||||
fi
|
||||
;;
|
||||
unset_proxy)
|
||||
[ -w ~/.bashrc ] && profile=~/.bashrc
|
||||
[ -w /etc/profile ] && profile=/etc/profile
|
||||
sed -i '/all_proxy/'d $profile
|
||||
sed -i '/ALL_PROXY/'d $profile
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user