46 Commits

Author SHA1 Message Date
juewuy
4079d1525f v1.0.0beta15
~新增对使用mips-softfloat核心设备的适配
~新增手动指定核心架构的菜单
~增加了按照关键字白名单筛选节点的功能
~新增了帮助:-h,测试:-t脚本运行参数
~优化节点保存方式,现在每10分钟检测一次,仅在检测到文件变动后方进行保存
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
~修复设置本机代理时直接跳出的bug
~优化安装脚本,增加root用户检测
~优化ipv6dns拦截方式
~回滚对循环计算的方式
2020-10-14 17:22:13 +08:00
juewuy
0219fcd94e v1.0.0beta14fix5
~新增对使用mips-softfloat核心设备的适配
~优化节点保存方式,现在每10分钟检测一次,仅在检测到文件变动后方进行保存
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
~修复设置本机代理时直接跳出的bug
~优化安装脚本,增加root用户检测
~优化ipv6dns拦截方式
~回滚对循环计算的方式
2020-10-14 16:19:44 +08:00
juewuy
30b3a34d8e v1.0.0beta14fix4
~优化节点保存方式,现在每10分钟检测一次,仅在检测到文件变动后方进行保存
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
~修复设置本机代理时直接跳出的bug
~优化安装脚本,增加root用户检测
~优化ipv6dns拦截方式
~回滚对循环计算的方式
2020-10-14 09:39:42 +08:00
juewuy
8dc3c3fdc2 v1.0.0beta14fix5
~优化节点保存方式,现在每10分钟检测一次,仅在检测到文件变动后方进行保存
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
~修复设置本机代理时直接跳出的bug
~优化安装脚本,增加root用户检测
~优化ipv6dns拦截方式
~回滚对循环计算的方式
2020-10-14 09:12:23 +08:00
juewuy
68e7519fdf v1.0.0beta14fix4
~优化节点保存方式,现在每10分钟检测一次,仅在检测到文件变动后方进行保存
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
~修复设置本机代理时直接跳出的bug
~优化安装脚本,增加root用户检测
~优化ipv6dns拦截方式
~修复部分设备开机启动显示不正常的bug
~修复部分设备时间显示不正常的bug
2020-10-13 17:25:04 +08:00
juewuy
fd267e6316 v1.0.0beta14fix4
~优化节点保存方式,现在每10分钟检测一次,仅在检测到文件变动后方进行保存
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
~修复设置本机代理时直接跳出的bug
~优化安装脚本,增加root用户检测
~优化ipv6dns拦截方式
~修复部分设备开机启动显示不正常的bug
~修复部分设备时间显示不正常的bug
2020-10-13 17:24:29 +08:00
juewuy
c1ac05fd36 v1.0.0beta14fix4
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
~修复设置本机代理时直接跳出的bug
~优化安装脚本,增加root用户检测
~优化ipv6dns拦截方式
~修复部分设备开机启动显示不正常的bug
~修复部分设备时间显示不正常的bug
2020-10-13 17:06:21 +08:00
juewuy
fc5dc18348 v1.0.0beta14fix4
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
~修复设置本机代理时直接跳出的bug
~优化安装脚本,增加root用户检测
~优化ipv6dns拦截方式
~修复部分设备开机启动显示不正常的bug
~修复部分设备时间显示不正常的bug
2020-10-12 17:17:30 +08:00
juewuy
94c0ed99ef v1.0.0beta14fix4
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
~修复设置本机代理时直接跳出的bug
~优化安装脚本,增加root用户检测
~优化ipv6dns拦截方式
2020-10-12 16:48:30 +08:00
juewuy
5598809f57 Update README.md 2020-10-12 15:01:35 +08:00
juewuy
9ea1fb7df6 Rename install.sh to install_cdn.sh 2020-10-12 10:40:35 +08:00
juewuy
f607cfbc70 Update install.sh 2020-10-12 10:38:05 +08:00
juewuy
8484ffae3b v1.0.0beta14fix3
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
~修复设置本机代理时直接跳出的bug
~优化安装脚本,增加root用户检测
2020-10-11 21:33:40 +08:00
juewuy
87ae8b78be v1.0.0beta14fix3
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
~修复设置本机代理时直接跳出的bug
~优化安装脚本,增加root用户检测
2020-10-11 21:30:20 +08:00
juewuy
156d9193ee v1.0.0beta14fix2
~修复部分ssr节点不可用的bug
~mac过滤功能增加移除单个设备以及添加全部设备功能
2020-10-11 13:08:02 +08:00
juewuy
12f3babe47 v1.0.0beta14fix1
~修复部分ssr节点不可用的bug
2020-10-11 00:03:03 +08:00
juewuy
1f00c32e5a v1.0.0beta14
~新增保存面板配置功能(每小时/手动停止服务时自动保存)
~同步最新1.2.0版本clash核心以及pre版核心
~同步最新版GeoIP数据库
~修改导入配置文件时的规则,现在会自动尝试最多5次
~修复了使用systemd无法正常启动进程的bug
~修复了导入未经转换配置文件时报错的bug
~屏蔽了部分已经无法使用的sub后端服务器地址
~修改了本机代理实现方式,现在会随着clash服务停止而取消
2020-10-10 17:07:14 +08:00
juewuy
cd8a885618 v1.0.0beta14
~新增保存面板配置功能(每小时/手动停止服务时自动保存)
~同步最新1.2.0版本clash核心以及pre版核心
~同步最新版GeoIP数据库
~修改导入配置文件时的规则,现在会自动尝试最多5次
~修复了使用systemd无法正常启动进程的bug
~修复了导入未经转换配置文件时报错的bug
~屏蔽了部分已经无法使用的sub后端服务器地址
~修改了本机代理实现方式,现在会随着clash服务停止而取消
2020-10-10 17:02:53 +08:00
juewuy
a33da9f15f v1.0.0beta14
~同步最新1.2.0版本clash核心以及pre版核心
~同步最新版GeoIP数据库
~修复了使用systemd无法正常启动进程的bug
~修复了导入未经转换配置文件时报错的bug
~屏蔽了部分已经无法使用的sub后端服务器地址
~修改了本机代理实现方式,现在会随着clash服务停止而取消
2020-10-10 09:00:23 +08:00
juewuy
cb413622eb v1.0.0beta13fix3
~修复了使用systemd无法正常启动进程的bug
2020-10-09 19:21:28 +08:00
juewuy
420aeeba3d v1.0.0beta13fix2
~修复了导入未经转换配置文件时报错的bug
~屏蔽了部分已经无法使用的sub后端服务器地址
~修改了本机代理实现方式,现在会随着clash服务停止而取消
2020-10-07 16:31:39 +08:00
juewuy
8827f2d561 v1.0.0beta13fix1
~修复了导入未经转换配置文件时报错的bug
~屏蔽了部分已经无法使用的sub后端服务器地址
2020-10-07 11:21:05 +08:00
juewuy
23b8c2265e v1.0.0beta13
~支持Padavan系统(仅保守模式)
~进阶功能菜单增加修改默认端口功能
~优化版本检测机制以及显示效果
~优化定时任务功能,修复部分设备不可用的bug
~优化检测端口占用流程
~优化安装脚本安装流程,支持覆盖安装
~修复部分设备因开启ipv6导致的DNS污染(待测试)
~修复小米R2D等博通芯片设备使用ARMv7核心报错的bug
~修复部分旧设备无法正确显示运行时间的bug
~修复无法正常导入个人更新源的bug
2020-10-06 20:10:07 +08:00
juewuy
6dc8545ddd v1.0.0beta13
~支持Padavan系统(仅保守模式)
~进阶功能菜单增加修改默认端口功能
~优化版本检测机制以及显示效果
~优化定时任务功能,修复部分设备不可用的bug
~优化检测端口占用流程
~优化安装脚本安装流程,支持覆盖安装
~修复部分设备因开启ipv6导致的DNS污染(待测试)
~修复小米R2D等博通芯片设备使用ARMv7核心报错的bug
~修复部分旧设备无法正确显示运行时间的bug
~修复无法正常导入个人更新源的bug
2020-10-06 20:05:07 +08:00
juewuy
dea883c011 v1.0.0beta13
~支持Padavan系统(仅保守模式)
~进阶功能菜单增加修改默认端口功能
~优化版本检测机制以及显示效果
~优化定时任务功能,修复部分设备不可用的bug
~优化检测端口占用流程
~优化安装脚本安装流程,支持覆盖安装
~修复部分设备因开启ipv6导致的DNS污染(待测试)
~修复小米R2D等博通芯片设备使用ARMv7核心报错的bug
~修复部分旧设备无法正确显示运行时间的bug
~修复无法正常导入个人更新源的bug
2020-10-06 17:56:17 +08:00
juewuy
7baff049dc v1.0.0pre1
~增加fake-ip屏蔽域名列表,修复各种fakeip下服务出错
~增加fallbackDNS跳过GeoIPCN,优化响应速度
~使用upx3.9.3版本压缩mipsle核心文件,优化兼容性(待测试)
~调整导入订阅时的提示信息,尽可能减少歧义
~屏蔽导入节点功能,请自行转换配置文件!
~增加新版本clash核心对内置hosts的支持(待测试)
2020-10-03 17:05:11 +08:00
juewuy
78d8c31f57 v1.0.0pre1
~增加fake-ip屏蔽域名列表,修复各种fakeip下服务出错
~增加fallbackDNS跳过GeoIPCN,优化响应速度
~使用upx3.9.3版本压缩mipsle核心文件,优化兼容性(待测试)
~调整导入订阅时的提示信息,尽可能减少歧义
~屏蔽导入节点功能,请自行转换配置文件!
2020-10-03 15:51:14 +08:00
juewuy
c4b8836b6e v1.0.0pre1
~增加fake-ip屏蔽域名列表,修复各种fakeip下服务出错
~增加fallbackDNS跳过GeoIPCN,优化响应速度
~使用upx3.9.3版本压缩mipsle核心文件,优化兼容性(待测试)
~调整导入订阅时的提示信息,尽可能减少歧义
~屏蔽导入节点功能,请自行转换配置文件!
2020-10-02 11:56:42 +08:00
juewuy
da80a6bba8 v1.0.0pre1
~增加fake-ip屏蔽域名列表,修复各种fakeip下服务出错
~增加fallbackDNS跳过GeoIPCN,优化响应速度
~使用upx3.9.3压缩mipsle核心文件,优化兼容性
~调整导入节点时的提示信息,尽可能减少歧义
2020-10-02 11:29:09 +08:00
juewuy
f0d2b7e16c v1.0.0pre1
~增加fake-ip屏蔽域名列表,修复各种fakeip下服务出错
~增加fallbackDNS跳过GeoIPCN,优化响应速度
~不再使用upx压缩mipsle核心文件,优化兼容性
~调整导入节点时的提示信息,尽可能减少歧义
2020-10-02 09:43:46 +08:00
juewuy
3ad9294037 v1.0.0pre1
~增加fake-ip屏蔽域名列表,修复各种fakeip下服务出错
~增加fallbackDNS跳过GeoIPCN,优化响应速度
2020-10-02 09:19:38 +08:00
juewuy
eaac6ea43f v1.0.0beta11
~同步最新GeoIP数据库
~修复启动失败后依然提示服务启动的bug
~屏蔽经常出现的netstat命令提示
~优化节点链接导入功能
~修复部分设备开启ipv6后造成dns污染的问题
~修复cdn更新脚本或核心失败的bug
2020-10-02 09:17:04 +08:00
juewuy
100a32f2a3 Merge branch 'master' of https://github.com/juewuy/clash-for-Miwifi into master 2020-10-02 09:16:27 +08:00
juewuy
d5b1bfa0f5 v1.0.0beta11
~同步最新GeoIP数据库
~修复启动失败后依然提示服务启动的bug
~屏蔽经常出现的netstat命令提示
~优化节点链接导入功能
~修复部分设备开启ipv6后造成dns污染的问题
~修复cdn更新脚本或核心失败的bug
2020-10-02 09:16:12 +08:00
juewuy
0fec04488e Update README.md 2020-10-02 07:36:44 +08:00
juewuy
ac2386be93 v1.0.0beta11
~同步最新GeoIP数据库
~修复启动失败后依然提示服务启动的bug
~屏蔽经常出现的netstat命令提示
~优化节点链接导入功能
~修复部分设备开启ipv6后造成dns污染的问题
2020-10-01 19:17:54 +08:00
juewuy
f16ba5a49d v1.0.0beta11
~同步最新GeoIP数据库
~修复启动失败后依然提示服务启动的bug
~屏蔽经常出现的netstat命令提示
~优化节点链接导入功能
~修复部分设备开启ipv6后造成dns污染的问题
2020-10-01 19:14:29 +08:00
juewuy
b83104a888 v1.0.0beta10fix3
~修复启动失败后依然提示服务启动的bug
~屏蔽经常出现的netstat命令提示
~优化节点链接导入功能
~修复部分设备开启ipv6后造成dns污染的问题
2020-10-01 18:45:26 +08:00
juewuy
e9674a1ca6 v1.0.0beta10fix2
~增加大量订阅内置规则
~修复偶尔无法正常更新的bug
~修复导入订阅时无法正常启动的bug
~修复ac2100核心无法正常工作的bug
~修复切换更新源后无法正常更新的bug
2020-09-29 19:40:07 +08:00
juewuy
29f7ba1518 v1.0.0beta10fix2
~增加大量订阅内置规则
~修复偶尔无法正常更新的bug
~修复导入订阅时无法正常启动的bug
~修复ac2100核心无法正常工作的bug
~修复切换更新源后无法正常更新的bug
2020-09-29 19:31:12 +08:00
juewuy
baf0b1adc5 v1.0.0beta10fix2
~增加大量订阅内置规则
~修复偶尔无法正常更新的bug
~修复导入订阅时无法正常启动的bug
~修复ac2100核心无法正常工作的bug
2020-09-29 19:03:45 +08:00
juewuy
dbe7ca280a v1.0.0beta10fix1
~增加大量订阅内置规则
~修复偶尔无法正常更新的bug
~修复导入订阅时无法正常启动的bug
~修复ac2100核心无法正常工作的bug
2020-09-29 19:02:28 +08:00
juewuy
87e1d5773c v1.0.0beta10
~同步Premium核心版本至20200927
~增加对小米/红米AC2100系列设备的支持
~修复了默认配置设置显示与实际设置不符的bug
2020-09-28 22:05:18 +08:00
juewuy
e78b336edf v1.0.0beta10
~同步Premium核心版本至20200927
~增加对小米/红米AC2100系列设备的支持
~修复了默认配置设置显示与实际设置不符的bug
2020-09-28 21:11:00 +08:00
juewuy
aa2f16a7d9 v1.0.0beta10
~同步Premium核心版本至20200927
~增加对小米/红米AC2100系列设备的支持
~修复了默认配置设置显示与实际设置不符的bug
2020-09-28 21:10:37 +08:00
juewuy
7c18992e9b v1.0.0beta10
~同步Premium核心版本至20200927
~增加对小米/红米AC2100系列设备的支持
~修复了默认配置设置显示与实际设置不符的bug
2020-09-28 21:02:46 +08:00
35 changed files with 865 additions and 644 deletions

View File

@@ -1,35 +1,49 @@
# ShellClash原Clash for Miwifi # ShellClash原Clash for Miwifi
在Shell环境下一键部署及管理[Clash](https://github.com/Dreamacro/clash) 在Shell环境下一键部署及管理[Clash](https://github.com/Dreamacro/clash)
===== =====
功能简介: 功能简介:
-- --
~通过管理脚本在shell环境下便捷使用[Clash](https://github.com/Dreamacro/clash)<br> ~通过管理脚本在Shell环境下便捷使用[Clash](https://github.com/Dreamacro/clash)<br>
~支持在Shell环境下管理[Clash各种功能](https://lancellc.gitbook.io/clash)<br> ~支持在Shell环境下管理[Clash各种功能](https://lancellc.gitbook.io/clash)<br>
~支持批量导入SS/SSR/v2ray/trojan等节点链接及订阅链接<br>~支持配置定时任务,以及定时更新订阅<br>~支持使用以及安装网页面板管理规则组<br> ~支持批量导入[Clash](https://github.com/Dreamacro/clash)支持的节点链接及订阅链接<br>~支持配置定时任务,以及定时更新订阅<br>~支持在线安装及使用网页面板管理规则组<br>
~支持局域网透明代理/纯净模式等多种模式切换<br>~支持在线更新管理脚本及升级Clash核心<br> ~支持局域网透明代理/纯净模式等多种模式切换<br>~支持在线更新管理脚本及升级Clash核心<br>
设备支持: 设备支持:
-- --
~支持小米/红米全系使用官方系统或官方开发版系统的路由器设备Ac2100系列除外<br> ~支持小米/红米全系使用官方系统或官方开发版系统的路由器设备<br>
~支持各种基于OpenWrt或使用OpenWrt二次定制开发的路由器设备<br> ~支持各种基于OpenWrt或使用OpenWrt二次定制开发的路由器设备<br>
~支持各种运行标准Linux系统如Debian/CenOS/Armbian等的设备<br> ~支持各种运行标准Linux系统如Debian/CenOS/Armbian等的设备<br>~兼容Padavan固件保守模式、潘多拉固件<br>——————————
~更多设备请提issue或前往TG群反馈需提供设备名称及运行uname -a返回的设备核心信息<br> ~暂不支持高恪、梅林等固件<br>
~更多设备支持请提issue或前往TG群反馈需提供设备名称及运行uname -a返回的设备核心信息<br>
使用方式: 使用方式:
-- --
~确认路由器或设备已经开启SSH并获取root权限<br> ~确认路由器或设备已经开启SSH并获取root权限<br>
~使用SSH连接工具如puttyJuiceSSH系统自带终端等路由器或设备的SSH管理界面并切换到root用户<br> ~使用SSH连接工具如puttyJuiceSSH系统自带终端等路由器或设备的SSH管理界面并切换到root用户<br>
~在SSH界面执行如下安装命令并按照后续提示完成安装<br> ~确认设备已经安装curl如未安装LInux设备请[参考此处](https://www.howtoing.com/install-curl-in-linux)进行安装基于OpenWrt小米官方系统、潘多拉、高恪等的设备请使用如下命令安装<br>
```shell
opkg update && opkg install curl
```
~之后在SSH界面执行如下安装命令并按照后续提示完成安装<br>
~使用curl<br>
```Shell ```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 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
``` ```
或者
```Shell
sh -c "$(curl -kfsSl https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master/install_cdn.sh)" && source /etc/profile &> /dev/null
```
~安装完成管理脚本后,执行如下命令以运行管理脚本<br> ~安装完成管理脚本后,执行如下命令以运行管理脚本<br>
```Shell ```Shell
@@ -53,4 +67,4 @@ https://github.com/juewuy/ShellClash/releases
友情推广: 友情推广:
-- --
https://dler.best/auth/register?affid=89698 [顶级8K专线机场-墙洞](https://dler.best/auth/register?affid=89698)

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.

View File

@@ -1 +0,0 @@
version=1.1.0

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.

View File

@@ -1 +0,0 @@
version=2020.09.27

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1 +0,0 @@
version=1.0.0

View File

@@ -1,2 +1,4 @@
GeoIP_v=20200917 clash_v=1.2.0
versionsh=1.0.0beta9fix2 clashpre_v=2020.10.09
GeoIP_v=20201010
versionsh=1.0.0beta14fix5

View File

@@ -2,7 +2,7 @@
# Copyright (C) Juewuy # Copyright (C) Juewuy
echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo
test=0 [ -z "$1" ] && test=0 || test=$1
echo "***********************************************" echo "***********************************************"
echo "** 欢迎使用 **" echo "** 欢迎使用 **"
@@ -10,22 +10,27 @@ echo "** ShellClash **"
echo "** by Juewuy **" echo "** by Juewuy **"
echo "***********************************************" echo "***********************************************"
#检查root权限
[ "$USER" != "root" ] && [ "$USER" != "admin" ] && echo 请使用root用户执行安装&& exit 1
#检查更新
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash" url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
if [ $test -ge 1 ];then if [ "$test" -gt 0 ];then
url="--resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master" url="--resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master"
[ $test -ge 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi" [ "$test" -eq 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi" && echo $url
[ "$test" -eq 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi"
else else
release_new=$(curl -kfsSL --resolve api.github.com:443:140.82.113.5 "https://api.github.com/repos/juewuy/ShellClash/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') #检查版本 release_new=$(curl -kfsSL --resolve api.github.com:443:140.82.113.5 "https://api.github.com/repos/juewuy/ShellClash/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') #检查版本
fi fi
[ -z "$release_new" ] && release_new=$(curl -kfsSL $url/bin/version | grep "versionsh" | awk -F "=" '{print $2}') [ -z "$release_new" ] && release_new=$(curl -kfsSL $url/bin/version | grep "versionsh" | awk -F "=" '{print $2}')
[ -z "$release_new" ] && echo "无法连接服务器!" && exit [ -z "$release_new" ] && echo "无法连接服务器!" && exit
tarurl=$url@$release_new/bin/clashfm.tar.gz tarurl=$url@$release_new/bin/clashfm.tar.gz
[ $test -ge 1 ] && tarurl=$url/bin/clashfm.tar.gz [ "$test" -gt 0 ] && tarurl=$url/bin/clashfm.tar.gz
gettar(){ gettar(){
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl) result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl)
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1 [ "$result" != "200" ] && echo "文件下载失败!" && exit 1
#解压 #解压
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo 开始解压文件! echo 开始解压文件!
mkdir -p $clashdir > /dev/null mkdir -p $clashdir > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $clashdir/ tar -zxvf '/tmp/clashfm.tar.gz' -C $clashdir/
@@ -38,7 +43,7 @@ gettar(){
mv $clashdir/clashservice /etc/init.d/clash mv $clashdir/clashservice /etc/init.d/clash
chmod 777 /etc/init.d/clash chmod 777 /etc/init.d/clash
else else
[ -d /etc/systemd/system ] && sysdir=/etc/systemd/system [ -d /etc/systemd/system/ ] && sysdir=/etc/systemd/system/
[ -d /usr/lib/systemd/system/ ] && sysdir=/usr/lib/systemd/system/ [ -d /usr/lib/systemd/system/ ] && sysdir=/usr/lib/systemd/system/
if [ -n "$sysdir" ];then if [ -n "$sysdir" ];then
#设为systemd方式启动 #设为systemd方式启动
@@ -68,17 +73,24 @@ gettar(){
rm -rf $clashdir/clashservice rm -rf $clashdir/clashservice
rm -rf $clashdir/clash.service rm -rf $clashdir/clash.service
} }
#输出 #下载及安装
$echo "最新版本:\033[32m$release_new\033[0m" install(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
$echo "\033[44m如遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m" echo 开始从服务器获取安装文件!
$echo "\033[37m支持各种基于openwrt的路由器设备" echo -----------------------------------------------
$echo "\033[33m支持Debian、Centos等标准Linux系统\033[0m" gettar
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo ShellClash 已经安装成功!
echo -----------------------------------------------
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
echo -----------------------------------------------
}
setdir(){
echo -----------------------------------------------
$echo "\033[32m 1 在默认目录(/etc)安装" $echo "\033[32m 1 在默认目录(/etc)安装"
$echo "\033[33m 2 手动设置安装目录" $echo "\033[33m 2 手动设置安装目录"
$echo "\033[0m 0 退出安装" $echo "\033[0m 0 退出安装"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
read -p "请输入相应数字 > " num read -p "请输入相应数字 > " num
#设置目录 #设置目录
if [ -z $num ];then if [ -z $num ];then
@@ -87,29 +99,46 @@ if [ -z $num ];then
elif [ "$num" = "1" ];then elif [ "$num" = "1" ];then
dir=/etc dir=/etc
elif [ "$num" = "2" ];then elif [ "$num" = "2" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo '可用路径 剩余空间:' echo '可用路径 剩余空间:'
df -h | awk '{print $6,$2}'| sed 1d df -h | awk '{print $6,$2}'| sed 1d
echo '路径是必须带 / 的格式,写入虚拟内存(/tmp,/sys,..)的文件会在重启后消失!!!' echo '路径是必须带 / 的格式,写入虚拟内存(/tmp,/sys,..)的文件会在重启后消失!!!'
read -p "请输入自定义路径 > " dir read -p "请输入自定义路径 > " dir
if [ -z $dir ];then if [ -z "$dir" ];then
echo 路径错误!已取消安装! $echo "\033[31m路径错误!已取消安装!\033[0m"
exit; exit;
fi fi
else else
echo 安装已取消 echo 安装已取消
exit; exit;
fi fi
clashdir=$dir/clash clashdir=$dir/clash
#输出 install
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }
echo 开始从服务器获取安装文件!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#下载及安装
gettar
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ShellClash 已经安装成功!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#输出
$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
else
$echo "\033[31m输入错误已取消安装\033[0m"
exit;
fi
else
setdir
fi

View File

@@ -2,7 +2,7 @@
# Copyright (C) Juewuy # Copyright (C) Juewuy
echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo
test=0 [ -z "$1" ] && test=0 || test=$1
echo "***********************************************" echo "***********************************************"
echo "** 欢迎使用 **" echo "** 欢迎使用 **"
@@ -10,22 +10,27 @@ echo "** ShellClash **"
echo "** by Juewuy **" echo "** by Juewuy **"
echo "***********************************************" echo "***********************************************"
#检查root权限
[ "$USER" != "root" ] && [ "$USER" != "admin" ] && echo 请使用root用户执行安装&& exit 1
#检查更新
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash" url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
if [ $test -ge 1 ];then if [ "$test" -gt 0 ];then
url="--resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master" url="--resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master"
[ $test -ge 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi" [ "$test" -eq 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi" && echo $url
[ "$test" -eq 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi"
else else
release_new=$(curl -kfsSL --resolve api.github.com:443:140.82.113.5 "https://api.github.com/repos/juewuy/ShellClash/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') #检查版本 release_new=$(curl -kfsSL --resolve api.github.com:443:140.82.113.5 "https://api.github.com/repos/juewuy/ShellClash/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') #检查版本
fi fi
[ -z "$release_new" ] && release_new=$(curl -kfsSL $url/bin/version | grep "versionsh" | awk -F "=" '{print $2}') [ -z "$release_new" ] && release_new=$(curl -kfsSL $url/bin/version | grep "versionsh" | awk -F "=" '{print $2}')
[ -z "$release_new" ] && echo "无法连接服务器!" && exit [ -z "$release_new" ] && echo "无法连接服务器!" && exit
tarurl=$url@$release_new/bin/clashfm.tar.gz tarurl=$url@$release_new/bin/clashfm.tar.gz
[ $test -ge 1 ] && tarurl=$url/bin/clashfm.tar.gz [ "$test" -gt 0 ] && tarurl=$url/bin/clashfm.tar.gz
gettar(){ gettar(){
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl) result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl)
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1 [ "$result" != "200" ] && echo "文件下载失败!" && exit 1
#解压 #解压
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo 开始解压文件! echo 开始解压文件!
mkdir -p $clashdir > /dev/null mkdir -p $clashdir > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $clashdir/ tar -zxvf '/tmp/clashfm.tar.gz' -C $clashdir/
@@ -38,7 +43,7 @@ gettar(){
mv $clashdir/clashservice /etc/init.d/clash mv $clashdir/clashservice /etc/init.d/clash
chmod 777 /etc/init.d/clash chmod 777 /etc/init.d/clash
else else
[ -d /etc/systemd/system ] && sysdir=/etc/systemd/system [ -d /etc/systemd/system/ ] && sysdir=/etc/systemd/system/
[ -d /usr/lib/systemd/system/ ] && sysdir=/usr/lib/systemd/system/ [ -d /usr/lib/systemd/system/ ] && sysdir=/usr/lib/systemd/system/
if [ -n "$sysdir" ];then if [ -n "$sysdir" ];then
#设为systemd方式启动 #设为systemd方式启动
@@ -68,17 +73,24 @@ gettar(){
rm -rf $clashdir/clashservice rm -rf $clashdir/clashservice
rm -rf $clashdir/clash.service rm -rf $clashdir/clash.service
} }
#输出 #下载及安装
$echo "最新版本:\033[32m$release_new\033[0m" install(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
$echo "\033[44m如遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m" echo 开始从服务器获取安装文件!
$echo "\033[37m支持各种基于openwrt的路由器设备" echo -----------------------------------------------
$echo "\033[33m支持Debian、Centos等标准Linux系统\033[0m" gettar
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo ShellClash 已经安装成功!
echo -----------------------------------------------
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
echo -----------------------------------------------
}
setdir(){
echo -----------------------------------------------
$echo "\033[32m 1 在默认目录(/etc)安装" $echo "\033[32m 1 在默认目录(/etc)安装"
$echo "\033[33m 2 手动设置安装目录" $echo "\033[33m 2 手动设置安装目录"
$echo "\033[0m 0 退出安装" $echo "\033[0m 0 退出安装"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
read -p "请输入相应数字 > " num read -p "请输入相应数字 > " num
#设置目录 #设置目录
if [ -z $num ];then if [ -z $num ];then
@@ -87,29 +99,46 @@ if [ -z $num ];then
elif [ "$num" = "1" ];then elif [ "$num" = "1" ];then
dir=/etc dir=/etc
elif [ "$num" = "2" ];then elif [ "$num" = "2" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo '可用路径 剩余空间:' echo '可用路径 剩余空间:'
df -h | awk '{print $6,$2}'| sed 1d df -h | awk '{print $6,$2}'| sed 1d
echo '路径是必须带 / 的格式,写入虚拟内存(/tmp,/sys,..)的文件会在重启后消失!!!' echo '路径是必须带 / 的格式,写入虚拟内存(/tmp,/sys,..)的文件会在重启后消失!!!'
read -p "请输入自定义路径 > " dir read -p "请输入自定义路径 > " dir
if [ -z $dir ];then if [ -z "$dir" ];then
echo 路径错误!已取消安装! $echo "\033[31m路径错误!已取消安装!\033[0m"
exit; exit;
fi fi
else else
echo 安装已取消 echo 安装已取消
exit; exit;
fi fi
clashdir=$dir/clash clashdir=$dir/clash
#输出 install
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }
echo 开始从服务器获取安装文件!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#下载及安装
gettar
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ShellClash 已经安装成功!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#输出
$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
else
$echo "\033[31m输入错误已取消安装\033[0m"
exit;
fi
else
setdir
fi

View File

@@ -1,115 +0,0 @@
#! /bin/bash
# Copyright (C) Juewuy
echo='echo -e' && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && echo=echo
test=1
echo "***********************************************"
echo "** 欢迎使用 **"
echo "** ShellClash **"
echo "** by Juewuy **"
echo "***********************************************"
url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash"
if [ $test -ge 1 ];then
url="--resolve raw.githubusercontent.com:443:199.232.68.133 https://raw.githubusercontent.com/juewuy/ShellClash/master"
[ $test -ge 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi"
else
release_new=$(curl -kfsSL --resolve api.github.com:443:140.82.113.5 "https://api.github.com/repos/juewuy/ShellClash/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') #检查版本
fi
[ -z "$release_new" ] && release_new=$(curl -kfsSL $url/bin/version | grep "versionsh" | awk -F "=" '{print $2}')
[ -z "$release_new" ] && echo "无法连接服务器!" && exit
tarurl=$url@$release_new/bin/clashfm.tar.gz
[ $test -ge 1 ] && tarurl=$url/bin/clashfm.tar.gz
gettar(){
result=$(curl -w %{http_code} -kLo /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 "文件解压失败!" && 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
[ -d /etc/systemd/system ] && sysdir=/etc/systemd/system
[ -d /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
rm -rf /etc/init.d/clash
else
#设为保守模式启动
sed -i '/start_old=*/'d $clashdir/mark
sed -i "1i\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%g" $clashdir/start.sh
chmod 777 $clashdir/start.sh
sed -i '/versionsh_l=*/'d $clashdir/mark
sed -i "1i\versionsh_l=$release_new" $clashdir/mark
#设置环境变量
sed -i '/alias clash=*/'d /etc/profile
echo "alias clash=\"$shtype $clashdir/clash.sh\"" >> /etc/profile #设置快捷命令环境变量
sed -i '/export clashdir=*/'d /etc/profile
echo "export clashdir=\"$clashdir\"" >> /etc/profile #设置clash路径环境变量
#删除临时文件
rm -rf /tmp/clashfm.tar.gz
rm -rf $clashdir/clashservice
rm -rf $clashdir/clash.service
}
#输出
$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"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$echo "\033[32m 1 在默认目录(/etc)安装"
$echo "\033[33m 2 手动设置安装目录"
$echo "\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
clashdir=$dir/clash
#输出
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始从服务器获取安装文件!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#下载及安装
gettar
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ShellClash 已经安装成功!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$echo "\033[33m输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -6,8 +6,8 @@ getconfig(){
if [ -f /bin/opkg ];then if [ -f /bin/opkg ];then
host=$(ubus call network.interface.lan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';) host=$(ubus call network.interface.lan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';)
else else
host=$(ip a|grep -w 'inet'|grep 'global'|grep -E '192.|10.'|sed 's/.*inet.//g'|sed 's/\/[0-9][0-9].*$//g') host=$(ip a|grep -w 'inet'|grep 'global'|grep -E '192.|10.'|sed 's/.*inet.//g'|sed 's/\/[0-9][0-9].*$//g'|head -n 1)
[ -z $host ] && host=127.0.0.1 [ -z "$host" ] && host=127.0.0.1
fi fi
#服务器地址 #服务器地址
[ -z "$update_url" ] && update_url=https://cdn.jsdelivr.net/gh/juewuy/ShellClash [ -z "$update_url" ] && update_url=https://cdn.jsdelivr.net/gh/juewuy/ShellClash
@@ -22,13 +22,13 @@ source $ccfg
[ ! -f $clashdir/mac ] && touch $clashdir/mac [ ! -f $clashdir/mac ] && touch $clashdir/mac
#开机自启相关 #开机自启相关
if [ -f /etc/rc.common ];then if [ -f /etc/rc.common ];then
if [ -f /etc/rc.d/*clash ];then if [ -n "$(find /etc/rc.d -name '*clash')" ];then
autostart=enable_rc autostart=enable_rc
else else
autostart=disable_rc autostart=disable_rc
fi fi
else else
if [ -n "$(systemctl list-unit-files clash.service | grep -o enable)" ];then if [ -n "$(systemctl list-unit-files clash.service 2>&1 | grep -o enable)" ];then
autostart=enable_sys autostart=enable_sys
else else
autostart=disable_sys autostart=disable_sys
@@ -44,6 +44,12 @@ else
auto="\033[31m未设置开机启动\033[0m" auto="\033[31m未设置开机启动\033[0m"
auto1="\033[36m允许\033[0mclash开机启动" auto1="\033[36m允许\033[0mclash开机启动"
fi fi
#获取默认端口
[ -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 "$secret" ] && secret=未设置
#获取运行模式 #获取运行模式
if [ -z "$redir_mod" ];then if [ -z "$redir_mod" ];then
sed -i "2i\redir_mod=Redir模式" $ccfg sed -i "2i\redir_mod=Redir模式" $ccfg
@@ -56,22 +62,25 @@ if [ -n "$PID" ];then
VmRSS=`cat /proc/$PID/status|grep -w VmRSS|awk '{print $2,$3}'` VmRSS=`cat /proc/$PID/status|grep -w VmRSS|awk '{print $2,$3}'`
#获取运行时长 #获取运行时长
if [ -n "$start_time" ]; then if [ -n "$start_time" ]; then
time=$((`date +%s`-$start_time)) time=$((`date +%s`-start_time))
day=$(($time/86400)) day=$((time/86400))
if [[ $day != 0 ]]; then #day=$(expr $time / 86400)
day=$day天 if [ "$day" = "0" ]; then
else
day="" day=""
else
day="$day""天"
fi fi
time=`date -u -d @${time} +"%-H小时%-M分%-S秒"` time=`date -u -d @${time} +%H小时%M分%S秒`
fi fi
else else
run="\033[31m没有运行$redir_mod\033[0m" run="\033[31m没有运行$redir_mod\033[0m"
#检测系统端口占用
checkport
fi fi
#输出状态 #输出状态
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[30;46m欢迎使用ShellClash\033[0m 版本:$versionsh_l" echo -e "\033[30;46m欢迎使用ShellClash\033[0m 版本:$versionsh_l"
echo -e "Clash服务"$run""$auto"" echo -e "Clash服务"$run""$auto""
if [ -n "$PID" ];then if [ -n "$PID" ];then
echo -e "当前内存占用:\033[44m"$VmRSS"\033[0m已运行\033[46;30m"$day"\033[44;37m"$time"\033[0m" echo -e "当前内存占用:\033[44m"$VmRSS"\033[0m已运行\033[46;30m"$day"\033[44;37m"$time"\033[0m"
@@ -82,43 +91,132 @@ echo -----------------------------------------------
if [ ! -f $clashdir/clash ];then if [ ! -f $clashdir/clash ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m没有找到核心文件请先下载clash核心\033[0m" echo -e "\033[31m没有找到核心文件请先下载clash核心\033[0m"
checkupdate
source $clashdir/getdate.sh source $clashdir/getdate.sh
getcore getcore
fi fi
#检查GeoIP数据库 #检查GeoIP数据库
if [ ! -f $clashdir/Country.mmdb ];then if [ ! -f $clashdir/Country.mmdb ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m没有找到GeoIP数据库文件下载数据库!\033[0m" echo -e "\033[31m没有找到GeoIP数据库文件请下载数据库文件\033[0m"
checkupdate
source $clashdir/getdate.sh source $clashdir/getdate.sh
getgeo getgeo
clashstart fi
#检查定时任务配置文件
if [ -z "$cronpath" ];then
[ -d /etc/crontabs/ ] && cronpath="/etc/crontabs/root"
[ -d /var/spool/cron/ ] && cronpath="/var/spool/cron/root"
[ -d /var/spool/cron/crontabs/ ] && cronpath="/var/spool/cron/crontabs/root"
[ -d /etc/storage/cron/crontabs ] && cronpath="/etc/storage/cron/crontabs/admin"
[ -n "$cronpath" ] && sed -i "1i\cronpath=\'$cronpath\'" $ccfg
fi fi
} }
start_over(){ start_over(){
[ $? -eq 1 ] && exit
echo -e "\033[32mclash服务已启动\033[0m" echo -e "\033[32mclash服务已启动\033[0m"
if [ -d /www/clash ];then if [ -d /www/clash ];then
echo -e "请使用\033[30;47m http://$host/clash \033[0m管理内置规则" echo -e "请使用\033[30;47m http://$host/clash \033[0m管理内置规则"
elif [ -d $clashdir/ui ];then elif [ -d $clashdir/ui ];then
echo -e "请使用\033[30;47m http://$host:9999/ui \033[0m管理内置规则" echo -e "请使用\033[30;47m http://$host:$db_port/ui \033[0m管理内置规则"
else else
echo -e "可使用\033[30;47m http://clash.razord.top \033[0m管理内置规则" echo -e "可使用\033[30;47m http://clash.razord.top \033[0m管理内置规则"
echo -e "Host地址:\033[36m $host \033[0m 端口:\033[36m 9999 \033[0m" echo -e "Host地址:\033[36m $host \033[0m 端口:\033[36m $db_port \033[0m"
echo -e "也可前往更新菜单安装本地Dashboard面板连接更稳定\033[0m" echo -e "也可前往更新菜单安装本地Dashboard面板连接更稳定\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fi fi
echo -----------------------------------------------
}
setport(){
inputport(){
read -p "请输入端口号(1000-65535) > " portx
if [ -z "$portx" ]; then
setport
elif [ $portx -gt 65535 -o $portx -le 999 ]; then
echo -e "\033[31m输入错误请输入正确的数值(1000-65535)\033[0m"
inputport
elif [ -n "$(echo $mix_port$redir_port$dns_port$db_port|grep $portx)" ]; then
echo -e "\033[31m输入错误请不要输入重复的端口\033[0m"
inputport
elif [ -n "$(netstat -ntul |grep :$portx)" ];then
echo -e "\033[31m当前端口已被其他进程占用请重新输入\033[0m"
inputport
else
sed -i "/$xport*/"d $ccfg
sed -i "1i$xport=$portx" $ccfg
echo -e "\033[32m设置成功\033[0m"
setport
fi
}
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
else
clashsh
fi
fi
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e " 1 修改Http/Sock5端口\033[36m$mix_port\033[0m"
echo -e " 2 修改静态路由端口:\033[36m$redir_port\033[0m"
echo -e " 3 修改DNS监听端口\033[36m$dns_port\033[0m"
echo -e " 4 修改面板访问端口:\033[36m$db_port\033[0m"
echo -e " 5 修改面板访问密码:\033[36m$secret\033[0m"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
elif [[ $num == 1 ]]; then
xport=mix_port
inputport
elif [[ $num == 2 ]]; then
xport=redir_port
inputport
elif [[ $num == 3 ]]; then
xport=dns_port
inputport
elif [[ $num == 4 ]]; then
xport=db_port
inputport
elif [[ $num == 5 ]]; then
read -p "请输入面板访问密码 > " secret
if [ -n "$secret" ]; then
sed -i "/secret*/"d $ccfg
sed -i "1i\secret=$secret" $ccfg
echo -e "\033[32m设置成功\033[0m"
fi
setport
fi
}
checkport(){
for portx in $dns_port $mix_port $redir_port $db_port ;do
if [ -n "$(netstat -ntul 2>&1 |grep :$portx)" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "检测到端口【$portx】被以下进程占用clash可能无法正常启动\033[33m"
echo $(netstat -ntulp | grep :$portx | head -n 1)
echo -e "\033[0m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e "\033[36m请修改默认端口配置\033[0m"
setport
source $ccfg
checkport
fi
done
} }
clashstart(){ clashstart(){
if [ ! -f "$yaml" ];then if [ ! -f "$yaml" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m没有找到配置文件请先导入节点/订阅链接\033[0m" echo -e "\033[31m没有找到配置文件请先导入配置文件\033[0m"
clashlink clashlink
fi fi
if [ -n "$PID" ];then if [ -n "$PID" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
$clashdir/start.sh stop $clashdir/start.sh stop
echo -e "\033[31mClash服务已停止\033[0m" echo -e "\033[31mClash服务已停止\033[0m"
fi fi
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
$clashdir/start.sh start $clashdir/start.sh start
sleep 1 sleep 1
PID=$(pidof clash) PID=$(pidof clash)
@@ -132,26 +230,26 @@ clashstart(){
clashlink(){ clashlink(){
#获取订阅规则 #获取订阅规则
if [ -z "$rule_link" ]; then if [ -z "$rule_link" ]; then
sed -i '/rule_link=*/'d $ccfg
sed -i "4i\rule_link=1" $ccfg sed -i "4i\rule_link=1" $ccfg
rule_link=1 rule_link=1
fi fi
#获取后端服务器地址 #获取后端服务器地址
if [ -z "$server_link" ]; then if [ -z "$server_link" ]; then
sed -i '/server_link=*/'d $ccfg
sed -i "5i\server_link=1" $ccfg sed -i "5i\server_link=1" $ccfg
server_link=1 server_link=1
fi fi
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[30;47m 欢迎使用订阅功能!\033[0m" echo -e "\033[30;47m 欢迎使用导入配置文件功能!\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e " 1 导入\033[36m节点/订阅\033[0m链接" echo -e " 1 在线导入\033[36m订阅\033[0m并生成Clash配置文件"
echo -e " 2 使用完整clash规则链接" echo -e " 2 在线导入\033[33mClash\033[0m配置文件"
echo -e " 3 添加/修改\033[32m节点过滤\033[0m关键字 \033[47;30m$exclude\033[0m" echo -e " 3 设置\033[31m节点过滤\033[0m关键字 \033[47;30m$exclude\033[0m"
echo -e " 4 选取\033[33mclash配置规则\033[0m模版" echo -e " 4 设置\033[32m节点筛选\033[0m关键字 \033[47;30m$include\033[0m"
echo -e " 5 选择在线生成服务器" echo -e " 5 选取\033[33mClash配置规则\033[0m在线模版"
echo -e " 6 \033[36m还原\033[0m配置文件" echo -e " 6 选择在线生成服务器-subconverter"
echo -e " 7 \033[32m手动更新\033[0m订阅" echo -e " 7 \033[36m还原\033[0m之前的配置文件"
echo -e " 8 \033[33m手动更新\033[0m配置文件"
echo -e " 9 设置\033[36m自动更新\033[0m配置文件"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e " 0 返回上级菜单" echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
@@ -198,15 +296,20 @@ elif [[ $num == 3 ]];then
elif [[ $num == 4 ]];then elif [[ $num == 4 ]];then
source $clashdir/getdate.sh source $clashdir/getdate.sh
linkconfig linkfilter2
clashlink clashlink
elif [[ $num == 5 ]];then elif [[ $num == 5 ]];then
source $clashdir/getdate.sh source $clashdir/getdate.sh
linkserver linkconfig
clashlink clashlink
elif [[ $num == 6 ]];then elif [[ $num == 6 ]];then
source $clashdir/getdate.sh
linkserver
clashlink
elif [[ $num == 7 ]];then
yamlbak=$yaml.bak yamlbak=$yaml.bak
if [ ! -f "$yaml".bak ];then if [ ! -f "$yaml".bak ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -226,24 +329,29 @@ elif [[ $num == 6 ]];then
fi fi
clashsh clashsh
elif [[ $num == 7 ]];then elif [[ $num == 8 ]];then
if [ -z "$Url" -a -z "$Https" ];then if [ -z "$Url" -a -z "$Https" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 没有找到你的订阅链接!请先输入链接! echo -e "\033[31m没有找到你的订阅链接!请先输入链接!\033[0m"
sleep 2
clashlink clashlink
else else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m当前系统记录的订阅链接为\033[0m" echo -e "\033[33m当前系统记录的订阅链接为\033[0m"
echo -e "\033[4;32m$Url\033[0m" echo -e "\033[4;32m$Url\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
read -p "确认更新配置文件?[1/0] > " res read -p "确认更新配置文件?[1/0] > " res
if [ "$res" = '1' ]; then if [ "$res" = '1' ]; then
source $clashdir/start.sh $clashdir/start.sh getyaml
getyaml start_over
exit;
fi fi
clashlink clashlink
fi fi
elif [[ $num == 9 ]];then
clashcron
elif [[ $num == 0 ]];then elif [[ $num == 0 ]];then
clashsh clashsh
else else
@@ -252,6 +360,105 @@ else
exit; exit;
fi fi
} }
macfilter(){
add_mac(){
echo -----------------------------------------------
echo -e "\033[33m序号 设备IP 设备mac地址 设备名称\033[32m"
cat /tmp/dhcp.leases | awk '{print " "NR" "$3,$2,$4}'
echo -e "\033[0m 0-----------------------------------------------"
echo -e " 0 或回车 结束添加"
read -p "请输入需要添加的设备的对应序号 > " num
if [ -z "$num" ]||[ "$num" -le 0 ]; then
macfilter
elif [ $num -le $(cat /tmp/dhcp.leases | awk 'END{print NR}') ]; then
macadd=$(cat /tmp/dhcp.leases | awk '{print $2}' | sed -n "$num"p)
if [ -z "$(cat $clashdir/mac | grep -E "$macadd")" ];then
echo $macadd >> $clashdir/mac
echo -----------------------------------------------
echo 已添加的mac地址
cat $clashdir/mac
else
echo -----------------------------------------------
echo -e "\033[31m已添加的设备请勿重复添加\033[0m"
fi
else
echo -----------------------------------------------
echo -e "\033[31m输入有误请重新输入\033[0m"
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
echo -e " $i \033[32m$(cat /tmp/dhcp.leases | awk '{print $3,$2,$4}' | grep $mac)\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 -----------------------------------------------
echo -e "\033[31m输入有误请重新输入\033[0m"
fi
del_mac
}
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[30;47m请在此添加或移除设备\033[0m"
if [ -n "$(cat $clashdir/mac)" ]; then
echo -----------------------------------------------
echo -e "当前已过滤设备为:\033[36m"
echo -e "\033[33m 设备IP 设备mac地址 设备名称\033[0m"
for mac in $(cat $clashdir/mac); do
cat /tmp/dhcp.leases | awk '{print $3,$2,$4}' | grep $mac
done
echo -----------------------------------------------
fi
echo -e " 1 \033[31m清空整个列表\033[0m"
echo -e " 2 \033[32m添加指定设备\033[0m"
echo -e " 3 \033[33m移除指定设备\033[0m"
echo -e " 4 \033[32m添加全部设备\033[0m(请搭配移除指定设备使用)"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
clashcfg
elif [[ $num == 0 ]]; then
clashcfg
elif [[ $num == 1 ]]; then
:>$clashdir/mac
echo -----------------------------------------------
echo -e "\033[31m设备列表已清空\033[0m"
macfilter
elif [[ $num == 2 ]]; then
add_mac
elif [[ $num == 3 ]]; then
del_mac
elif [[ $num == 4 ]]; then
echo -----------------------------------------------
cat /tmp/dhcp.leases | awk '{print $2}' > $clashdir/mac
echo -e "\033[32m已经将所有设备全部添加进过滤列表\033[0m"
echo -e "\033[33m请搭配【移除指定设备】功能使用\033[0m"
sleep 1
macfilter
else
echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m"
macfilter
fi
}
clashcfg(){ clashcfg(){
#获取设置默认显示 #获取设置默认显示
[ -z "$skip_cert" ] && skip_cert=已开启 [ -z "$skip_cert" ] && skip_cert=已开启
@@ -290,13 +497,13 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
echo ----------------------------------------------- echo -----------------------------------------------
echo " 1 Redir模式CPU以及内存占用较低" echo " 1 Redir模式CPU以及内存占用较低"
echo " 但不支持UDP流量转发" echo " 但不支持UDP流量转发"
echo " 日常使用推荐此模式" echo " 适合非游戏用户使用"
echo " 2 Tun模式 支持UDP转发且延迟低" echo " 2 Tun模式 支持UDP转发且延迟低"
echo " CPU及内存占用更高" echo " CPU占用极高只支持fake-ip模式"
echo " 且不支持redir-host" echo " 适合游戏用户、非大流量用户"
echo " 3 混合模式: 使用Tun转发UPD流量" echo " 3 混合模式: 使用redir转发TCPTun转发UPD"
echo " CPU和内存占用高" echo " 速度较快,内存占用高"
echo " 不推荐使用redir-host" echo " 适合游戏用户、综合用户"
echo " 4 纯净模式: 不设置iptables静态路由" echo " 4 纯净模式: 不设置iptables静态路由"
echo " 必须手动配置http/sock5代理" echo " 必须手动配置http/sock5代理"
echo " 0 返回上级菜单" echo " 0 返回上级菜单"
@@ -329,7 +536,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32m已经设置为纯净模式\033[0m" echo -e "\033[32m已经设置为纯净模式\033[0m"
echo -e "\033[33m当前模式必须手动在设备WiFi或应用中配置HTTP或sock5代理\033[0m" echo -e "\033[33m当前模式必须手动在设备WiFi或应用中配置HTTP或sock5代理\033[0m"
echo -e "HTTP/SOCK5代理服务器地址\033[30;47m$host\033[0m;端口均为:\033[30;47m7890\033[0m" echo -e "HTTP/SOCK5代理服务器地址\033[30;47m$host\033[0m;端口均为:\033[30;47m$mix_port\033[0m"
echo -e "\033[31m也可以使用PAC自动代理文件具体使用方法请自行搜索\033[0m" echo -e "\033[31m也可以使用PAC自动代理文件具体使用方法请自行搜索\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
read -p "是否配置自动代理PAC文件(1/0) > " res read -p "是否配置自动代理PAC文件(1/0) > " res
@@ -355,9 +562,9 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
echo -e "\033[33m切换模式后需要手动重启clash服务以生效\033[0m" echo -e "\033[33m切换模式后需要手动重启clash服务以生效\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo " 1 fake-ip模式 响应速度更快" echo " 1 fake-ip模式 响应速度更快"
echo " 不兼容部分软件" echo " 可能与某些局域网设备有冲突"
echo " 2 redir_host模式使用稳定,兼容性好" echo " 2 redir_host模式兼容性好"
echo " 不支持Tun模式" echo " 不支持Tun模式可能存在DNS污染"
echo " 0 返回上级菜单" echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
if [ -z "$num" ]; then if [ -z "$num" ]; then
@@ -413,67 +620,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
clashcfg clashcfg
elif [[ $num == 5 ]]; then elif [[ $num == 5 ]]; then
macfilter
add_mac(){
echo -----------------------------------------------
echo -e "\033[33m序号 设备IP 设备mac地址 设备名称\033[32m"
cat /tmp/dhcp.leases | awk '{print " "NR" "$3,$2,$4}'
echo -e "\033[0m 0 或回车 结束添加"
read -p "请输入对应序号 > " num
if [ -z "$num" ]; then
clashcfg
elif [ $num -le 0 ]; then
clashcfg
elif [ $num -le $(cat /tmp/dhcp.leases | awk 'END{print NR}') ]; then
macadd=$(cat /tmp/dhcp.leases | awk '{print $2}' | sed -n "$num"p)
if [ -z $(cat $clashdir/mac | grep -E "$macadd") ];then
echo $macadd >> $clashdir/mac
echo -----------------------------------------------
echo 已添加的mac地址
cat $clashdir/mac
else
echo -----------------------------------------------
echo -e "\033[31m已添加的设备请勿重复添加\033[0m"
fi
else
echo -----------------------------------------------
echo -e "\033[31m输入有误请重新输入\033[0m"
fi
add_mac
}
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m请在此添加或移除设备\033[0m"
if [ -n "$(cat $clashdir/mac)" ]; then
echo -e "当前已过滤设备为:\033[36m"
for mac in $(cat $clashdir/mac); do
cat /tmp/dhcp.leases | awk '{print $3,$2,$4}' | grep $mac
done
echo -e "\033[0m-----------------------------------------------"
fi
echo -e " 1 \033[31m清空列表\033[0m"
echo -e " 2 \033[32m添加设备\033[0m"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashcfg
elif [[ $num == 0 ]]; then
clashcfg
elif [[ $num == 1 ]]; then
:>$clashdir/mac
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m设备列表已清空\033[0m"
sleep 1
clashcfg
elif [[ $num == 2 ]]; then
add_mac
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashcfg
fi
elif [[ $num == 6 ]]; then elif [[ $num == 6 ]]; then
sed -i '/dns_over*/'d $ccfg sed -i '/dns_over*/'d $ccfg
@@ -518,10 +665,11 @@ echo -e "\033[30;47m欢迎使用进阶模式菜单\033[0m"
echo -e "\033[33m如您不是很了解clash的运行机制请勿更改\033[0m" echo -e "\033[33m如您不是很了解clash的运行机制请勿更改\033[0m"
echo -e "\033[32m修改配置后请手动重启clash服务\033[0m" echo -e "\033[32m修改配置后请手动重启clash服务\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e " 1 不修饰config.yaml: \033[36m$modify_yaml\033[0m ————用于使用自定义配置" echo -e " 1 不修饰config.yaml: \033[36m$modify_yaml\033[0m ————用于使用自定义配置"
echo -e " 2 启用ipv6支持: \033[36m$ipv6_support\033[0m ————实验性且不兼容Fake_ip" echo -e " 2 启用ipv6支持: \033[36m$ipv6_support\033[0m ————实验性功能,可能不可用"
echo -e " 3 使用保守方式启动: \033[36m$start_old\033[0m ————切换时会停止clash服务" echo -e " 3 使用保守方式启动: \033[36m$start_old\033[0m ————切换时会停止clash服务"
echo -e " 4 代理本机流量: \033[36m$local_proxy\033[0m ————配置本机代理环境变量" echo -e " 4 代理本机流量: \033[36m$local_proxy\033[0m ————配置本机代理环境变量"
echo -e " 5 手动指定clash运行端口"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e " 8 \033[31m重置\033[0m配置文件" echo -e " 8 \033[31m重置\033[0m配置文件"
echo -e " 9 \033[32m重启\033[0mclash服务" echo -e " 9 \033[32m重启\033[0mclash服务"
@@ -573,13 +721,13 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
echo -e "\033[33m改为使用保守方式启动clash服务\033[0m" echo -e "\033[33m改为使用保守方式启动clash服务\033[0m"
echo -e "\033[36m此模式兼容性更好但无法禁用开机启动\033[0m" echo -e "\033[36m此模式兼容性更好但无法禁用开机启动\033[0m"
start_old=已开启 start_old=已开启
$clashdir/start.sh stop > /dev/null 2>&1 $clashdir/start.sh stop
sleep 2 sleep 2
else else
sed -i "1i\start_old=未开启" $ccfg sed -i "1i\start_old=未开启" $ccfg
echo -e "\033[32m改为使用默认方式启动clash服务\033[0m" echo -e "\033[32m改为使用默认方式启动clash服务\033[0m"
start_old=未开启 start_old=未开启
$clashdir/start.sh stop > /dev/null 2>&1 $clashdir/start.sh stop
fi fi
clashadv clashadv
@@ -589,21 +737,19 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
if [ "$local_proxy" = "未开启" ] > /dev/null 2>&1; then if [ "$local_proxy" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\local_proxy=已开启" $ccfg sed -i "1i\local_proxy=已开启" $ccfg
local_proxy=已开启 local_proxy=已开启
echo 'export http_proxy=http://127.0.0.1:7890' >> /etc/profile $clashdir/start.sh set_proxy $mix_port
echo 'export https_proxy=$http_proxy' >> /etc/profile
echo 'export HTTP_PROXY=$http_proxy' >> /etc/profile
echo 'export HTTPS_PROXY=$http_proxy' >> /etc/profile
echo -e "\033[32m已经将代理参数写入环境变量~\033[0m" echo -e "\033[32m已经将代理参数写入环境变量~\033[0m"
echo -e "\033[36m如未生效请重新登录或者重启设备\033[0m" echo -e "\033[36m如未生效请重新启动终端或重新连接SSH\033[0m"
sleep 1
else else
sed -i "1i\local_proxy=未开启" $ccfg sed -i "1i\local_proxy=未开启" $ccfg
sed -i '/http*_proxy/'d /etc/profile
sed -i '/HTTP*_PROXY/'d /etc/profile
echo -e "\033[33m已经将代理参数从环境变量移除\033[0m"
local_proxy=未开启 local_proxy=未开启
$clashdir/start.sh unset_proxy
echo -e "\033[33m已经将代理参数从环境变量移除\033[0m"
fi fi
source /etc/profile > /dev/null 2>&1 sleep 1
clashadv
elif [[ $num == 5 ]]; then
setport
clashadv clashadv
elif [[ $num == 8 ]]; then elif [[ $num == 8 ]]; then
@@ -631,25 +777,27 @@ else
fi fi
exit; exit;
} }
update(){ checkupdate(){
if [ -z "$release_new" ];then if [ -z "$release_new" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m正在检查更新\033[0m"
if [ "$update_url" = "https://cdn.jsdelivr.net/gh/juewuy/ShellClash" ];then if [ "$update_url" = "https://cdn.jsdelivr.net/gh/juewuy/ShellClash" ];then
release_new=$(curl -kfsSL --resolve api.github.com:443:140.82.113.5 "https://api.github.com/repos/juewuy/ShellClash/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g') release_new=$(curl -kfsSL --resolve api.github.com:443:140.82.113.5 --connect-timeout 5 -m 5 "https://api.github.com/repos/juewuy/ShellClash/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
update_url=$update_url@$release_new update_url=$update_url@$release_new
fi fi
[ -z "$release_new" ] && release_new=$(curl -kfsSL $update_url/bin/version | grep "versionsh" | awk -F "=" '{print $2}') curl -skL --connect-timeout 5 -m 5 $update_url/bin/version > /tmp/clashversion
[ -z "$release_new" ] && echo "检查更新失败!" source /tmp/clashversion
[ -z "$release_new" ] && release_new=$versionsh
fi fi
}
update(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m正在检查更新\033[0m"
checkupdate
[ "$clashcore" = "clash" ] && clash_n=$clash_v || clash_n=$clashpre_v
echo -e "\033[30;47m欢迎使用更新功能\033[0m" echo -e "\033[30;47m欢迎使用更新功能\033[0m"
[ -n "$release_new" ] && echo -e "当前ShellClash版本\033[33m $versionsh_l \033[0m"
[ -n "$release_new" ] && echo -e "最新ShellClash版本\033[32m $release_new \033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e " 1 更新\033[36m管理脚本\033[0m" echo -e " 1 更新\033[36m管理脚本 \033[33m$versionsh_l\033[0m > \033[32m$versionsh\033[0m"
echo -e " 2 切换\033[33mclash核心\033[0m" echo -e " 2 切换\033[33mclash核心 \033[33m$clashv\033[0m > \033[32m$clash_n\033[0m"
echo -e " 3 更新\033[32mGeoIP数据库\033[0m" echo -e " 3 更新\033[32mGeoIP数据库 \033[33m$Geo_v\033[0m > \033[32m$GeoIP_v\033[0m"
echo -e " 4 安装本地\033[35mDashboard\033[0m面板" echo -e " 4 安装本地\033[35mDashboard\033[0m面板"
echo -e " 5 生成本地PAC文件(需先安装本地面板)" echo -e " 5 生成本地PAC文件(需先安装本地面板)"
echo ----------------------------------------------- echo -----------------------------------------------
@@ -801,15 +949,23 @@ clashcron(){
clashcron clashcron
} }
checkcron(){ checkcron(){
[ -d /etc/crontabs/ ]&&cronpath="/etc/crontabs/root" if [ -z "$cronpath" ];then
[ -d /var/spool/cron/ ]&&cronpath="/var/spool/cron/root"
[ -d /var/spool/cron/crontabs/ ]&&cronpath="/var/spool/cron/crontabs/root"
if [ -z $cronpath ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo "找不到定时任务文件,无法添加定时任务!" echo -e "\033[33m找不到定时任务配置文件无法添加添加定时任务!"
clashsh echo -e "\033[0m请手动指定定时任务配置文件文件位置可以通过【crontab -e】命令查看\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
read -p "请输入crontab文件路径(输入回车返回主菜单) > " path
if [ -z "$path" ];then
clashsh
elif [ -f $path ];then
cronpath=$path
sed -i '/cronpath*/'d $ccfg
sed -i "1i\cronpath=\'$cronpath\'" $ccfg
else
echo -e "\033[33m输入的路径不正确请重新输入\033[0m"
checkcron
fi
fi fi
} }
#定时任务菜单 #定时任务菜单
checkcron #检测定时任务文件 checkcron #检测定时任务文件
@@ -818,7 +974,7 @@ echo -e "\033[30;47m欢迎使用定时任务功能\033[0m"
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m" echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "\033[33m已添加的定时任务\033[36m" echo -e "\033[33m已添加的定时任务\033[36m"
cat $cronpath | egrep -o ' #.*' cat $cronpath | grep -oE ' #.*'
echo -e "\033[0m"----------------------------------------------- echo -e "\033[0m"-----------------------------------------------
echo -e " 1 设置\033[33m定时重启\033[0mclash服务" echo -e " 1 设置\033[33m定时重启\033[0mclash服务"
echo -e " 2 设置\033[31m定时停止\033[0mclash服务" echo -e " 2 设置\033[31m定时停止\033[0mclash服务"
@@ -866,8 +1022,8 @@ echo -e " 1 \033[32m启动/重启\033[0mclash服务"
echo -e " 2 clash\033[33m功能设置\033[0m" echo -e " 2 clash\033[33m功能设置\033[0m"
echo -e " 3 \033[31m停止\033[0mclash服务" echo -e " 3 \033[31m停止\033[0mclash服务"
echo -e " 4 $auto1" echo -e " 4 $auto1"
echo -e " 5 设置\033[33m定时任务\033[0m" echo -e " 5 设置\033[33m定时任务\033[0m$cronoff"
echo -e " 6 导入\033[32m节点/订阅\033[0m链接" echo -e " 6 导入\033[32m配置文件\033[0m"
echo -e " 7 clash\033[31m进阶设置\033[0m" echo -e " 7 clash\033[31m进阶设置\033[0m"
echo -e " 8 \033[35m测试菜单\033[0m" echo -e " 8 \033[35m测试菜单\033[0m"
echo -e " 9 \033[36m更新/卸载\033[0m" echo -e " 9 \033[36m更新/卸载\033[0m"
@@ -981,7 +1137,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
exit; exit;
elif [[ $num == 6 ]]; then elif [[ $num == 6 ]]; then
echo 注意:测试结果不保证一定准确! echo 注意:测试结果不保证一定准确!
delay=`curl -kx 127.0.0.1:7890 -o /dev/null -s -w '%{time_starttransfer}' 'https://google.tw' & { sleep 3 ; kill $! & }` > /dev/null 2>&1 delay=`curl -kx 127.0.0.1:$mix_port -o /dev/null -s -w '%{time_starttransfer}' 'https://google.tw' & { sleep 3 ; kill $! & }` > /dev/null 2>&1
delay=`echo |awk "{print $delay*1000}"` > /dev/null 2>&1 delay=`echo |awk "{print $delay*1000}"` > /dev/null 2>&1
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ `echo ${#delay}` -gt 1 ];then if [ `echo ${#delay}` -gt 1 ];then
@@ -1010,4 +1166,24 @@ else
fi fi
exit 1 exit 1
} }
clashsh
[ -z "$1" ] && clashsh
case "$1" in
-h)
echo -----------------------------------------
echo "欢迎使用ShellClash"
echo -----------------------------------------
echo " -t 测试模式"
echo " -h 帮助列表"
echo -----------------------------------------
echo "在线求助t.me/clashfm"
echo "官方博客juewuy.github.io"
echo "发布页面github.com/juewuy/ShellClash"
echo -----------------------------------------
;;
-t)
shtype=sh && [ -n "$(ls -l /bin/sh|grep -o dash)" ] && shtype=bash
$shtype -x $clashdir/clash.sh
;;
esac

View File

@@ -5,24 +5,28 @@ linkconfig(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m" echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo 当前使用规则为:$rule_link echo 当前使用规则为:$rule_link
echo 1 ACL4SSR默认通用版 echo 1 ACL4SSR通用版无去广告(推荐)
echo 2 ACL4SSR精简全能版推荐 echo 2 ACL4SSR精简全能版推荐
echo 3 ACL4SSR通用版+去广告加强 echo 3 ACL4SSR通用版+去广告加强
echo 4 ACL4SSR精简版+去广告加强 echo 4 ACL4SSR精简版+去广告加强
echo 5 ACL4SSR通用版无去广告 echo 5 ACL4SSR重度全分组+奈飞分流
echo 6 ACL4SSR通用版无自动测速 echo 6 ACL4SSR重度全分组+去广告加强
echo 7 ACL4SSR精简版无自动测速 echo 7 洞主规则精简版(推荐)
echo 8 ACL4SSR全分组+奈飞(慎用) echo 8 洞主规则重度完整版
echo 9 ACL4SSR全分组+去广告(慎用) echo 9 神机规则高级版
echo 10 神机规则-回国专用
echo 11 李哥规则-墙洞专用
echo 12 基础规则-仅Geoip CN+Final
echo 13 网易云解锁-仅规则分组
echo ----------------------------------------------- echo -----------------------------------------------
echo 0 返回上级菜单 echo 0 返回上级菜单
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
if [ -z "$num" ] || [[ $num -gt 9 ]];then if [ -z "$num" ] || [[ $num -gt 13 ]];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m" echo -e "\033[31m请输入正确的数字\033[0m"
elif [[ "$num" = 0 ]];then elif [[ "$num" = "0" ]];then
echo echo
elif [[ $num -le 9 ]];then elif [[ $num -le 13 ]];then
#将对应标记值写入mark #将对应标记值写入mark
sed -i '/rule_link*/'d $ccfg sed -i '/rule_link*/'d $ccfg
sed -i "4i\rule_link="$num"" $ccfg sed -i "4i\rule_link="$num"" $ccfg
@@ -34,22 +38,22 @@ fi
linkserver(){ linkserver(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m" echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -e "\033[36m 感谢 https://github.com/tindy2013/subconverter \033[0m"
echo 当前使用后端为:$server_link echo 当前使用后端为:$server_link
echo 1 subconverter-web.now.sh echo 1 subcon.dlj.tf
echo 2 subconverter.herokuapp.com echo 2 subconverter.herokuapp.com
echo 3 subcon.py6.pw echo 3 subcon.py6.pw
echo 4 api.dler.io echo 4 api.dler.io
echo 5 api.wcc.best echo 5 api.wcc.best
echo 6 skapi.cool
echo ----------------------------------------------- echo -----------------------------------------------
echo 0 返回上级菜单 echo 0 返回上级菜单
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
if [ -z "$num" ] || [[ $num -gt 6 ]];then if [ -z "$num" ] || [[ $num -gt 5 ]];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m" echo -e "\033[31m请输入正确的数字\033[0m"
elif [[ "$num" = 0 ]];then elif [[ "$num" = 0 ]];then
echo echo
elif [[ $num -le 6 ]];then elif [[ $num -le 5 ]];then
#将对应标记值写入mark #将对应标记值写入mark
sed -i '/server_link*/'d $ccfg sed -i '/server_link*/'d $ccfg
sed -i "4i\server_link="$num"" $ccfg sed -i "4i\server_link="$num"" $ccfg
@@ -64,9 +68,9 @@ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m" echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -e "\033[33m当前过滤关键字\033[47;30m$exclude\033[0m" echo -e "\033[33m当前过滤关键字\033[47;30m$exclude\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "\033[36m匹配关键字的节点会在导入时被屏蔽\033[0m" echo -e "\033[33m匹配关键字的节点会在导入时被屏蔽】!!!\033[0m"
echo -e "多个关键字可以用\033[30;47m | \033[0m号分隔" echo -e "多个关键字可以用\033[30;47m | \033[0m号分隔"
echo -e "\033[32m支持正则表达式\033[0m特殊符号请使用\033[30;47m \ \033[0m号转义" echo -e "\033[32m支持正则表达式\033[0m空格请使用\033[30;47m + \033[0m号替代"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e " 000 \033[31m删除\033[0m关键字" echo -e " 000 \033[31m删除\033[0m关键字"
echo -e " 回车 取消输入并返回上级菜单" echo -e " 回车 取消输入并返回上级菜单"
@@ -83,18 +87,44 @@ sed -i '/exclude=*/'d $ccfg
sed -i "1i\exclude=\'$exclude\'" $ccfg sed -i "1i\exclude=\'$exclude\'" $ccfg
linkset linkset
} }
linkfilter2(){
[ -z "$include" ] && include="未设置"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -e "\033[33m当前筛选关键字\033[47;30m$include\033[0m"
echo -----------------------------------------------
echo -e "\033[33m仅有匹配关键字的节点才会被【导入】\033[0m"
echo -e "多个关键字可以用\033[30;47m | \033[0m号分隔"
echo -e "\033[32m支持正则表达式\033[0m空格请使用\033[30;47m + \033[0m号替代"
echo -----------------------------------------------
echo -e " 000 \033[31m删除\033[0m关键字"
echo -e " 回车 取消输入并返回上级菜单"
echo -----------------------------------------------
read -p "请输入关键字 > " include
if [ -z "$include" ]; then
linkset
elif [ "$include" = '000' ]; then
echo -----------------------------------------------
include=''
echo -e "\033[31m 已删除节点匹配关键字!!!\033[0m"
fi
sed -i '/include=*/'d $ccfg
sed -i "1i\include=\'$include\'" $ccfg
linkset
}
linkset(){ linkset(){
if [ -n $Url ];then if [ -n "$Url" ];then
[ -z "$skip_cert" ] && skip_cert=已开启 [ -z "$skip_cert" ] && skip_cert=已开启
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[47;30m请检查输入的链接是否正确\033[0m" echo -e "\033[47;30m请检查输入的链接是否正确\033[0m"
echo -e "\033[32;4m$Url\033[0m" echo -e "\033[32;4m$Url\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e " 1 \033[32m生成配置文件原文件将被备份\033[0m" echo -e " 1 \033[36m生成配置文件\033[0m(原文件将被备份)"
echo -e " 2 \033[36m添加/修改节点过滤关键字 \033[47;30m$exclude\033[0m" echo -e " 2 设置\033[31m节点过滤\033[0m关键字 \033[47;30m$exclude\033[0m"
echo -e " 3 \033[33m选取配置规则模版\033[0m" echo -e " 3 设置\033[32m节点筛选\033[0m关键字 \033[47;30m$include\033[0m"
echo -e " 4 \033[0m选取在线生成服务器\033[0m" echo -e " 4 选取在线\033[33m配置规则模版\033[0m"
echo -e " 5 \033[0m跳过本地证书验证: \033[36m$skip_cert\033[0m ————自建tls节点务必开启" echo -e " 5 \033[0m选取在线生成服务器\033[0m"
echo -e " 6 \033[0m跳过本地证书验证 \033[36m$skip_cert\033[0m ————自建tls节点务必开启"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e " 0 \033[31m取消导入\033[0m并返回上级菜单" echo -e " 0 \033[31m取消导入\033[0m并返回上级菜单"
echo ----------------------------------------------- echo -----------------------------------------------
@@ -110,18 +140,22 @@ if [ -n $Url ];then
sed -i "6i\Url=\'$Url\'" $ccfg sed -i "6i\Url=\'$Url\'" $ccfg
Https="" Https=""
#获取在线yaml文件 #获取在线yaml文件
source $clashdir/start.sh $clashdir/start.sh getyaml
getyaml start_over
exit;
elif [ "$num" = '2' ]; then elif [ "$num" = '2' ]; then
linkfilter linkfilter
linkset linkset
elif [ "$num" = '3' ]; then elif [ "$num" = '3' ]; then
linkconfig linkfilter2
linkset linkset
elif [ "$num" = '4' ]; then elif [ "$num" = '4' ]; then
linkserver linkconfig
linkset linkset
elif [ "$num" = '5' ]; then elif [ "$num" = '5' ]; then
linkserver
linkset
elif [ "$num" = '6' ]; then
sed -i '/skip_cert*/'d $ccfg sed -i '/skip_cert*/'d $ccfg
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ "$skip_cert" = "未开启" ] > /dev/null 2>&1; then if [ "$skip_cert" = "未开启" ] > /dev/null 2>&1; then
@@ -149,37 +183,37 @@ while [ $i -le 99 ]
do do
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[44m 遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m" echo -e "\033[44m 遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -e "\033[31m本功能依赖第三方网站在线服务实现脚本本身不提供任何代理服务\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "支持批量导入\033[30;46m Http/Https/Clash \033[0m等格式的订阅链接" echo -e "支持批量导入订阅文件的在线链接"
echo -e "以及\033[30;42m Vmess/SSR/SS/Trojan \033[0m等格式的节点链接"
echo -e "自建Trojan节点链接格式为trojan://密码@host地址:443"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "多个较短的链接可以用\033[30;47m | \033[0m号分隔以一次性输入" echo -e " 0 \033[31m撤销输入\033[0m"
echo -e "多个较长的链接可分次输入,支持多达\033[30;47m 99 \033[0m次输入" echo -e "回车 \033[32m完成输入\033[0m并\033[33m开始导入\033[0m配置文件!"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "回车 \033[32m完成输入\033[0m并开始导入链接" read -p "请输入第${i}个链接 > " url
echo -e " 0 \033[33m取消输入\033[0m并返回上级菜单"
echo -----------------------------------------------
read -p "请输入第"$i"个链接 > " url
test=$(echo $url | grep "://") test=$(echo $url | grep "://")
url=`echo ${url/\ \(*\)/''}` #删除恶心的超链接内容 url=`echo ${url/\ \(*\)/''}` #删除恶心的超链接内容
url=`echo ${url/*\&url\=/""}` #将clash完整链接还原成单一链接 url=`echo ${url/*\&url\=/""}` #将clash完整链接还原成单一链接
url=`echo ${url/\&config\=*/""}` #将clash完整链接还原成单一链接 url=`echo ${url/\&config\=*/""}` #将clash完整链接还原成单一链接
url=`echo ${url//\&/\%26}` #将分隔符 & 替换成urlcode%26 url=`echo ${url//\&/\%26}` #将分隔符 & 替换成urlcode%26
if [[ "$test" != "" ]];then if [[ "$test" != "" ]];then
if [[ -z $Url ]];then if [ -z "$Url" ];then
Url="$url" Url="$url"
else else
Url="$Url"\|"$url" Url="$Url"\|"$url"
fi fi
i=$(($i+1)) i=$((i+1))
elif [ -z $url ];then elif [ -z "$url" ];then
linkset [ -n "$Url" ] && linkset
elif [[ $url == 0 ]];then elif [[ $url == 0 ]];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m已撤销并删除所有已输入的链接\033[0m"
Url=""
sleep 1
clashlink clashlink
else else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的订阅/分享链接!!!\033[0m" echo -e "\033[31m请输入正确的订阅链接\033[0m"
fi fi
done done
#### ####
@@ -190,39 +224,37 @@ clashlink
} }
getlink2(){ getlink2(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[30;47m 此功能不明勿用,出问题自行解决\033[0m" echo -e "\033[33m仅限导入完整clash配置文件链接\033[0m"
echo ----------------------------------------------- echo -e "可以使用\033[32m https://acl4ssr.netlify.app \033[0m在线生成配置文件"
echo -e "\033[33m仅限导入完整clash链接\033[0m" echo -e "\033[36m导入后如无法运行请使用【导入订阅】功能"
echo -e "可以使用\033[32m https://acl4ssr.netlify.app \033[0m在线转换"
echo -e "\033[36m导入后如无法运行请使用【导入节点/订阅链接】功能"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "\033[33m0 返回上级菜单\033[0m" echo -e "\033[33m0 返回上级菜单\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
read -p "请输入完整链接 > " Https read -p "请输入完整链接 > " Https
test=$(echo $Https | grep "://") test=$(echo $Https | grep -iE "http.*://" )
Https=`echo ${Https/\ \(*\)/''}` #删除恶心的超链接内容 Https=`echo ${Https/\ \(*\)/''}` #删除恶心的超链接内容
#Https=`echo ${Https//\&/\%26}` #将分隔符 & 替换成Httpscode%26 if [ -n "$Https" -a -n "$test" ];then
if [ -n $Https ];then echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ -n $test ];then echo -e 请检查输入的链接是否正确:
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -e "\033[4m$Https\033[0m"
echo -e 请检查输入的链接是否正确: read -p "确认导入配置文件原配置文件将被更名为config.yaml.bak![1/0] > " res
echo -e "\033[4m$Https\033[0m" if [ "$res" = '1' ]; then
read -p "确认导入配置文件原配置文件将被更名为config.yaml.bak![1/0] > " res #将用户链接写入mark
if [ "$res" = '1' ]; then sed -i '/Url=*/'d $ccfg
#将用户链接写入mark sed -i '/Https=*/'d $ccfg
sed -i '/Url=*/'d $ccfg sed -i "6i\Https=\'$Https\'" $ccfg
sed -i '/Https=*/'d $ccfg #获取在线yaml文件
sed -i "6i\Https=\'$Https\'" $ccfg $clashdir/start.sh getyaml
#获取在线yaml文件 start_over
$clashdir/start.sh getyaml exit;
fi fi
clashlink
fi
elif [[ $Https == 0 ]];then elif [[ $Https == 0 ]];then
clashlink clashlink
else else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的链接地址\033[0m" echo -e "\033[31m请输入正确的配置文件链接地址!!!\033[0m"
echo -e "\033[33m链接地址必须是http或者https开头的形式\033[0m"
clashlink
fi fi
} }
gettar(){ gettar(){
@@ -292,110 +324,109 @@ if [ "$res" = '1' ]; then
fi fi
} }
getcore(){ getcore(){
source $ccfg
#获取核心及版本信息 #获取核心及版本信息
if [ ! -f $clashdir/clash ]; then [ ! -f $clashdir/clash ] && clashcore="未安装核心"
clashcore=没有安装核心!
clashv=''
fi
clashcore_n=$clashcore
#获取设备处理器架构 #获取设备处理器架构
cpucore=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]') getcputype(){
[ -n "$(echo $cpucore | grep -E "linux.*armv.*")" ] && cpucore="armv5" cputype=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]')
[ -n "$(echo $cpucore | grep -E "linux.*aarch64.*")" ] && cpucore="armv8" [ -n "$(echo $cputype | grep -E "linux.*armv.*")" ] && cpucore="armv5"
[ -n "$(echo $cpucore | grep -E "linux.*armv8.*")" ] && cpucore="armv8" [ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && cpucore="armv7"
[ -n "$(echo $cpucore | grep -E "linux.*armv7.*")" ] && cpucore="armv7" [ -n "$(echo $cputype | grep -E "linux.*aarch64.*|linux.*armv8.*")" ] && cpucore="armv8"
[ -n "$(echo $cpucore | grep -E "linux.*x86.*")" ] && cpucore="386" [ -n "$(echo $cputype | grep -E "linux.*86.*")" ] && cpucore="386"
[ -n "$(echo $cpucore | grep -E "linux.*x86_64.*")" ] && cpucore="amd64" [ -n "$(echo $cputype | grep -E "linux.*86_64.*")" ] && cpucore="amd64"
if [ -n "$(echo $cpucore | grep -E "linux.*mips.*")" ];then if [ -n "$(echo $cputype | grep -E "linux.*mips.*")" ];then
cpucore="mipsle-softfloat" mipstype=$(echo -n I | hexdump -o | awk '{ print substr($2,6,1); exit}') #通过判断大小端判断mips或mipsle
[ -n "$(uname -a | grep -E "*M2100*")" ] && cpucore="mipsle-hardfloat" if [ "$mipstype" = "1" ];then
fi cpucore="mipsle-softfloat"
#[ -n "$(uname -a | grep -E "M2100")" ] && cpucore="mipsle-hardfloat"
else
cpucore="mips-softfloat"
fi
fi
}
### ###
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ -z "$cpucore" ] && getcputype
echo -e "当前clash核心\033[47;30m $clashcore \033[46;30m$clashv\033[0m" echo -e "当前clash核心\033[47;30m $clashcore \033[46;30m$clashv\033[0m"
echo -e "\033[32m请选择需要下载的核心版本\033[0m" echo -e "当前系统处理器架构:\033[32m $cpucore \033[0m"
echo -e "\033[33m请选择需要下载的核心版本\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo "1 clash 稳定,内存占用小,推荐!" echo "1 clash 稳定,内存占用小,推荐!"
echo "(官方正式版) 不支持Tun模式" echo "(官方正式版) 不支持Tun模式、混合模式"
echo echo
echo "2 clashpre 支持Tun模式、混合模式" echo "2 clashpre 支持Tun模式、混合模式"
echo "(高级预览版) 内存占用更高" echo "(高级预览版) 内存占用更高"
echo
echo "3 手动指定处理器架构"
echo ----------------------------------------------- echo -----------------------------------------------
echo 0 返回上级菜单 echo 0 返回上级菜单
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
if [ -z $num ]; then if [ -z "$num" ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m" echo -e "\033[31m请输入正确的数字\033[0m"
update update
elif [[ $num == 0 ]]; then elif [[ $num == 0 ]]; then
update update
elif [[ $num == 1 ]]; then elif [[ $num == 1 ]]; then
clashcore=clash clashcore=clash
version=$clash_v
elif [[ $num == 2 ]]; then elif [[ $num == 2 ]]; then
clashcore=clashpre clashcore=clashpre
version=$clashpre_v
elif [[ $num == 3 ]]; then elif [[ $num == 3 ]]; then
clashcore=clashr cpucore_list="armv5 armv7 armv8 386 amd64 mipsle-softfloat mipsle-hardfloat mips-softfloat"
echo -----------------------------------------------
echo -e "\033[31m仅适合脚本无法正确识别核心或核心无法正常运行时使用\033[0m"
echo -e "当前可供在线下载的处理器架构为:"
echo -e "\033[32m$cpucore_list\033[0m"
echo -e "如果您的CPU架构未在以上列表中请运行【uname -a】命令,并复制好返回信息"
echo -e "之后前往 t.me/clashfm 群提交或 github.com/juewuy/ShellClash 提交issue"
echo -----------------------------------------------
read -p "请手动输入处理器架构 > " cpucore
if [ -z "$(echo $cpucore_list |grep "$cpucore")" ];then
echo -e "\033[31m请输入正确的处理器架构\033[0m"
sleep 1
cpucore=""
fi
getcore
else else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m请输入正确的数字\033[0m" echo -e "\033[31m请输入正确的数字\033[0m"
update update
fi fi
#生成链接 #生成链接
corelink="$update_url/bin/$clashcore/clash-linux-$cpucore" corelink="$update_url/bin/$clashcore/clash-linux-$cpucore"
versionlink="$update_url/bin/$clashcore/version"
#检测版本
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m正在检查更新\033[0m" echo 正在连接服务器获取clash核心文件…………链接地址为
result=$(curl -w %{http_code} -skLo /tmp/clashversion $versionlink) echo -e "\033[4;32m$corelink\033[0m"
[ "$result" != "200" ] && echo "检查更新失败!" && exit 1 echo 如无法正常下载可以手动复制到浏览器下载核心文件!
source /tmp/clashversion echo -e "\033[36m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -e "| |"
echo -e "当前clash核心\033[0m $clashcore_n \033[33m$clashv\033[0m" echo -e "| 需要一点时间,请耐心等待! |"
echo -e "最新clash核心\033[32m $clashcore \033[36m$version\033[0m" echo -e "| \033[0m如长时间没有数据请用ctrl+c退出 |"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\033[0m"
read -p "是否更新?[1/0] > " res #获取在线clash核心文件
if [ "$res" = '1' ]; then result=$(curl -w %{http_code} -kLo /tmp/clash.new $corelink)
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if [ "$result" != "200" ];then
echo 正在连接服务器获取clash核心文件…………链接地址为 echo -----------------------------------------------
echo -e "\033[4;32m$corelink\033[0m" echo -e "\033[31m核心文件下载失败\033[0m"
echo 如无法正常下载可以手动复制到浏览器下载核心文件! echo -----------------------------------------------
echo -e "\033[36m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" getcore
echo -e "| |"
echo -e "| 需要一点时间,请耐心等待! |"
echo -e "| \033[0m如长时间没有数据请用ctrl+c退出 |"
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\033[0m"
#获取在线clash核心文件
result=$(curl -w %{http_code} -kLo /tmp/clash.new $corelink)
if [ "$result" != "200" ];then
echo -----------------------------------------------
echo -e "\033[31m核心文件下载失败\033[0m"
echo -----------------------------------------------
getcore
else
echo -e "\033[32m$clashcore核心下载成功,正在替换!\033[0m"
mv /tmp/clash.new $clashdir/clash
chmod 777 $clashdir/clash #授予权限
sed -i '/clashcore=*/'d $ccfg
sed -i "1i\clashcore=$clashcore" $ccfg
sed -i '/clashv=*/'d $ccfg
sed -i "1i\clashv=$version" $ccfg
rm -rf /tmp/clashversion
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32m$clashcore核心替换成功请手动启动clash服务\033[0m"
clashsh
fi
else else
getcore echo -e "\033[32m$clashcore核心下载成功,正在替换!\033[0m"
mv /tmp/clash.new $clashdir/clash
chmod 777 $clashdir/clash #授予权限
sed -i '/clashcore=*/'d $ccfg
sed -i "1i\clashcore=$clashcore" $ccfg
sed -i '/clashv=*/'d $ccfg
sed -i "1i\clashv=$version" $ccfg
rm -rf /tmp/clashversion
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32m$clashcore核心替换成功请手动启动clash服务\033[0m"
clashsh
fi fi
} }
getgeo(){ getgeo(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m正在检查更新\033[0m"
echo $update_url
result=$(curl -w %{http_code} -skLo /tmp/clashversion $update_url/bin/version)
[ "$result" != "200" ] && echo "检查更新失败!" && exit 1
source /tmp/clashversion
echo ----------------------------------------------- echo -----------------------------------------------
echo -e "当前GeoIP版本为\033[33m $Geo_v \033[0m" echo -e "当前GeoIP版本为\033[33m $Geo_v \033[0m"
echo -e "最新GeoIP版本为\033[32m $GeoIP_v \033[0m" echo -e "最新GeoIP版本为\033[32m $GeoIP_v \033[0m"
@@ -431,8 +462,8 @@ echo -----------------------------------------------
echo -e "\033[32m打开管理面板的速度更快且更稳定" echo -e "\033[32m打开管理面板的速度更快且更稳定"
echo -e "\033[33m需要占用约500kb的本地空间\033[0m" echo -e "\033[33m需要占用约500kb的本地空间\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo " 1 在/www/clash目录安装(http://$host/clash可能安装失败)" echo -e " 1 在$clashdir/ui目录安装推荐\033[33m安装后需重启clash服务\033[0m"
echo " 2 在$clashdir/ui目录安装(http://$host:9999/ui安装后需重启clash)" echo " 2 在/www/clash目录安装(依赖路由器自带的Nginx服务可能安装失败)"
echo ----------------------------------------------- echo -----------------------------------------------
echo " 0 返回上级菜单" echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
@@ -440,11 +471,11 @@ read -p "请输入对应数字 > " num
if [ -z "$num" ];then if [ -z "$num" ];then
update update
elif [ "$num" = '1' ]; then elif [ "$num" = '1' ]; then
dbdir=$clashdir/ui
hostdir=":$db_port/ui\033[0;36m访问面板(需重启clash服务)"
elif [ "$num" = '2' ]; then
dbdir=/www/clash dbdir=/www/clash
hostdir='/clash\033[0;36m访问面板' hostdir='/clash\033[0;36m访问面板'
elif [ "$num" = '2' ]; then
dbdir=$clashdir/ui
hostdir=':9999/ui\033[0;36m访问面板(需重启clash服务)'
else else
update update
fi fi
@@ -478,8 +509,8 @@ fi
tar -zxvf '/tmp/clashdb.tar.gz' -C $dbdir > /dev/null tar -zxvf '/tmp/clashdb.tar.gz' -C $dbdir > /dev/null
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1 [ $? -ne 0 ] && echo "文件解压失败!" && exit 1
#修改默认host和端口 #修改默认host和端口
sed -i "s/127.0.0.1/$host/g" $dbdir/js/*.js sed -i "s/127.0.0.1/${host}/g" $dbdir/js/*.js
sed -i "s/9090/9999/g" $dbdir/js/*.js sed -i "s/9090/${db_port}/g" $dbdir/js/*.js
# #
echo -e "\033[32m面板安装成功\033[0m" echo -e "\033[32m面板安装成功\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -495,7 +526,7 @@ catpac(){
[ ! -d /www/clash -a ! -d $clashdir/ui ]&&echo 未检测到本地Dashboard面板请先安装面板&&sleep 1&&getdb [ ! -d /www/clash -a ! -d $clashdir/ui ]&&echo 未检测到本地Dashboard面板请先安装面板&&sleep 1&&getdb
#host=$(ubus call network.interface.lan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';) #host=$(ubus call network.interface.lan status | grep \"address\" | grep -oE '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}';)
[ -d /www/clash ]&&dir="/www/clash"&&pac=http://$host/clash/pac [ -d /www/clash ]&&dir="/www/clash"&&pac=http://$host/clash/pac
[ -d $clashdir/ui ]&&dir="$clashdir/ui"&&pac=http://$host:9999/ui/pac [ -d $clashdir/ui ]&&dir="$clashdir/ui"&&pac=http://$host:$db_port/ui/pac
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[30;47m生成用于设备WIFI或浏览器的自动PAC代理文件\033[0m" echo -e "\033[30;47m生成用于设备WIFI或浏览器的自动PAC代理文件\033[0m"
echo -e "\033[33m非纯净模式不推荐使用此功能\033[0m" echo -e "\033[33m非纯净模式不推荐使用此功能\033[0m"
@@ -508,7 +539,7 @@ echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
if [ "$num" = '1' ]; then if [ "$num" = '1' ]; then
echo 'function FindProxyForURL(url, host) {' > $dir/pac echo 'function FindProxyForURL(url, host) {' > $dir/pac
echo " return \"SOCKS $host:7890; PROXY $host:7890; DIRECT;\"" >> $dir/pac echo " return \"SOCKS $host:$mix_port; PROXY $host:$mix_port; DIRECT;\"" >> $dir/pac
echo '}' >> $dir/pac echo '}' >> $dir/pac
echo -e "\033[33mPAC文件已生成\033[0m" echo -e "\033[33mPAC文件已生成\033[0m"
echo -e "PAC地址\033[32m$pac\033[0m" echo -e "PAC地址\033[32m$pac\033[0m"
@@ -527,13 +558,13 @@ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[30;47m您可以在此处切换在线更新时使用的资源地址\033[0m" echo -e "\033[30;47m您可以在此处切换在线更新时使用的资源地址\033[0m"
echo -e "当前源:\033[4;32m$update_url\033[0m" echo -e "当前源:\033[4;32m$update_url\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e " 1 Github源(使用host指定IP)" echo -e " 1 Github源(直连美国服务器)"
echo -e " 2 CDN源(仅同步最新release版本)" echo -e " 2 Jsdelivr-CDN源(仅同步最新release版本)"
echo -e " 3 Github源+clash代理(需开启clash服务)" echo -e " 3 Github源+clash代理(需开启clash服务)"
echo -e " 4 自定义输入(请务必确保路径正确)" echo -e " 4 自定义输入(请务必确保路径正确)"
echo -e " 0 返回上级菜单" echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num read -p "请输入对应数字 > " num
if [ -z $num ]; then if [ -z "$num" ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m" echo -e "\033[31m请输入正确的数字\033[0m"
update update
@@ -542,11 +573,11 @@ elif [[ $num == 1 ]]; then
elif [[ $num == 2 ]]; then elif [[ $num == 2 ]]; then
update_url='https://cdn.jsdelivr.net/gh/juewuy/ShellClash' update_url='https://cdn.jsdelivr.net/gh/juewuy/ShellClash'
elif [[ $num == 3 ]]; then elif [[ $num == 3 ]]; then
update_url='-x 127.0.0.1:7890 https://raw.githubusercontent.com/juewuy/ShellClash/master' update_url='-x 127.0.0.1:'$mix_port' https://raw.githubusercontent.com/juewuy/ShellClash/master'
elif [[ $num == 4 ]]; then elif [[ $num == 4 ]]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
read -p "请输入个人源路径 > " update_url read -p "请输入个人源路径 > " update_url
if [ -n $update_url ];then if [ -z "$update_url" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m取消输入返回上级菜单\033[0m" echo -e "\033[31m取消输入返回上级菜单\033[0m"
update update
@@ -563,5 +594,6 @@ sed -i '/update_url*/'d $ccfg
sed -i "1i\update_url=\'$update_url\'" $ccfg sed -i "1i\update_url=\'$update_url\'" $ccfg
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32m源地址更新成功\033[0m" echo -e "\033[32m源地址更新成功\033[0m"
release_new=""
update update
} }

View File

@@ -17,38 +17,41 @@ source $ccfg
[ -z "$ipv6_support" ] && ipv6_support=未开启 [ -z "$ipv6_support" ] && ipv6_support=未开启
[ -z "$start_old" ] && start_old=未开启 [ -z "$start_old" ] && start_old=未开启
[ -z "$local_proxy" ] && local_proxy=未开启 [ -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
#是否代理常用端口 #是否代理常用端口
[ "$common_ports" = "已开启" ] && ports='-m multiport --dports 22,53,587,465,995,993,143,80,443 ' [ "$common_ports" = "已开启" ] && ports='-m multiport --dports 22,53,587,465,995,993,143,80,443 '
#检测系统端口占用
for portx in 1053 7890 7892 9999 ;do
[ -n "$(netstat -ntulp |grep :$portx|grep -v clash)" ] && echo -e "检测到端口:\033[30;47m $portx \033[0m被以下进程占用clash无法启动" && echo $(netstat -ntulp |grep :$portx) && exit;
done
} }
getyaml(){ getyaml(){
#前后端订阅服务器地址索引,可在此处添加! #前后端订阅服务器地址索引,可在此处添加!
Server=`sed -n ""$server_link"p"<<EOF Server=`sed -n ""$server_link"p"<<EOF
subconverter-web.now.sh subcon.dlj.tf
subconverter.herokuapp.com subconverter.herokuapp.com
subcon.py6.pw subcon.py6.pw
api.dler.io api.dler.io
api.wcc.best api.wcc.best
skapi.cool
EOF` EOF`
Config=`sed -n ""$rule_link"p"<<EOF Config=`sed -n ""$rule_link"p"<<EOF
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online.ini 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_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_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_Mini_AdblockPlus.ini
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_NoReject.ini
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_NoAuto.ini
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Mini_NoAuto.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_Netflix.ini
https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_Online_Full_AdblockPlus.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
EOF` EOF`
#如果传来的是Url链接则合成Https链接否则直接使用Https链接 #如果传来的是Url链接则合成Https链接否则直接使用Https链接
if [ -z $Https ];then if [ -z "$Https" ];then
#echo $Url #echo $Url
Https="https://$Server/sub?target=clashr&insert=true&new_name=true&scv=true&exclude=$exclude&url=$Url&config=$Config" Https="https://$Server/sub?target=clash&insert=true&new_name=true&scv=true&exclude=$exclude&include=$include&url=$Url&config=$Config"
markhttp=1 markhttp=1
fi fi
# #
@@ -69,142 +72,126 @@ result=$(curl -w %{http_code} -kLo $yamlnew $Https)
if [ "$result" != "200" ];then if [ "$result" != "200" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m配置文件获取失败\033[0m" echo -e "\033[31m配置文件获取失败\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if [ -z "$markhttp" ];then
echo echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ -z $markhttp ];then echo -e "\033[31m请尝试使用【导入节点/链接】功能!\033[0m"
echo 请尝试使用导入节点/链接功能! echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
getlink exit 1
else else
read -p "是否更换后端地址后重试?[1/0] > " res if [ "$retry" -ge 5 ];then
if [ "$res" = '1' ]; then echo -e "\033[32m无法获取配置文件请检查链接格式以及网络连接状态\033[0m"
exit 1
else
retry=$((retry+1))
echo -e "\033[32m尝试使用其他服务器获取配置\033[0m"
echo -e "\033[33m正在尝试第$retry次/共5次\033[0m"
sed -i '/server_link=*/'d $ccfg sed -i '/server_link=*/'d $ccfg
if [[ $server_link -ge 6 ]]; then if [ "$server_link" -ge 5 ]; then
server_link=0 server_link=0
fi fi
server_link=$(($server_link + 1)) server_link=$((server_link+1))
echo $server_link
sed -i "1i\server_link=$server_link" $ccfg sed -i "1i\server_link=$server_link" $ccfg
Https="" Https=""
getyaml getyaml
fi fi
#exit;
fi fi
else else
Https="" Https=""
if cat $yamlnew | grep ', server:' >/dev/null;then #检测节点
#检测旧格式 if [ -z "$(cat $yamlnew | grep 'server:' | grep -v 'nameserver')" ];then
if cat $yamlnew | grep 'Proxy Group:' >/dev/null;then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m已经停止对旧格式配置文件的支持\033[0m"
echo -e "请使用新格式或者使用\033[32m导入节点/订阅\033[0m功能"
sleep 2
clashlink
fi
#检测不支持的加密协议
if cat $yamlnew | grep 'cipher: chacha20,' >/dev/null;then
if [ "$clashcore" = "clash" -o "$clashcore" = "clashpre" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m当前核心$clashcore不支持chacha20加密\033[0m"
echo -e "请更换使用clashR核心"
sleep 2
getcore
fi
fi
#替换文件
[ -f $yaml ] && mv $yaml $yaml.bak
mv $yamlnew $yaml
echo 配置文件已生成正在启动clash使其生效
#重启clash服务
$0 stop
$0 start
sleep 1
if pidof clash >/dev/null;then
start_over
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ -f $yaml.bak ];then
$clashdir/start.sh stop
mv $yaml.bak $yaml
$0 start
echo -e "\033[31mclash服务启动失败已还原配置文件并重启clash\033[0m"
sleep 1
if pidof clash >/dev/null;then
start_over
exit;
fi
fi
echo -e "\033[31mclash服务启动失败请查看报错信息\033[0m"
$0 stop
$clashdir/clash -t -d $clashdir
exit;
fi
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m获取到了配置文件但格式似乎不对\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[33m获取到了配置文件但似乎并不包含正确的节点信息\033[0m"
echo -----------------------------------------------
sed -n '1,30p' $yamlnew sed -n '1,30p' $yamlnew
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[33m请检查如上配置文件信息:\033[0m" echo -e "\033[33m请检查如上配置文件信息:\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exit 1
fi
#检测旧格式
if cat $yamlnew | grep 'Proxy Group:' >/dev/null;then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m已经停止对旧格式配置文件的支持\033[0m"
echo -e "请使用新格式或者使用【导入节点/链接】功能!"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exit 1
fi
#检测不支持的加密协议
if cat $yamlnew | grep 'cipher: chacha20,' >/dev/null;then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m不支持chacha20加密请更换节点加密协议\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exit 1
fi
#替换文件
[ -f $yaml ] && mv $yaml $yaml.bak
mv $yamlnew $yaml
echo 配置文件已生成正在启动clash使其生效
#重启clash服务
$0 stop
$0 start
sleep 1
if [ -z "$(pidof clash)" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if [ -f $yaml.bak ];then
$clashdir/start.sh stop
mv $yaml.bak $yaml
$0 start
echo -e "\033[31mclash服务启动失败已还原配置文件并重启clash\033[0m"
sleep 1
[ -n "$(pidof clash)" ] && exit 0
fi
echo -e "\033[31mclash服务启动失败请查看报错信息\033[0m"
$0 stop
$clashdir/clash -t -d $clashdir
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exit 1
fi fi
#exit;
fi fi
#exit
} }
modify_yaml(){ modify_yaml(){
##########需要变更的配置########### ##########需要变更的配置###########
mix='mixed-port: 7890'
redir='redir-port: 7892'
lan='allow-lan: true' lan='allow-lan: true'
mode='mode: Rule' mode='mode: Rule'
log='log-level: info' log='log-level: info'
if [ "$ipv6_support" = "已开启" ];then [ "$ipv6_support" = "已开启" ] && ipv6='ipv6: true' || ipv6='ipv6: false'
ipv6='ipv6: true' external="external-controller: 0.0.0.0:$db_port"
else [ -d $clashdir/ui ] && db_ui=ui
ipv6='ipv6: false' [ "$redir_mod" != "Redir模式" ] && tun='tun: {enable: true, stack: system}' || tun='tun: {enable: false}'
fi
external='external-controller: 0.0.0.0:9999'
if [ -d $clashdir/ui ];then
external_ui='external-ui: ui'
else
external_ui='external-ui:'
fi
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]}'
elif [ "$dns_over" = "已开启" ];then
dns='dns: {enable: true, ipv6: true, listen: 0.0.0.0:1053, enhanced-mode: redir-host, nameserver: [114.114.114.114, 223.5.5.5], fallback: [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, 223.5.5.5, 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}' 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"], nameserver: [114.114.114.114, 223.5.5.5, 127.0.0.1:53], fallback: [tcp://1.0.0.1, 8.8.4.4], fallback-filter: {geoip: true}}'
elif [ "$dns_over" = "已开启" ];then
dns='dns: {enable: true, ipv6: true, listen: 0.0.0.0:'$dns_port', use-hosts: true, enhanced-mode: redir-host, nameserver: [114.114.114.114, 223.5.5.5], fallback: [1.0.0.1, 8.8.4.4], 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: [114.114.114.114, 223.5.5.5, 127.0.0.1:53], fallback: [1.0.0.1, 8.8.4.4], fallback-filter: {geoip: true}}'
fi
################################### ###################################
yaml=$clashdir/config.yaml
#预删除需要添加的项目 #预删除需要添加的项目
i=$(grep -n "^proxies:" $clashdir/config.yaml | head -1 | cut -d ":" -f 1) i=$(grep -n "^proxies:" $clashdir/config.yaml | head -1 | cut -d ":" -f 1)
i=$(($i-1)) i=$((i-1))
sed -i "1,${i}d" $clashdir/config.yaml sed -i "1,${i}d" $yaml
#添加配置 #添加配置
sed -i "1i$mix" $clashdir/config.yaml sed -i "1imixed-port:\ $mix_port" $yaml
sed -i "1a$redir" $clashdir/config.yaml sed -i "1aredir-port:\ $redir_port" $yaml
sed -i "2a$lan" $clashdir/config.yaml sed -i "2a$lan" $yaml
sed -i "3a$mode" $clashdir/config.yaml sed -i "3a$mode" $yaml
sed -i "4a$log" $clashdir/config.yaml sed -i "4a$log" $yaml
sed -i "5a$ipv6" $clashdir/config.yaml sed -i "5a$ipv6" $yaml
sed -i "6a$external" $clashdir/config.yaml sed -i "6aexternal-controller:\ :$db_port" $yaml
sed -i "7a$external_ui" $clashdir/config.yaml sed -i "7aexternal-ui:\ $db_ui" $yaml
sed -i "8a$dns" $clashdir/config.yaml sed -i "8asecret:\ $secret" $yaml
sed -i "9a$tun" $clashdir/config.yaml sed -i "9a$dns" $yaml
sed -i "10a$exper" $clashdir/config.yaml sed -i "10a$tun" $yaml
sed -i "11a$exper" $yaml
#跳过本地tls证书验证 #跳过本地tls证书验证
if [ "$skip_cert" = "已开启" ];then if [ "$skip_cert" = "已开启" ];then
sed -i '10,99s/skip-cert-verify: false/skip-cert-verify: true/' $clashdir/config.yaml sed -i '10,99s/skip-cert-verify: false/skip-cert-verify: true/' $yaml
else else
sed -i '10,99s/skip-cert-verify: true/skip-cert-verify: false/' $clashdir/config.yaml sed -i '10,99s/skip-cert-verify: true/skip-cert-verify: false/' $yaml
fi fi
} }
mark_time(){ mark_time(){
@@ -227,16 +214,16 @@ start_redir(){
iptables -t nat -A clash -m mac --mac-source $mac -j RETURN iptables -t nat -A clash -m mac --mac-source $mac -j RETURN
done done
#设置防火墙流量转发 #设置防火墙流量转发
iptables -t nat -A clash -p tcp $ports-j REDIRECT --to-ports 7892 iptables -t nat -A clash -p tcp $ports-j REDIRECT --to-ports $redir_port
iptables -t nat -A PREROUTING -p tcp -j clash iptables -t nat -A PREROUTING -p tcp -j clash
#设置ipv6转发 #设置ipv6转发
if [ "$ipv6_support" = "已开启" ];then if [ -n "ip6_nat" -a "$ipv6_support" = "已开启" ];then
ip6tables -t nat -N clash ip6tables -t nat -N clashv6
for mac in $(cat $clashdir/mac); do for mac in $(cat $clashdir/mac); do
ip6tables -t nat -A clash -m mac --mac-source $mac -j RETURN ip6tables -t nat -A clashv6 -m mac --mac-source $mac -j RETURN
done done
ip6tables -t nat -A clash -p tcp $ports-j REDIRECT --to-ports 7892 ip6tables -t nat -A clashv6 -p tcp $ports-j REDIRECT --to-ports $redir_port
ip6tables -t nat -A PREROUTING -p tcp -j clash ip6tables -t nat -A PREROUTING -p tcp -j clashv6
fi fi
} }
stop_iptables(){ stop_iptables(){
@@ -245,54 +232,98 @@ stop_iptables(){
iptables -t nat -D PREROUTING -p udp -j clash_dns > /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.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 -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 -F clash > /dev/null 2>&1
iptables -t nat -X 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 -F clash_dns > /dev/null 2>&1
iptables -t nat -X 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
#重置ipv6规则 #重置ipv6规则
ip6tables -t nat -D PREROUTING -p tcp -j clash > /dev/null 2>&1 ip6tables -t nat -D PREROUTING -p tcp -j clashv6 > /dev/null 2>&1
ip6tables -t nat -D PREROUTING -p udp -j clash_dns > /dev/null 2>&1 ip6tables -t nat -D PREROUTING -p udp -j clashv6_dns > /dev/null 2>&1
ip6tables -t nat -F clash > /dev/null 2>&1 ip6tables -t nat -F clashv6 > /dev/null 2>&1
ip6tables -t nat -X clash > /dev/null 2>&1 ip6tables -t nat -X clashv6 > /dev/null 2>&1
ip6tables -t nat -F clash_dns > /dev/null 2>&1 ip6tables -t nat -F clashv6_dns > /dev/null 2>&1
ip6tables -t nat -X clash_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
} }
start_dns(){ start_dns(){
#允许tun网卡接受流量 #允许tun网卡接受流量
iptables -I FORWARD -o utun -j ACCEPT if [ "$redir_mod" = "Tun模式" -o "$redir_mod" = "混合模式" ];then
ip6tables -I FORWARD -o utun -j ACCEPT > /dev/null 2>&1 iptables -I FORWARD -o utun -j ACCEPT
[ "$ipv6_support" = "已开启" ] && ip6tables -I FORWARD -o utun -j ACCEPT > /dev/null 2>&1
fi
#设置dns转发 #设置dns转发
iptables -t nat -N clash_dns iptables -t nat -N clash_dns
for mac in $(cat $clashdir/mac); do for mac in $(cat $clashdir/mac); do
iptables -t nat -A clash_dns -m mac --mac-source $mac -j RETURN iptables -t nat -A clash_dns -m mac --mac-source $mac -j RETURN
done done
iptables -t nat -A clash_dns -p udp --dport 53 -j REDIRECT --to 1053 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 1053 iptables -t nat -A clash_dns -p tcp --dport 53 -j REDIRECT --to $dns_port
iptables -t nat -A PREROUTING -p udp -j clash_dns iptables -t nat -A PREROUTING -p udp -j clash_dns
#Google home DNS特殊处理 #Google home DNS特殊处理
iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 -j clash_dns iptables -t nat -I PREROUTING -p tcp -d 8.8.8.8 -j clash_dns
iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j clash_dns iptables -t nat -I PREROUTING -p tcp -d 8.8.4.4 -j clash_dns
#ipv6DNS #ipv6DNS
ip6tables -t nat -N clash_dns > /dev/null 2>&1 ip6_nat=$(ip6tables -t nat -L 2>&1|grep -o 'Chain')
for mac in $(cat $clashdir/mac); do if [ -n "ip6_nat" ];then
ip6tables -t nat -A clash_dns -m mac --mac-source $mac -j RETURN > /dev/null 2>&1 ip6tables -t nat -N clashv6_dns > /dev/null 2>&1
done for mac in $(cat $clashdir/mac); do
ip6tables -t nat -A clash_dns -p udp --dport 53 -j REDIRECT --to 1053 > /dev/null 2>&1 ip6tables -t nat -A clashv6_dns -m mac --mac-source $mac -j RETURN > /dev/null 2>&1
ip6tables -t nat -A PREROUTING -p udp -j clash_dns > /dev/null 2>&1 done
} ip6tables -t nat -A clashv6_dns -p udp --dport 53 -j REDIRECT --to $dns_port > /dev/null 2>&1
checkcron(){ ip6tables -t nat -A PREROUTING -p udp -j clashv6_dns > /dev/null 2>&1
[ -d /etc/crontabs/ ]&&cronpath="/etc/crontabs/root" else
[ -d /var/spool/cron/ ]&&cronpath="/var/spool/cron/root" ip6tables -I INPUT -p tcp --dport 53 -j REJECT
[ -d /var/spool/cron/crontabs/ ]&&cronpath="/var/spool/cron/crontabs/root" ip6tables -I INPUT -p udp --dport 53 -j REJECT
[ -z $cronpath ]&&echo "找不到定时任务文件,无法添加定时任务!" fi
} }
daemon(){ daemon(){
checkcron if [ -n "$cronpath" ];then
echo '*/1 * * * * test -z "$(pidof clash)" && /etc/init.d/clash restart #clash守护进程' >> $cronpath echo '*/1 * * * * test -z "$(pidof clash)" && /etc/init.d/clash restart #clash保守模式守护进程' >> $cronpath
chmod 600 $cronpath chmod 600 $cronpath
else
echo 找不到定时任务配置文件,无法添加守护进程!
echo 请进入定时任务菜单手动指定系统定时任务文件路径!!!
fi
}
web_save(){
#使用curl获取面板节点设置
curl -s -H "Authorization: Bearer ${secret}" -H "Content-Type:application/json" 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
#对比文件,如果有变动则写入磁盘,否则清除缓存
if [ "$(cat /tmp/clash_web_save)" = "$(cat $clashdir/web_save 2>/dev/null)" ];then
rm -rf /tmp/clash_web_save
else
mv -f /tmp/clash_web_save $clashdir/web_save
fi
}
web_restore(){
#设置循环检测clash面板端口
i=1
while [ $i -lt 10 ]
do
sleep 1
[ -n "$(curl -s http://localhost:${db_port})" ] && 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)
curl -sS -X PUT -H "Authorization: Bearer ${secret}" -H "Content-Type:application/json" http://localhost:${db_port}/proxies/"${group_name}" -d "{\"name\":\"${now_name}\"}" >/dev/null
done
exit 0
}
web_save_auto(){
if [ -n "$cronpath" ];then
if [ -z "$(cat $cronpath | grep '保存节点配置')" ];then
echo '*/10 * * * * test -n "$(pidof clash)" && /etc/init.d/clash web_save #每10分钟保存节点配置' >> $cronpath
chmod 600 $cronpath
fi
else
echo 找不到定时任务配置文件,无法添加守护进程!
echo 请进入定时任务菜单手动指定系统定时任务文件路径!!!
fi
} }
afstart(){ afstart(){
#读取配置文件 #读取配置文件
@@ -303,6 +334,12 @@ afstart(){
[ "$redir_mod" != "纯净模式" ] && [ "$redir_mod" != "Tun模式" ] && start_redir [ "$redir_mod" != "纯净模式" ] && [ "$redir_mod" != "Tun模式" ] && start_redir
#标记启动时间 #标记启动时间
mark_time mark_time
#设置本机代理
[ "$local_proxy" = "已开启" ] && $0 set_proxy $mix_port
#启用面板配置自动保存
web_save_auto
#后台还原面板配置
[ -f $clashdir/web_save ] && web_restore &
} }
case "$1" in case "$1" in
@@ -318,6 +355,7 @@ start)
#使用不同方式启动clash服务 #使用不同方式启动clash服务
if [ "$start_old" = "已开启" ];then if [ "$start_old" = "已开启" ];then
$clashdir/clash -d $clashdir >/dev/null 2>&1 & $clashdir/clash -d $clashdir >/dev/null 2>&1 &
sleep 1
daemon daemon
afstart afstart
elif [ -f /etc/rc.common ];then elif [ -f /etc/rc.common ];then
@@ -327,9 +365,13 @@ start)
fi fi
;; ;;
stop) stop)
#删除守护 #读取配置文件
checkcron getconfig
sed -i /clash守护进程/d $cronpath >/dev/null 2>&1 #保存面板配置
web_save
#删除守护进程&面板配置自动保存
sed -i /clash保守模式守护进程/d $cronpath >/dev/null 2>&1
sed -i /面板配置自动保存/d $cronpath >/dev/null 2>&1
#多种方式结束进程 #多种方式结束进程
if [ -f /etc/rc.common ];then if [ -f /etc/rc.common ];then
/etc/init.d/clash stop >/dev/null 2>&1 /etc/init.d/clash stop >/dev/null 2>&1
@@ -339,6 +381,8 @@ stop)
killall -9 clash >/dev/null 2>&1 killall -9 clash >/dev/null 2>&1
#清理iptables #清理iptables
stop_iptables stop_iptables
#禁用本机代理
[ "$local_proxy" = "已开启" ] && $0 unset_proxy
;; ;;
restart) restart)
$0 stop $0 stop
@@ -351,5 +395,18 @@ getyaml)
daemon) daemon)
daemon daemon
;; ;;
web_save)
getconfig
web_save
;;
set_proxy)
echo 'export all_proxy=http://127.0.0.1:'"$2" >> /etc/profile
echo 'export ALL_PROXY=$all_proxy' >> /etc/profile
;;
unset_proxy)
sed -i '/all_proxy/'d /etc/profile
sed -i '/ALL_PROXY/'d /etc/profile
;;
esac esac
#exit 0
exit 0