62 Commits

Author SHA1 Message Date
juewuy
82ba1447e1 已修改 bin/release_version 2020-12-21 21:34:07 +08:00
juewuy
5dc3b53e6e 已修改 README.md
已修改        README_CN.md
2020-12-21 13:31:46 +08:00
juewuy
e5c4e65812 已修改 README.md
已修改        README_CN.md
2020-12-21 13:27:18 +08:00
juewuy
4285663e55 已修改 README_CN.md 2020-12-21 13:26:15 +08:00
juewuy
54b66f0925 Update README.md 2020-12-21 13:24:25 +08:00
juewuy
cfd1b98bd2 已修改 README.md 2020-12-21 13:23:16 +08:00
juewuy
862e5f54fc Update README.md 2020-12-21 13:18:43 +08:00
juewuy
db43540735 Update README.md 2020-12-21 13:16:17 +08:00
juewuy
e048261914 Update README.md 2020-12-21 13:15:46 +08:00
juewuy
bfb57cd094 Update README.md 2020-12-21 13:15:15 +08:00
juewuy
3cab521370 Update README.md 2020-12-21 13:13:27 +08:00
juewuy
e76a62c76f Update README.md 2020-12-21 13:12:34 +08:00
juewuy
75d121d01a 更新Readme 2020-12-21 13:11:33 +08:00
juewuy
6f978ac58f 更新Readme 2020-12-21 13:09:38 +08:00
juewuy
9772fdee87 更新Readme 2020-12-21 13:08:14 +08:00
juewuy
2e3fefe854 更新Readme 2020-12-21 13:06:57 +08:00
juewuy
d26fbe5046 更新Readme 2020-12-21 13:06:04 +08:00
juewuy
e11e883ffd 更新Readme 2020-12-21 12:37:31 +08:00
juewuy
a8b485bd7d v1.0.0beta18.2
~修复部分情况下首次安装本地面板报错的bug
~修复卸载时无法正确移除定时任务的bug
2020-12-21 11:56:05 +08:00
juewuy
5f5d384d53 v1.0.0beta18.2
~修复部分情况下首次安装本地面板报错的bug
~修复卸载时无法正确移除定时任务的bug
2020-12-21 11:55:43 +08:00
juewuy
38efeb7aef v1.0.0beta18.1
~同步最新版本GeoIP数据库文件
~下载本地根证书功能增加自动检测证书目录逻辑
~现在导入包含高级版规则的配置时,会自动切换到高级版核心
2020-12-18 13:00:36 +08:00
juewuy
fea5673384 v1.0.0beta18.1
~下载本地根证书功能增加自动检测证书目录逻辑
~现在导入包含高级版规则的配置时,会自动切换到高级版核心
2020-12-18 12:58:41 +08:00
juewuy
7b3e38e4c6 v1.0.0beta18fix
~回退armv5核心为未压缩状态
~修复定时任务界面层级错乱的bug
~修复过滤局域网设备无法正确读取dhcp列表的bug
2020-12-17 09:59:18 +08:00
juewuy
cee0a10548 v1.0.0beta18
~回退armv5核心为未压缩状态
~修复定时任务界面层级错乱的bug
~修复过滤局域网设备无法正确读取dhcp列表的bug
2020-12-17 09:58:01 +08:00
juewuy
cf7ff363e0 v1.0.0beta18
~回退armv5核心为未压缩状态
~修复定时任务界面层级错乱的bug
~修复过滤局域网设备无法正确读取dhcp列表的bug
2020-12-17 09:57:33 +08:00
juewuy
eebffa662f v1.0.0beta18
~回退armv5核心为未压缩状态
~修复定时任务界面层级错乱的bug
2020-12-15 10:36:21 +08:00
juewuy
41080fb146 v1.0.0beta18
~回退armv5核心为未压缩状态
~修复定时任务界面层级错乱的bug
2020-12-15 10:35:39 +08:00
juewuy
c1379cde16 v1.0.0beta17.9
~增加了一键切换加密dns的功能
~修复了切换安装源时会偶尔清空配置文件的bug
~修复了下载失败并提示127.0.0.1无法连接的bug
2020-12-14 16:38:48 +08:00
juewuy
2ec1fd6e74 v1.0.0beta17.9
~增加了一键切换加密dns的功能
~修复了切换安装源时会偶尔清空配置文件的bug
~修复了下载失败并提示127.0.0.1无法连接的bug
2020-12-14 16:38:14 +08:00
juewuy
c5089f0277 v1.0.0beta17.8
~增加了对padavan系统读取局域网设备过滤列表的支持
~优化了配置文件保存方式,减少闪存消耗
~修复了部分mipsle设备无法正确识别核心的bug
~修复了部分情况下订阅链接/配置链接丢失的bug
~修复了部分情况下会连续下载两次核心的bug
2020-12-13 22:13:27 +08:00
juewuy
872a84abc1 v1.0.0beta17.8
~增加了对padavan系统读取局域网设备过滤列表的支持
~优化了配置文件保存方式,减少闪存消耗
~修复了部分mipsle设备无法正确识别核心的bug
~修复了部分情况下订阅链接/配置链接丢失的bug
~修复了部分情况下会连续下载两次核心的bug
2020-12-13 22:12:52 +08:00
juewuy
66cc65f239 v1.0.0beta17.8
~增加了对padavan系统读取局域网设备过滤列表的支持
~优化了配置文件保存方式,减少闪存消耗
~修复了部分mipsle设备无法正确识别核心的bug
~修复了部分情况下订阅链接/配置链接丢失的bug
~修复了部分情况下会连续下载两次核心的bug
2020-12-13 21:22:41 +08:00
juewuy
2fa0840c6e v1.0.0beta17.8
~优化了保存节点信息的方式,节省存储消耗
~修复了部分情况下订阅链接/配置链接丢失的bug
~修复了部分情况下会连续下载两次核心的bug
2020-12-13 16:40:19 +08:00
juewuy
5924a3ecf7 v1.0.0beta17.8
~优化了保存节点信息的方式,节省存储消耗
~修复了部分情况下订阅链接/配置链接丢失的bug
2020-12-13 13:57:37 +08:00
juewuy
91ada9f49f v1.0.0beta17.8
~修复了部分情况下订阅链接/配置链接丢失的bug
2020-12-13 12:39:25 +08:00
juewuy
67e8626e8a v1.0.0beta17.7
~增加了在使用功能设置变更配置后告知用户重启的提示
~修复定时更新订阅时不会重启clash服务的bug
~优化语句结构,修复部分情况下菜单层级错乱的bug
~修复卸载时不会清除部分定时任务的bug
~修复pac在部分设备上不可用的bug(待测试)
2020-12-12 18:30:18 +08:00
juewuy
9f9d3c3dcb v1.0.0beta17.7
~增加了在使用功能设置变更配置后告知用户重启的提示
~修复定时更新订阅时不会重启clash服务的bug
~优化语句结构,修复部分情况下菜单层级错乱的bug
~修复卸载时不会清除部分定时任务的bug
~修复pac在部分设备上不可用的bug(待测试)
2020-12-12 18:29:59 +08:00
juewuy
82cadd1aaf v1.0.0beta17.7
~修复定时更新订阅时不会重启clash服务的bug
~优化语句结构,修复部分情况下菜单层级错乱的bug
2020-12-12 13:30:19 +08:00
juewuy
c12d59231d v1.0.0beta17.7
~修复定时更新订阅时不会重启clash服务的bug
~优化语句结构,修复部分情况下菜单层级错乱的bug
2020-12-12 13:30:00 +08:00
juewuy
3ef6effe78 v1.0.0beta17.7
~修复定时更新订阅时不会重启clash服务的bug
2020-12-12 12:20:22 +08:00
juewuy
f72df657db v1.0.0beta17.6
~大幅度调整和优化导入配置文件功能
~大幅度调整和优化新手引导逻辑和步骤
~新增Hackl0us提供的精简版GeoIP数据库下载
~修复部分情况下提示本地代理连接失败的bug
~修复导入配置文件功能部分bug
2020-12-12 10:27:20 +08:00
juewuy
89bca53889 v1.0.0beta17.6
~大幅度调整和优化导入配置文件功能
~大幅度调整和优化新手引导逻辑和步骤
~新增Hackl0us提供的精简版GeoIP数据库下载
~修复部分情况下提示本地代理连接失败的bug
~修复导入配置文件功能部分bug
2020-12-12 10:27:03 +08:00
juewuy
656682be14 v1.0.0beta17.5
~大幅度调整和优化导入配置文件功能
~大幅度调整和优化新手引导逻辑和步骤
~新增Hackl0us提供的精简版GeoIP数据库下载
~修复部分情况下提示本地代理连接失败的bug
2020-12-11 22:26:07 +08:00
juewuy
bdc84608d2 v1.0.0beta17.5
~大幅度调整和优化导入配置文件功能
~大幅度调整和优化新手引导逻辑和步骤
~新增Hackl0us提供的精简版GeoIP数据库下载
~修复部分情况下提示本地代理连接失败的bug
2020-12-11 22:17:29 +08:00
juewuy
533f856b0b v1.0.0beta17.4
~新增安装本地根证书文件功能,用于解决各种证书验证问题及x509报错问题
2020-12-09 13:03:42 +08:00
juewuy
c87208983b v1.0.0beta17.3
~新增自定义默认过滤端口功能
~屏蔽已被封禁的gitee下载源
~修复新用户无法正常启动新手引导的bug
~修复部分设备重启后代理失效的bug
~修复偶尔检测更新出错的bug
2020-12-08 23:25:57 +08:00
juewuy
5adb662ece v1.0.0beta17.3
~新增自定义默认过滤端口功能
~屏蔽已被封禁的gitee下载源
~修复新用户无法正常启动新手引导的bug
~修复部分设备重启后代理失效的bug
~修复偶尔检测更新出错的bug
2020-12-08 23:21:50 +08:00
juewuy
0f4fbd8d68 v1.0.0beta17.3
~新增自定义默认过滤端口功能
~屏蔽已被封禁的gitee下载源
~修复部分设备重启后代理失效的bug
~修复偶尔检测更新出错的bug
2020-12-08 20:47:33 +08:00
juewuy
15deb9a608 v1.0.0beta17.3
~新增自定义默认过滤端口功能
~屏蔽已被封禁的gitee下载源
~修复部分设备重启后代理失效的bug
~修复偶尔检测更新出错的bug
2020-12-08 20:42:03 +08:00
juewuy
62c3566ac9 v1.0.0beta17.3
~新增自定义默认过滤端口功能
~屏蔽已被封禁的gitee下载源
~修复部分设备重启后代理失效的bug
~修复偶尔检测更新出错的bug
2020-12-08 20:37:49 +08:00
juewuy
09432eee01 v1.0.0beta17.3
~修复偶尔检测更新出错的bug
2020-12-03 13:06:40 +08:00
juewuy
bb28742b86 v1.0.0beta17.2
~同步官方最新1.3.0版本clash核心及premium核心
~同步最新GeoIP数据库文件
~同步最新dashboard面板文件
~修复使用在线节点时获取配置文件报错的bug
~修复手动更新订阅界面不显示已保存链接的bug
~下载dashboard面板时,自动检测目录是否可写
~修复下载配置文件失败后依然显示clash启动的bug
2020-11-22 15:40:31 +08:00
juewuy
f316957a64 v1.0.0beta17.2
~同步官方最新1.3.0版本clash核心及premium核心
~同步最新GeoIP数据库文件
~同步最新dashboard面板文件
~修复使用在线节点时获取配置文件报错的bug
~修复手动更新订阅界面不显示已保存链接的bug
~下载dashboard面板时,自动检测目录是否可写
~修复下载配置文件失败后依然显示clash启动的bug
2020-11-22 15:21:24 +08:00
juewuy
2a2ee0b90d v1.0.0beta17.2
~修复使用在线节点时获取配置文件报错的bug
~修复手动更新订阅界面不显示已保存链接的bug
~下载dashboard面板时,自动检测目录是否可写
~修复下载配置文件失败后依然显示clash启动的bug
2020-11-22 15:11:39 +08:00
juewuy
a5cbde33e1 Merge branch 'master' of https://github.com/juewuy/clash-for-Miwifi into master 2020-11-22 15:11:00 +08:00
juewuy
893b6f1dae Update README.md 2020-11-22 10:57:50 +08:00
juewuy
de571b58e3 v1.0.0beta17.2
~修复使用在线节点时获取配置文件报错的bug
~修复手动更新订阅界面不显示已保存链接的bug
~下载dashboard面板时,自动检测目录是否可写
2020-11-15 13:01:29 +08:00
juewuy
7e528f5b2b v1.0.0beta17.1
~修复部分设备无法使用mac过滤的bug
~更新菜单增加PAC配置地址及说明
2020-11-12 15:29:06 +08:00
juewuy
c28eb1cbbc v1.0.0beta17.1
~修复部分设备无法使用mac过滤的bug
~更新菜单增加PAC配置地址及说明
2020-11-12 14:30:17 +08:00
juewuy
3a85ac1499 v1.0.0beta17.1
~修复部分设备无法使用mac过滤的bug
~更新菜单增加PAC配置地址及说明
2020-11-12 14:20:01 +08:00
juewuy
558a2ee6d8 v1.0.0beta17fix
~修复下载yacd面板后无法自动配置访问IP的bug
2020-11-09 16:16:14 +08:00
juewuy
aaa1228319 v1.0.0beta17
~同步最新版本Geoip数据库
~新增更新切换版本到其他release版本的功能
~调整release版本更新检测机制
~修复部分设备提示缺少cmb的问题
~修复使用自定义规则时,每次启动clash规则都会被重复导入的问题
~进一步优化面板保存机制
2020-11-08 15:06:30 +08:00
31 changed files with 4329 additions and 623 deletions

121
README.md
View File

@@ -1,105 +1,108 @@
<h1 align="center">
<img src="https://github.com/Dreamacro/clash/raw/master/docs/logo.png" alt="Clash" width="200">
<br>ShellClash<br>
</h1>
# ShellClash原Clash for Miwifi
<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>
在Shell环境下一键部署及管理[Clash](https://github.com/Dreamacro/clash)
=====
[中文](README_CN.md) | English
功能简介:
--
~通过管理脚本在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>~支持GNOME、KDE桌面自动配置本机系统级代理<br>~支持在线更新<br>
## 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:
--
~支持小米/红米全系使用官方系统或官方开发版系统的路由器设备<br>
~支持各种基于OpenWrt或使用OpenWrt二次定制开发的路由器设备<br>
~支持各种运行标准Linux系统如Debian/CenOS/Armbian等的设备<br>~兼容Padavan固件保守模式、潘多拉固件<br>——————————
~更多设备支持请提issue或前往TG群反馈需提供设备名称及运行uname -a返回的设备核心信息<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>
使用方式:
--
~确认路由器设备已经开启SSH并获取root权限带GUI桌面的Linux设备可使用自带终端安装<br>
~使用SSH连接工具如puttyJuiceSSH系统自带终端等路由器或Linux设备的SSH管理界面或终端界面并切换到root用户<br>
~确认设备已经安装curl或者wget下载工具。如未安装LInux设备请[参考此处](https://www.howtoing.com/install-curl-in-linux)安装curl基于OpenWrt小米官方系统、潘多拉、高恪等的设备请使用如下命令安装curl<br>
```shell
```sh
opkg update && opkg install curl
```
~之后在SSH界面执行如下安装命令并按照后续提示完成安装<br>
~ Then execute the following installation commands on the SSH interface, and follow the subsequent prompts to complete the installation<br>
~**使用curl安装**<br>
##### ~Use curl:<br>
```Shell
#Release版本-github直连
#Release version - by github
sh -c "$(curl -kfsSl --resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master/install.sh)" && source /etc/profile &> /dev/null
#Release版本-jsdelivrCDN
#Release version - by jsdelivrCDN
sh -c "$(curl -kfsSl https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master/install.sh)" && source /etc/profile &> /dev/null
#Test版本-github直连
#Test version - by github
sh -c "$(curl -kfsSl --resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master/install.sh)" -s 1 && source /etc/profile &> /dev/null
```
~**使用wget安装**<br>
##### ~Use wget<br>
```sh
#Release版本-jsdelivrCDN
wget -q --no-check-certificate -O /tmp/install.sh https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master/install.sh && sh /tmp/install.sh 2 && source /etc/profile &> /dev/null
#Release version - by jsdelivrCDN
wget -q --no-check-certificate -O /tmp/install.sh https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master/install.sh && sh /tmp/install.sh && source /etc/profile &> /dev/null
```
~**非root用户安装后**请额外执行以下命令以读取环境变量:<br>
~**After installation by non-root users**, please execute the following additional commands to read environment variables:<br>
```shell
source ~/.bashrc &> /dev/null
```
~安装完成管理脚本后,执行如下命令以**运行管理脚本**<br>
~After installing the management script, execute the following command to **run the management script**<br>
```Shell
clash #正常模式运行
clash -h #脚本帮助及说明
clash -t #测试模式运行
clash #normal mode
clash -h #help
clash -t #test mode
```
~**运行时的额外依赖**<br>
~**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 必须 全部缺少时无法安装及运行脚本
curl/wget 必须 全部缺少时无法在线安装及更新,无法使用节点保存功能
iptables 重要 缺少时只能使用纯净模式
systemd/rc.common 一般 全部缺少时只能使用保守模式
iptables-mod-nat 一般 缺少时无法使用redir模式混合模式
ip6tables-mod-nat 较低 缺少时影响redir模式混合模式对ipv6的支持
crontab 较低 缺少时无法启用定时任务功能
net-tools 极低 缺少时无法正常检测端口占用
ubus/iproute-doc 极低 缺少时无法正常获取本机host地址
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:
### [点击查看](https://github.com/juewuy/ShellClash/releases)
### [Click to view](https://github.com/juewuy/ShellClash/releases)
交流反馈:
--
### [TG讨论组](https://t.me/clashfm)
## Exchange feedback:
相关Q&A
--
### [TG Discussion Group](https://t.me/clashfm)
### [详见博客](https://juewuy.github.io)
## Related Q&A:
## 捐赠此项目:
### [See blog for details](https://juewuy.github.io)
### [前往页面](https://juewuy.github.io/yOF4Yf06Q/)
## Donate this project
### [Go to page](https://juewuy.github.io/yOF4Yf06Q/)
## Friendly promotion:
### [Top 8K Airport-Dler](https://dler.best/auth/register?affid=89698)
友情推广:
--
### [顶级8K专线机场-墙洞](https://dler.best/auth/register?affid=89698)

117
README_CN.md Normal file
View File

@@ -0,0 +1,117 @@
<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>~支持GNOME、KDE桌面自动配置本机模式<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连接工具如puttyJuiceSSH系统自带终端等路由器或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
#Release版本-github直连
sh -c "$(curl -kfsSl --resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master/install.sh)" && source /etc/profile &> /dev/null
#Release版本-jsdelivrCDN源
sh -c "$(curl -kfsSl https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master/install.sh)" && source /etc/profile &> /dev/null
#Test版本-github直连
sh -c "$(curl -kfsSl --resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master/install.sh)" -s 1 && source /etc/profile &> /dev/null
```
~**使用wget安装**<br>
```sh
#Release版本-jsdelivrCDN源
wget -q --no-check-certificate -O /tmp/install.sh https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master/install.sh && sh /tmp/install.sh && source /etc/profile &> /dev/null
```
~**非root用户安装后**请额外执行以下命令以读取环境变量:<br>
```shell
source ~/.bashrc &> /dev/null
```
~安装完成管理脚本后,执行如下命令以**运行管理脚本**<br>
```Shell
clash #正常模式运行
clash -h #脚本帮助及说明
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)
## 捐赠此项目:
### [前往页面](https://juewuy.github.io/yOF4Yf06Q/)
友情推广:
--
### [顶级8K专线机场-墙洞](https://dler.best/auth/register?affid=89698)

Binary file not shown.

3435
bin/ca-certificates.crt Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
bin/cn_mini.mmdb Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

View File

@@ -1,3 +1,5 @@
1.0.0beta18.2
1.0.0beta17
1.0.0beta15
1.0.0beta11
1.0.0beta5

View File

@@ -1,4 +1,4 @@
clash_v=1.2.0
clashpre_v=2020.10.26
GeoIP_v=20201108
versionsh=1.0.0beta17
clash_v=1.3.0
clashpre_v=2020.11.20
GeoIP_v=20201218
versionsh=1.0.0beta18.2

Binary file not shown.

View File

@@ -37,11 +37,11 @@ webget(){
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
if [ "$test" -gt 0 ];then
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master"
[ "$test" -eq 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi"
[ "$test" -eq 2 ] && url="http://192.168.31.31:8080/ShellClash"
[ "$test" -eq 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi"
else
webget /tmp/clashrelease $url@master/bin/release_version echoon rediroff 2>/tmp/clashrelease
release_new=$(cat /tmp/clashrelease | head -1)
[ "$result" = "200" ] && release_new=$(cat /tmp/clashrelease | head -1)
[ -z "$release_new" ] && release_new=master
url=$url@$release_new
fi
@@ -110,13 +110,14 @@ echo -----------------------------------------------
gettar
echo -----------------------------------------------
echo ShellClash 已经安装成功!
[ "$USER" != "root" ] && echo "请执行【source ~/.bashrc &> /dev/null】命令以加载环境变量"
echo -----------------------------------------------
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
echo -----------------------------------------------
}
setdir(){
echo -----------------------------------------------
$echo "\033[33m安装ShellClash至少需要预留约10MB的磁盘空间\033[0m"
$echo "\033[33m安装ShellClash至少需要预留约1MB的磁盘空间\033[0m"
$echo " 1 在\033[32m/etc目录\033[0m下安装(适合路由设备)"
$echo " 2 在\033[32m/usr/share目录\033[0m下安装(适合大多数设备)"
$echo " 3 在\033[32m当前用户目录\033[0m下安装(适合非root用户)"

View File

@@ -11,6 +11,9 @@ getconfig(){
yaml=$clashdir/config.yaml
#检查/读取标识文件
[ ! -f $ccfg ] && echo '#标识clash运行状态的文件不明勿动' > $ccfg
#检查重复行并去除
[ -n "$(awk 'a[$0]++' $ccfg)" ] && awk '!a[$0]++' $ccfg > $ccfg
#使用source加载配置文件
source $ccfg
#设置默认核心资源目录
[ -z "$bindir" ] && bindir=$clashdir
@@ -19,6 +22,7 @@ getconfig(){
[ -z "$redir_port" ] && redir_port=7892
[ -z "$db_port" ] && db_port=9999
[ -z "$dns_port" ] && dns_port=1053
[ -z "$multiport" ] && multiport='53,587,465,995,993,143,80,443'
[ -z "$local_proxy" ] && local_proxy=未开启
#检查mac地址记录
[ ! -f $clashdir/mac ] && touch $clashdir/mac
@@ -29,22 +33,25 @@ getconfig(){
#dashboard目录位置
[ -d $clashdir/ui ] && dbdir=$clashdir/ui && hostdir=":$db_port/ui"
[ -d /www/clash ] && dbdir=/www/clash && hostdir=/clash
#开机自启相关
#开机自启检测
if [ -f /etc/rc.common ];then
[ -n "$(find /etc/rc.d -name '*clash')" ] && autostart=enable_rc || autostart=disable_rc
else
elif [ -w /etc/systemd/system -o -w /usr/lib/systemd/system ];then
[ -n "$(systemctl is-enabled clash.service 2>&1 | grep enable)" ] && autostart=enable_sys || autostart=disable_sys
fi
#开机自启描述
if [ "$start_old" = "已开启" ];then
if [ "$start_old" = "已开启" ]; then
auto="\033[32m保守模式\033[0m"
auto1="代理本机:\033[36m$local_proxy\033[0m"
elif [ "$autostart" = "enable_rc" -o "$autostart" = "enable_sys" ]; then
auto="\033[32m已设置开机启动\033[0m"
auto1="\033[36m禁用\033[0mclash开机启动"
else
elif [ "$autostart" = "disable_rc" -o "$autostart" = "disable_sys" ]; then
auto="\033[31m未设置开机启动\033[0m"
auto1="\033[36m允许\033[0mclash开机启动"
else
auto="\033[32m保守模式\033[0m"
auto1="代理本机:\033[36m$local_proxy\033[0m"
fi
#获取运行模式
[ -z "$redir_mod" ] && [ "$USER" = "root" -o "$USER" = "admin" ] && redir_mod=Redir模式
@@ -77,15 +84,16 @@ getconfig(){
echo -----------------------------------------------
#检查新手引导
if [ -z "$userguide" ];then
sed -i "1i\userguide=1" $ccfg
[ "$res" = 1 ] && source $clashdir/getdate.sh && userguide
setconfig userguide 1
source $clashdir/getdate.sh && userguide
fi
#检查执行权限
[ ! -x $clashdir/start.sh ] && chmod +x $clashdir/start.sh
}
setconfig(){
#参数1代表变量名参数2代表变量值,参数3即文件路径
[ -z "$3" ] && configpath=$clashdir/mark || configpath=$3
sed -i "/${1}*/"d $configpath
echo "${1}=${2}" >> $configpath
[ -n "$(grep ${1} $configpath)" ] && sed -i "s#${1}=.*#${1}=${2}#g" $configpath || echo "${1}=${2}" >> $configpath
}
#启动相关
errornum(){
@@ -95,9 +103,9 @@ errornum(){
startover(){
echo -e "\033[32mclash服务已启动\033[0m"
if [ -n "$hostdir" ];then
echo -e "请使用\033[4;32mhttp://$host$hostdir\033[0m管理内置规则"
echo -e "请使用 \033[4;32mhttp://$host$hostdir\033[0m 管理内置规则"
else
echo -e "可使用\033[4;32mhttp://clash.razord.top\033[0m管理内置规则"
echo -e "可使用 \033[4;32mhttp://clash.razord.top\033[0m 管理内置规则"
echo -e "Host地址:\033[36m $host \033[0m 端口:\033[36m $db_port \033[0m"
echo -e "推荐前往更新菜单安装本地Dashboard面板连接更稳定\033[0m"
fi
@@ -117,10 +125,19 @@ clashstart(){
echo -----------------------------------------------
$clashdir/start.sh start
sleep 1
[ -n "$(pidof clash)" ] && startover || exit 1
[ -n "$(pidof clash)" ] && startover
}
checkrestart(){
echo -----------------------------------------------
echo -e "\033[32m检测到已变更的内容请重启clash服务\033[0m"
echo -----------------------------------------------
read -p "是否现在重启clash服务(1/0) > " res
[ "$res" = 1 ] && clashstart
}
#功能相关
setport(){
[ -z "$secret" ] && secret=未设置
[ -z "$authentication" ] && authentication=未设置
inputport(){
read -p "请输入端口号(1000-65535) > " portx
if [ -z "$portx" ]; then
@@ -136,23 +153,11 @@ setport(){
inputport
else
setconfig $xport $portx
$xport=$portx
echo -e "\033[32m设置成功\033[0m"
setport
fi
}
source $ccfg
[ -z "$secret" ] && secret=未设置
[ -z "$authentication" ] && authentication=未设置
if [ -n "$(pidof clash)" ];then
echo -----------------------------------------------
echo -e "\033[33m检测到clash服务正在运行需要先停止clash服务\033[0m"
read -p "是否停止clash服务(1/0) > " res
if [ "$res" = "1" ];then
$clashdir/start.sh stop
else
clashadv
fi
fi
echo -----------------------------------------------
echo -e " 1 修改Http/Sock5端口 \033[36m$mix_port\033[0m"
echo -e " 2 设置Http/Sock5密码 \033[36m$authentication\033[0m"
@@ -160,6 +165,7 @@ setport(){
echo -e " 4 修改DNS监听端口 \033[36m$dns_port\033[0m"
echo -e " 5 修改面板访问端口: \033[36m$db_port\033[0m"
echo -e " 6 设置面板访问密码: \033[36m$secret\033[0m"
echo -e " 7 修改默认端口过滤: \033[36m$multiport\033[0m"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
@@ -177,7 +183,7 @@ setport(){
read -p "请输入Http/Sock5用户名及密码 > " input
if [ "$input" = "0" ];then
authentication=""
sed -i "/authentication*/"d $ccfg
setconfig authentication
echo 密码已移除!
else
if [ "$local_proxy" = "已开启" ];then
@@ -212,67 +218,89 @@ setport(){
echo -e "\033[32m设置成功\033[0m"
fi
setport
elif [ "$num" = 7 ]; then
echo -----------------------------------------------
echo -e "需配合\033[32m仅代理常用端口\033[0m功能使用"
echo -e "多个端口请用小写逗号分隔,例如:\033[33m143,80,443\033[0m"
echo -e "输入 0 重置为默认端口"
echo -----------------------------------------------
read -p "请输入需要指定代理的端口 > " multiport
if [ -n "$multiport" ]; then
[ "$multiport" = "0" ] && multiport=""
common_ports=已开启
setconfig multiport $multiport
setconfig common_ports $common_ports
echo -e "\033[32m设置成功\033[0m"
fi
setport
fi
}
setdns(){
source $ccfg
if [ "$dns_no" = "已禁用" ];then
read -p "检测到内置DNS已被禁用是否启用内置DNS(1/0) > " res
if [ "$res" = "1" ];then
sed -i "/dns_no*/"d $ccfg
else
clashadv
fi
fi
[ -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'
echo -----------------------------------------------
echo -e "当前基础DNS\033[32m$dns_nameserver\033[0m"
echo -e "fallbackDNS\033[36m$dns_fallback\033[0m"
echo -e "多个DNS地址请用\033[30;47m | \033[0m分隔一次性输入"
echo -e "\033[33m使用redir-host时fallback组暂不支持tls或者https形式的DNS\033[0m"
echo -e "多个DNS地址请用\033[30;47m“|”\033[0m或者\033[30;47m“, ”\033[0m分隔输入"
echo -e "\033[33m必须拥有本地根证书文件才能使用dot/doh类型的加密dns\033[0m"
echo -----------------------------------------------
echo -e " 1 修改\033[32m基础DNS\033[0m"
echo -e " 2 修改\033[36mfallback_DNS\033[0m"
echo -e " 3 \033[33m重置\033[0mDNS配置"
echo -e " 4 禁用内置DNS(慎用)"
echo -e " 5 使用\033[32m加密DNS\033[0m"
echo -e " 0 返回上级菜单"
echo -----------------------------------------------
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
errornum
clashadv
elif [ "$num" = 1 ]; then
read -p "请输入新的DNS > " dns_nameserver
dns_nameserver=$(echo $dns_nameserver | sed 's/|/\,\ /g')
dns_nameserver=$(echo $dns_nameserver | sed 's#|#\,\ #g')
if [ -n "$dns_nameserver" ]; then
setconfig dns_nameserver \'"$dns_nameserver"\'
echo -e "\033[32m设置成功\033[0m"
fi
setdns
elif [ "$num" = 2 ]; then
read -p "请输入新的DNS > " dns_fallback
dns_fallback=$(echo $dns_fallback | sed 's/|/\,\ /g')
if [ -n "$dns_fallback" ]; then
setconfig dns_fallback \'"$dns_fallback"\'
echo -e "\033[32m设置成功\033[0m"
fi
fi
setdns
elif [ "$num" = 3 ]; then
dns_nameserver=""
dns_fallback=""
sed -i "/dns_nameserver*/"d $ccfg
sed -i "/dns_fallback*/"d $ccfg
setconfig dns_nameserver
setconfig dns_fallback
echo -e "\033[33mDNS配置已重置\033[0m"
setdns
elif [ "$num" = 4 ]; then
echo -----------------------------------------------
echo -e "\033[31m仅限搭配其他DNS服务(比如dnsmasq、smartDNS)时使用!\033[0m"
dns_no=已禁用
setconfig dns_no $dns_no
echo -e "\033[33m已禁用内置DNS\033[0m"
clashadv
else
clashadv
setdns
elif [ "$num" = 5 ]; then
source $clashdir/getdate.sh
webget /tmp/ssl_test https://baidu.com echooff rediron skipceroff
if [ "$result" != "200" ];then
echo -----------------------------------------------
echo -e "\033[31m当前设备未安装openssl服务或者没有根证书无法启用\033[0m"
else
dns_nameserver='https://223.5.5.5/dns-query, https://doh.pub/dns-query, tls://dns.rubyfish.cn:853'
dns_fallback='https://1.0.0.1/dns-query, https://8.8.4.4/dns-query, https://doh.opendns.com/dns-query'
setconfig dns_nameserver \'"$dns_nameserver"\'
setconfig dns_fallback \'"$dns_fallback"\'
echo -e "\033[32m设置成功\033[0m"
fi
rm -rf /tmp/ssl_test
sleep 1
setdns
fi
setdns
}
checkport(){
for portx in $dns_port $mix_port $redir_port $db_port ;do
@@ -302,7 +330,7 @@ macfilter(){
echo -----------------------------------------------
read -p "请输入对应序号或直接输入mac地址 > " num
if [ -z "$num" -o "$num" = 0 ]; then
macfilter
i=
elif [ -n "$(echo $num | grep -E '^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$')" ];then
if [ -z "$(cat $clashdir/mac | grep -E "$num")" ];then
echo $num | grep -oE '^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$' >> $clashdir/mac
@@ -310,6 +338,7 @@ macfilter(){
echo -----------------------------------------------
echo -e "\033[31m已添加的设备请勿重复添加\033[0m"
fi
add_mac
elif [ $num -le $(cat $dhcpdir | awk 'END{print NR}') 2>/dev/null ]; then
macadd=$(cat $dhcpdir | awk '{print $2}' | sed -n "$num"p)
if [ -z "$(cat $clashdir/mac | grep -E "$macadd")" ];then
@@ -318,46 +347,50 @@ macfilter(){
echo -----------------------------------------------
echo -e "\033[31m已添加的设备请勿重复添加\033[0m"
fi
add_mac
else
echo -----------------------------------------------
echo -e "\033[31m输入有误请重新输入\033[0m"
add_mac
fi
add_mac
}
del_mac(){
echo -----------------------------------------------
if [ -z "$(cat $clashdir/mac)" ];then
echo -e "\033[31m列表中没有需要移除的设备\033[0m"
macfilter
fi
echo -e "\033[33m序号 设备IP 设备mac地址 设备名称\033[0m"
i=1
for mac in $(cat $clashdir/mac); do
dev_ip=$(cat $dhcpdir | grep $mac | awk '{print $3}') && [ -z "$dev_ip" ] && dev_ip='000.000.00.00'
dev_mac=$(cat $dhcpdir | grep $mac | awk '{print $2}') && [ -z "$dev_mac" ] && dev_mac=$mac
dev_name=$(cat $dhcpdir | grep $mac | awk '{print $4}') && [ -z "$dev_name" ] && dev_name='未知设备'
echo -e " $i \033[32m$dev_ip \033[36m$dev_mac \033[32m$dev_name\033[0m"
i=$((i+1))
done
echo -----------------------------------------------
echo -e "\033[0m 0 或回车 结束删除"
read -p "请输入需要移除的设备的对应序号 > " num
if [ -z "$num" ]||[ "$num" -le 0 ]; then
macfilter
elif [ $num -le $(cat $clashdir/mac | wc -l) ];then
sed -i "${num}d" $clashdir/mac
echo -----------------------------------------------
echo -e "\033[32m对应设备已移除\033[0m"
else
echo -e "\033[33m序号 设备IP 设备mac地址 设备名称\033[0m"
i=1
for mac in $(cat $clashdir/mac); do
dev_ip=$(cat $dhcpdir | grep $mac | awk '{print $3}') && [ -z "$dev_ip" ] && dev_ip='000.000.00.00'
dev_mac=$(cat $dhcpdir | grep $mac | awk '{print $2}') && [ -z "$dev_mac" ] && dev_mac=$mac
dev_name=$(cat $dhcpdir | grep $mac | awk '{print $4}') && [ -z "$dev_name" ] && dev_name='未知设备'
echo -e " $i \033[32m$dev_ip \033[36m$dev_mac \033[32m$dev_name\033[0m"
i=$((i+1))
done
echo -----------------------------------------------
echo -e "\033[31m输入有误请重新输入\033[0m"
echo -e "\033[0m 0 或回车 结束删除"
read -p "请输入需要移除的设备的对应序号 > " num
if [ -z "$num" ]||[ "$num" -le 0 ]; then
n=
elif [ $num -le $(cat $clashdir/mac | wc -l) ];then
sed -i "${num}d" $clashdir/mac
echo -----------------------------------------------
echo -e "\033[32m对应设备已移除\033[0m"
del_mac
else
echo -----------------------------------------------
echo -e "\033[31m输入有误请重新输入\033[0m"
del_mac
fi
fi
del_mac
}
echo -----------------------------------------------
[ -f /var/lib/dhcp/dhcpd.leases ] && dhcpdir='/var/lib/dhcp/dhcpd.leases'
[ -f /var/lib/dhcpd/dhcpd.leases ] && dhcpdir='/var/lib/dhcpd/dhcpd.leases'
[ -f /tmp/dhcp.leases ] && dhcpdir='/tmp/dhcp.leases'
[ -z "$dhcpdir" ] && [ -f /var/lib/dhcp/dhcpd.leases ] && dhcpdir='/var/lib/dhcp/dhcpd.leases'
[ -z "$dhcpdir" ] && [ -f /var/lib/dhcpd/dhcpd.leases ] && dhcpdir='/var/lib/dhcpd/dhcpd.leases'
[ -z "$dhcpdir" ] && [ -f /tmp/dhcp.leases ] && dhcpdir='/tmp/dhcp.leases'
[ -z "$dhcpdir" ] && [ -f /tmp/dnsmasq.leases ] && dhcpdir='/tmp/dnsmasq.leases'
[ -z "$dhcpdir" ] && dhcpdir='/dev/null'
[ -z "$macfilter_type" ] && macfilter_type='黑名单'
[ "$macfilter_type" = "黑名单" ] && macfilter_over='白名单' || macfilter_over='黑名单'
######
@@ -383,9 +416,8 @@ macfilter(){
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
errornum
clashcfg
elif [ "$num" = 0 ]; then
clashcfg
i=
elif [ "$num" = 1 ]; then
macfilter_type=$macfilter_over
setconfig macfilter_type $macfilter_type
@@ -394,8 +426,10 @@ macfilter(){
macfilter
elif [ "$num" = 2 ]; then
add_mac
macfilter
elif [ "$num" = 3 ]; then
del_mac
macfilter
elif [ "$num" = 4 ]; then
:>$clashdir/mac
echo -----------------------------------------------
@@ -473,32 +507,38 @@ localproxy(){
}
clashcfg(){
set_redir_mod(){
set_redir_config(){
setconfig redir_mod $redir_mod
setconfig dns_mod $dns_mod
echo -----------------------------------------------
echo -e "\033[36m已设为 $redir_mod \033[0m"
}
echo -----------------------------------------------
echo -e "当前代理模式为:\033[47;30m $redir_mod \033[0mClash核心为\033[47;30m $clashcore \033[0m"
echo -e "\033[33m切换模式后需要手动重启clash服务以生效\033[0m"
echo -e "\033[36mTun及混合模式必须使用clashpre核心\033[0m"
echo -----------------------------------------------
echo " 1 Redir模式CPU以及内存占用较低"
echo " 但不支持UDP流量转发"
echo " 适合非游戏用户使用"
echo " 2 Tun模式 支持UDP转发且延迟最低"
echo " CPU占用极高只支持fake-ip模式"
echo " 适合游戏用户、非大流量用户"
echo " 3 混合模式: 使用redir转发TCPTun转发UPD"
echo " 速度较快,内存占用略高"
echo " 适合游戏用户、综合用户"
echo " 4 纯净模式: 不设置iptables静态路由"
echo " 必须手动配置http/sock5代理"
echo " 或使用内置的PAC文件配置代理"
echo -e " 1 Redir模式CPU以及内存\033[33m占用较低\033[0m"
echo -e " 但\033[31m不支持UDP\033[0m流量转发"
echo -e " 适合\033[32m非游戏用户\033[0m使用"
echo -e " 2 Tun模式 \033[33m支持UDP转发\033[0m且延迟最低"
echo -e " \033[31mCPU占用极高\033[0m只支持fake-ip模式"
echo -e " 适合\033[32m游戏用户、非大流量用户\033[0m"
echo -e " 3 混合模式: 使用redir转发TCPTun转发UPD"
echo -e " \033[33m速度较快\033[0m\033[31m内存占用略高\033[0m"
echo -e " 适合\033[32m游戏用户、综合用户\033[0m"
echo -e " 4 纯净模式: 不设置iptables静态路由"
echo -e " 必须\033[33m手动配置\033[0mhttp/sock5代理"
echo -e " 或使用内置的PAC文件配置代理"
echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
errornum
clashcfg
elif [ "$num" = 0 ]; then
clashcfg
i=
elif [ "$num" = 1 ]; then
redir_mod=Redir模式
set_redir_config
elif [ "$num" = 2 ]; then
modinfo tun >/dev/null 2>&1
if [ "$?" != 0 ];then
@@ -508,6 +548,7 @@ clashcfg(){
if [ "$res" = 1 ];then
redir_mod=Tun模式
dns_mod=fake-ip
set_redir_config
else
set_redir_mod
fi
@@ -515,10 +556,10 @@ clashcfg(){
echo -----------------------------------------------
echo -e "\033[31m当前核心不支持开启Tun模式请先切换clash核心\033[0m"
sleep 1
clashcfg
else
redir_mod=Tun模式
dns_mod=fake-ip
set_redir_config
fi
elif [ "$num" = 3 ]; then
modinfo tun >/dev/null 2>&1
@@ -527,6 +568,7 @@ clashcfg(){
read -p "是否强制开启?可能无法正常使用!(1/0) > " res
if [ "$res" = 1 ];then
redir_mod=混合模式
set_redir_config
else
set_redir_mod
fi
@@ -534,12 +576,13 @@ clashcfg(){
echo -----------------------------------------------
echo -e "\033[31m当前核心不支持开启Tun模式请先切换clash核心\033[0m"
sleep 1
clashcfg
else
redir_mod=混合模式
set_redir_config
fi
elif [ "$num" = 4 ]; then
redir_mod=纯净模式
redir_mod=纯净模式
set_redir_config
echo -----------------------------------------------
echo -e "\033[33m当前模式需要手动在设备WiFi或应用中配置HTTP或sock5代理\033[0m"
echo -e "HTTP/SOCK5代理服务器地址\033[30;47m$host\033[0m;端口均为:\033[30;47m$mix_port\033[0m"
@@ -549,40 +592,37 @@ clashcfg(){
sleep 2
else
errornum
clashcfg
fi
setconfig redir_mod $redir_mod
setconfig dns_mod $dns_mod
echo -----------------------------------------------
echo -e "\033[36m已设为 $redir_mod \033[0m"
}
set_dns_mod(){
echo -----------------------------------------------
echo -e "当前DNS运行模式为\033[47;30m $dns_mod \033[0m"
echo -e "\033[33m切换模式后需要手动重启clash服务以生效\033[0m"
echo -----------------------------------------------
echo " 1 fake-ip模式 响应速度更快"
echo " 可能与某些局域网设备有冲突"
echo " 2 redir_host模式兼容性更好"
echo " 不支持Tun模式可能存在DNS污染"
echo -e " 1 fake-ip模式 \033[32m响应速度更快\033[0m"
echo -e " 可能与某些局域网设备有冲突"
echo -e " 2 redir_host模式\033[32m兼容性更好\033[0m"
echo -e " 不支持Tun模式可能存在DNS污染"
echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
errornum
clashcfg
elif [ "$num" = 0 ]; then
clashcfg
i=
elif [ "$num" = 1 ]; then
dns_mod=fake-ip
setconfig dns_mod $dns_mod
echo -----------------------------------------------
echo -e "\033[36m已设为 $dns_mod 模式!!\033[0m"
elif [ "$num" = 2 ]; then
dns_mod=redir_host
setconfig dns_mod $dns_mod
echo -----------------------------------------------
echo -e "\033[36m已设为 $dns_mod 模式!!\033[0m"
else
errornum
clashcfg
fi
setconfig dns_mod $dns_mod
echo -----------------------------------------------
echo -e "\033[36m已设为 $dns_mod 模式!!\033[0m"
}
#获取设置默认显示
@@ -599,8 +639,8 @@ clashcfg(){
echo -e " 1 切换Clash运行模式: \033[36m$redir_mod\033[0m"
echo -e " 2 切换DNS运行模式 \033[36m$dns_mod\033[0m"
echo -e " 3 跳过本地证书验证: \033[36m$skip_cert\033[0m ————解决节点证书验证错误"
echo -e " 4 只代理常用端口: \033[36m$common_ports\033[0m ————用于屏蔽P2P流量"
echo -e " 5 过滤局域网mac地址 \033[36m$mac_return\033[0m ————当前为$macfilter_type模式"
echo -e " 4 只代理常用端口: \033[36m$common_ports\033[0m ————用于过滤P2P流量"
echo -e " 5 过滤局域网设备 \033[36m$mac_return\033[0m ————使用黑名单/白名单进行过滤"
echo -e " 6 设置本机代理服务: \033[36m$local_proxy\033[0m ————使用环境变量或GUI/api配置本机代理"
echo -----------------------------------------------
echo -e " 9 \033[32m重启\033[0mclash服务"
@@ -609,9 +649,8 @@ clashcfg(){
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
errornum
clashsh
elif [ "$num" = 0 ]; then
clashsh
i=
elif [ "$num" = 1 ]; then
if [ "$USER" != "root" -a "$USER" != "admin" ];then
echo -----------------------------------------------
@@ -639,9 +678,9 @@ clashcfg(){
clashcfg
elif [ "$num" = 4 ]; then
echo -----------------------------------------------
echo -----------------------------------------------
if [ "$common_ports" = "未开启" ] > /dev/null 2>&1; then
echo -e "\033[33m已设为仅代理53,587,465,995,993,143,80,443等常用端口!!\033[0m"
echo -e "\033[33m已设为仅代理$multiport等常用端口!!\033[0m"
common_ports=已开启
else
echo -e "\033[33m已设为代理全部端口\033[0m"
@@ -652,6 +691,7 @@ clashcfg(){
elif [ "$num" = 5 ]; then
macfilter
clashcfg
elif [ "$num" = 6 ]; then
localproxy
@@ -660,10 +700,8 @@ clashcfg(){
elif [ "$num" = 9 ]; then
clashstart
clashsh
else
errornum
clashsh
fi
}
clashadv(){
@@ -683,8 +721,8 @@ clashadv(){
echo -e " 2 启用ipv6支持: \033[36m$ipv6_support\033[0m ————实验性功能,可能不稳定"
echo -e " 3 Redir模式udp转发: \033[36m$tproxy_mod\033[0m ————依赖iptables-mod-tproxy"
echo -e " 4 启用小闪存模式: \033[36m$mini_clash\033[0m ————启动时方下载核心及数据库文件"
echo -e " 5 配置内置DNS服务: \033[36m$dns_no\033[0m"
echo -e " 6 手动指定clash运行端口及秘钥"
echo -e " 5 配置内置DNS服务 \033[36m$dns_no\033[0m"
echo -e " 6 手动指定相关服务端口及秘钥"
echo -e " 7 使用自定义配置"
echo -----------------------------------------------
echo -e " 8 \033[31m重置\033[0m配置文件"
@@ -694,9 +732,8 @@ clashadv(){
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
errornum
clashsh
elif [ "$num" = 0 ]; then
clashsh
i=
elif [ "$num" = 2 ]; then
echo -----------------------------------------------
@@ -780,11 +817,31 @@ clashadv(){
clashadv
elif [ "$num" = 5 ]; then
setdns
source $ccfg
if [ "$dns_no" = "已禁用" ];then
read -p "检测到内置DNS已被禁用是否启用内置DNS(1/0) > " res
if [ "$res" = "1" ];then
setconfig dns_no
setdns
fi
else
setdns
fi
clashadv
elif [ "$num" = 6 ]; then
setport
source $ccfg
if [ -n "$(pidof clash)" ];then
echo -----------------------------------------------
echo -e "\033[33m检测到clash服务正在运行需要先停止clash服务\033[0m"
read -p "是否停止clash服务(1/0) > " res
if [ "$res" = "1" ];then
$clashdir/start.sh stop
setport
fi
else
setport
fi
clashadv
elif [ "$num" = 7 ]; then
@@ -829,15 +886,50 @@ EOF
elif [ "$num" = 9 ]; then
clashstart
sleep 1
clashsh
else
errornum
clashsh
fi
}
clashcron(){
setcron(){
setcrontab(){
#设置具体时间
echo -----------------------------------------------
read -p "请输入小时0-23 > " num
if [ -z "$num" ]; then
errornum
setcron
elif [ $num -gt 23 ] || [ $num -lt 0 ]; then
errornum
setcron
else
hour=$num
echo -----------------------------------------------
read -p "请输入分钟0-60 > " num
if [ -z "$num" ]; then
errornum
setcron
elif [ $num -gt 60 ] || [ $num -lt 0 ]; then
errornum
setcron
else
min=$num
echo -----------------------------------------------
echo 将在$week1的$hour点$min分$cronname(旧的任务会被覆盖)
read -p "是否确认添加定时任务?(1/0) > " res
if [ "$res" = '1' ]; then
cronwords="$min $hour * * $week $cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname"
crontab -l > /tmp/conf
sed -i "/$cronname/d" /tmp/conf
echo "$cronwords" >> /tmp/conf && crontab /tmp/conf
rm -f /tmp/conf
echo -----------------------------------------------
echo -e "\033[31m定时任务已添加\033[0m"
fi
fi
fi
}
echo -----------------------------------------------
echo -e " 正在设置:\033[32m$cronname\033[0m定时任务"
echo -e " 输入 1-7 对应\033[33m每周相应天\033[0m运行"
@@ -850,60 +942,24 @@ clashcron(){
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
errornum
clashcron
elif [ "$num" = 0 ]; then
clashcron
i=
elif [ "$num" = 9 ]; then
crontab -l > /tmp/conf && sed -i "/$cronname/d" /tmp/conf && crontab /tmp/conf
rm -f /tmp/conf
echo -----------------------------------------------
echo -e "\033[31m定时任务$cronname已删除\033[0m"
clashcron
elif [ "$num" = 8 ]; then
week='*'
week1=每天
echo 已设为每天定时运行!
setcrontab
else
week=$num
week1=每周$week
echo 已设为每周 $num 运行!
setcrontab
fi
#设置具体时间
echo -----------------------------------------------
read -p "请输入小时0-23 > " num
if [ -z "$num" ]; then
errornum
setcron
elif [ $num -gt 23 ] || [ $num -lt 0 ]; then
errornum
setcron
else
hour=$num
fi
echo -----------------------------------------------
read -p "请输入分钟0-60 > " num
if [ -z "$num" ]; then
errornum
setcron
elif [ $num -gt 60 ] || [ $num -lt 0 ]; then
errornum
setcron
else
min=$num
fi
echo -----------------------------------------------
echo 将在$week1的$hour点$min分$cronname(旧的任务会被覆盖)
read -p "是否确认添加定时任务?(1/0) > " res
if [ "$res" = '1' ]; then
cronwords="$min $hour * * $week $cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname"
crontab -l > /tmp/conf
sed -i "/$cronname/d" /tmp/conf
echo "$cronwords" >> /tmp/conf && crontab /tmp/conf
rm -f /tmp/conf
echo -----------------------------------------------
echo -e "\033[31m定时任务已添加\033[0m"
fi
clashcron
}
#定时任务菜单
echo -----------------------------------------------
@@ -922,31 +978,30 @@ clashcron(){
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
errornum
clashsh
elif [ "$num" = 0 ]; then
clashsh
i=
elif [ "$num" = 1 ]; then
cronname=重启clash服务
cronset="$clashdir/start.sh restart"
setcron
clashcron
elif [ "$num" = 2 ]; then
cronname=停止clash服务
cronset="$clashdir/start.sh stop"
setcron
clashcron
elif [ "$num" = 3 ]; then
cronname=开启clash服务
cronset="$clashdir/start.sh start"
setcron
clashcron
elif [ "$num" = 4 ]; then
cronname=更新订阅链接
cronset="$clashdir/start.sh getyaml"
cronset="$clashdir/start.sh updateyaml"
setcron
clashcron
else
errornum
clashsh
fi
}
#主菜单
@@ -975,18 +1030,22 @@ clashsh(){
elif [ "$num" = 1 ]; then
clashstart
sleep 1
clashsh
exit;
elif [ "$num" = 2 ]; then
checkcfg=$(cat $ccfg)
clashcfg
if [ -n "$PID" ];then
checkcfg_new=$(cat $ccfg)
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
clashsh
elif [ "$num" = 3 ]; then
$clashdir/start.sh stop
echo -----------------------------------------------
echo -e "\033[31mClash服务已停止\033[0m"
echo -----------------------------------------------
exit;
clashsh
elif [ "$num" = 4 ]; then
echo -----------------------------------------------
@@ -1011,18 +1070,32 @@ clashsh(){
elif [ "$num" = 5 ]; then
clashcron
clashsh
elif [ "$num" = 6 ]; then
source $clashdir/getdate.sh && clashlink
clashsh
elif [ "$num" = 7 ]; then
checkcfg=$(cat $ccfg)
clashadv
if [ -n "$PID" ];then
checkcfg_new=$(cat $ccfg)
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
clashsh
elif [ "$num" = 8 ]; then
source $clashdir/getdate.sh && testcommand
elif [ "$num" = 9 ]; then
checkcfg=$(cat $ccfg)
source $clashdir/getdate.sh && update
if [ -n "$PID" ];then
checkcfg_new=$(cat $ccfg)
[ "$checkcfg" != "$checkcfg_new" ] && checkrestart
fi
clashsh
else
errornum

View File

@@ -7,6 +7,7 @@ SERVICE_WRITE_PID=1
USE_PROCD=1
#获取目录
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

File diff suppressed because it is too large Load Diff

View File

@@ -4,14 +4,14 @@
#脚本内部工具
getconfig(){
#加载配置文件
[ -z "$clashdir" ] && source /etc/profile > /dev/null
[ -z "$clashdir" ] && source ~/.bashrc > /dev/null
[ -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=纯净模式
[ -z "$redir_mod" ] && redir_mod=Redir模式
[ -z "$skip_cert" ] && skip_cert=已开启
[ -z "$common_ports" ] && common_ports=已开启
[ -z "$dns_mod" ] && dns_mod=redir_host
@@ -26,38 +26,49 @@ getconfig(){
[ -z "$dns_port" ] && dns_port=1053
[ -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='53,587,465,995,993,143,80,443'
#是否代理常用端口
[ "$common_ports" = "已开启" ] && ports='-m multiport --dports 53,587,465,995,993,143,80,443'
[ "$common_ports" = "已开启" ] && ports="-m multiport --dports $multiport"
}
setconfig(){
#参数1代表变量名参数2代表变量值,参数3即文件路径
[ -z "$3" ] && configpath=$clashdir/mark || configpath=$3
sed -i "/${1}*/"d $configpath
echo "${1}=${2}" >> $configpath
[ -n "$(grep ${1} $configpath)" ] && sed -i "s#${1}=.*#${1}=${2}#g" $configpath || echo "${1}=${2}" >> $configpath
}
compare(){
if command -v cmp >/dev/null 2>&1; then
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
}
webget(){
[ -n "$(pidof clash)" ] && export all_proxy="http://$authentication@127.0.0.1:$mix_port" #设置临时http代理
[ -n "$(pidof clash)" ] && export all_proxy="http://$authentication@127.0.0.1:$mix_port" #设置临时http代理
#参数【$1】代表下载目录【$2】代表在线地址
#参数【$3】代表输出显示【$4】不启用重定向
#参数【$5】代表验证证书
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)
[ "$4" = "rediroff" ] && redirect='' || redirect='-L'
[ "$5" = "skipceroff" ] && certificate='' || certificate='-k'
result=$(curl -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o $1 $2)
[ "$result" != "200" ] && export all_proxy="" && result=$(curl -w %{http_code} --connect-timeout 3 $progress $redirect $certificate -o $1 $2)
else
[ "$3" = "echooff" ] && progress='-q' || progress='-q --show-progress'
[ "$3" = "echoon" ] && progress=''
[ -z "$4" ] && redirect='' || redirect='--max-redirect=0'
wget -Y on $progress $redirect --no-check-certificate --timeout=5 -O $1 $2
[ $? -eq 0 ] && result="200"
[ "$4" = "rediroff" ] && redirect='--max-redirect=0' || redirect=''
[ "$5" = "skipceroff" ] && certificate='' || certificate='--no-check-certificate'
wget -Y on $progress $redirect $certificate --timeout=3 -O $1 $2
if [ "$?" != "0" ];then
wget $progress $redirect $certificate --timeout=3 -O $1 $2
[ "$?" = "0" ] && result="200"
else
result="200"
fi
fi
export all_proxy=''
export all_proxy=""
}
logger(){
[ -n "$2" ] && echo -e "\033[$2m$1\033[0m"
@@ -86,7 +97,7 @@ getyaml(){
Server=`sed -n ""$server_link"p"<<EOF
subcon.dlj.tf
subconverter.herokuapp.com
subcon.py6.pw
subconverter-web.now.sh
api.dler.io
api.wcc.best
EOF`
@@ -148,8 +159,8 @@ EOF`
fi
else
Https=""
#检测节点
if [ -z "$(cat $yamlnew | grep 'server:' | grep -v 'nameserver')" ];then
#检测节点或providers
if [ -z "$(cat $yamlnew | grep -E 'server:|proxy-providers:' | grep -v 'nameserver')" ];then
echo -----------------------------------------------
logger "获取到了配置文件,但似乎并不包含正确的节点信息!" 31
echo -----------------------------------------------
@@ -170,33 +181,38 @@ EOF`
#检测不支持的加密协议
if cat $yamlnew | grep 'cipher: chacha20,' >/dev/null;then
echo -----------------------------------------------
logger "支持chacha20加密请更换节点加密协议" 31
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 ] && rm -f $yamlnew || mv -f $yaml $yaml.bak && mv -f $yamlnew $yaml
[ "$?" = 0 ] || mv -f $yaml $yaml.bak && mv -f $yamlnew $yaml
else
mv -f $yamlnew $yaml
fi
echo 配置文件已生成正在启动clash使其生效
#重启clash服务
$0 stop
$0 start
if [ "$?" = 0 ];then
logger "配置文件获取成功clash服务已启动"
exit 0
else
if [ -f $yaml.bak ];then
$0 stop
mv -f $yaml.bak $yaml
$0 start
[ "$?" = 0 ] && logger "已还原配置文件并重启clash" 32 && exit 0
logger "已还原配置文件但依然无法启动clash" 31 && exit 1
fi
fi
echo -e "\033[32m已成功获取配置文件\033[0m"
rm -rf $yamlnew
exit 0
fi
}
modify_yaml(){
@@ -386,27 +402,29 @@ start_udp(){
}
stop_iptables(){
#重置iptables规则
iptables -t nat -D PREROUTING -p tcp -j clash > /dev/null 2>&1
iptables -t nat -D PREROUTING -p udp -j clash_dns > /dev/null 2>&1
iptables -t nat -D PREROUTING -p tcp -d 8.8.8.8 -j clash_dns > /dev/null 2>&1
iptables -t nat -D PREROUTING -p tcp -d 8.8.4.4 -j clash_dns > /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 -F clash_dns > /dev/null 2>&1
iptables -t nat -X clash_dns > /dev/null 2>&1
iptables -D FORWARD -o utun -j ACCEPT > /dev/null 2>&1
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 -j clash 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_dns 2> /dev/null
iptables -t nat -D PREROUTING -p tcp -d 8.8.4.4 -j clash_dns 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
#重置udp规则
iptables -t mangle -D PREROUTING -p udp -j clash > /dev/null 2>&1
iptables -t mangle -F clash > /dev/null 2>&1
iptables -t mangle -X clash > /dev/null 2>&1
iptables -t mangle -D PREROUTING -p udp -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 > /dev/null 2>&1
ip6tables -t nat -D PREROUTING -p udp -j clashv6_dns > /dev/null 2>&1
ip6tables -t nat -F clashv6 > /dev/null 2>&1
ip6tables -t nat -X clashv6 > /dev/null 2>&1
ip6tables -t nat -F clashv6_dns > /dev/null 2>&1
ip6tables -t nat -X clashv6_dns > /dev/null 2>&1
ip6tables -D FORWARD -o utun -j ACCEPT > /dev/null 2>&1
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
}
#面板配置保存相关
web_save(){
@@ -422,10 +440,18 @@ web_save(){
fi
}
#使用get_save获取面板节点设置
get_save http://localhost:${db_port}/proxies | awk -F "{" '{for(i=1;i<=NF;i++) print $i}' | grep -E '^"all".*"Selector"' | grep -oE '"name".*"now".*",' | sed 's/"name"://g' | sed 's/"now"://g'| sed 's/"//g' > /tmp/clash_web_save_$USER
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
#对比文件,如果有变动且不为空则写入磁盘,否则清除缓存
[ ! -s /tmp/clash_web_save_$USER ] && 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
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(){
@@ -437,8 +463,7 @@ web_restore(){
}
#设置循环检测clash面板端口
i=1
while [ $i -lt 10 ]
do
while [ $i -lt 10 ];do
sleep 1
if curl --version > /dev/null 2>&1;then
test=$(curl -s http://localhost:${db_port})
@@ -475,7 +500,7 @@ function FindProxyForURL(url, host) {
)
return "DIRECT";
else
return "SOCKS5 $host:$mix_port; PROXY $host:$mix_port; DIRECT;"
return "PROXY 192.168.31.1:7890; DIRECT; SOCKS5 192.168.31.1:7890"
}
EOF
compare /tmp/clash_pac $bindir/ui/pac
@@ -489,10 +514,12 @@ bfstart(){
#检查clash核心
if [ ! -f $bindir/clash ];then
if [ -f $clashdir/clash ];then
mv $clashdir/clash $bindir/clash && chmod 777 $bindir/clash
mv $clashdir/clash $bindir/clash && chmod +x $bindir/clash
else
logger "未找到clash核心正在下载" 33
[ -z "$clashcore" ] && [ "$redir_mod" = "混合模式" -o "$redir_mod" = "Tun模式" ] && clashcore=clashpre || clashcore=clash
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
webget $bindir/clash "$update_url/bin/$clashcore/clash-linux-$cpucore"
@@ -508,10 +535,11 @@ bfstart(){
mv $clashdir/Country.mmdb $bindir/Country.mmdb
else
logger "未找到GeoIP数据库正在下载" 33
webget $bindir/Country.mmdb $update_url/bin/Country.mmdb
[ -z "$geotype" ] && geotype=cn_mini.mmdb
webget $bindir/Country.mmdb $update_url/bin/$geotype
[ "$?" = 1 ] && logger "数据库下载失败,已退出!" 31 && rm -f $bindir/Country.mmdb && exit 1
GeoIP_v=$(date +"%Y%m%d")
setconfig GeoIP_v $GeoIP_v
Geo_v=$(date +"%Y%m%d")
setconfig Geo_v $Geo_v
fi
fi
#检查dashboard文件
@@ -532,11 +560,12 @@ bfstart(){
fi
}
afstart(){
#读取配置文件
getconfig
$bindir/clash -t -d $bindir >/dev/null
if [ "$?" = 0 ];then
#修改iptables规则使流量进入clash
#设置iptables转发规则
[ "$redir_mod" != "纯净模式" ] && [ "$dns_no" != "已禁用" ] && start_dns
[ "$redir_mod" != "纯净模式" ] && [ "$redir_mod" != "Tun模式" ] && start_redir
[ "$redir_mod" = "Redir模式" ] && [ "$tproxy_mod" = "已开启" ] && start_udp
@@ -549,7 +578,8 @@ afstart(){
[ -f $clashdir/web_save ] && web_restore & #后台还原面板配置
else
logger "clash服务启动失败请查看报错信息" 31
logger `$bindir/clash -t -d $bindir 1>&0` 0
$bindir/clash -t -d $bindir
echo "$($bindir/clash -t -d $bindir)" >> $clashdir/log
$0 stop
exit 1
fi
@@ -612,8 +642,12 @@ getyaml)
getconfig
getyaml
;;
updateyaml)
$0 getyaml
$0 restart
;;
webget)
webget $1 $2 $3 $4
webget $2 $3 $4 $5
;;
web_save)
getconfig
@@ -623,6 +657,9 @@ daemon)
getconfig
cronset '#clash保守模式守护进程' "*/1 * * * * test -z \"$(pidof clash)\" && $clashdir/start.sh restart #clash保守模式守护进程"
;;
cronset)
cronset $2 $3
;;
set_proxy)
getconfig
#GNOME配置