25 Commits

Author SHA1 Message Date
juewuy
5cdf5a520e v1.0.0beta17
~同步最新版本Geoip数据库
~新增更新切换版本到其他release版本的功能
~调整release版本更新检测机制
~修复部分设备提示缺少cmb的问题
~修复使用自定义规则时,每次启动clash规则都会被重复导入的问题
~进一步优化面板保存机制
2020-11-08 15:02:24 +08:00
juewuy
ff7f6e7dc0 v1.0.0beta16.9
~新增更新切换版本到其他release版本的功能
~调整release版本更新检测机制
~修复部分设备提示缺少cmb的问题
~修复使用自定义规则时,每次启动clash规则都会被重复导入的问题
~进一步优化面板保存机制
2020-11-07 12:08:49 +08:00
juewuy
ed30acdd7a v1.0.0beta16.9
~新增更新切换版本到其他release版本的功能
~调整release版本更新检测机制
~修复部分设备提示缺少cmb的问题
~修复使用自定义规则时,每次启动clash规则都会被重复导入的问题
~进一步优化面板保存机制
2020-11-07 12:08:31 +08:00
juewuy
1d38865e03 v1.0.0beta16.9
~调整release版本更新检测机制
2020-11-07 11:49:36 +08:00
juewuy
5cb5bfe5e0 v1.0.0beta16.9
~调整release版本更新检测机制
2020-11-07 11:45:34 +08:00
juewuy
286f043849 v1.0.0beta16.8
~优化了mac地址导入和删除,现在不完全依赖dhcp服务
~优化了合并配置文件的方式,修复部分设备报错的bug
~修复保守模式守护进程未能正确添加的bug
~修复某些情况下提示iptables链已创建的bug
~修复了某些情况下重启导致保持节点被重置的bug
2020-11-06 16:59:49 +08:00
juewuy
44940d3496 v1.0.0beta16.8
~优化了mac地址导入和删除,现在不完全依赖dhcp服务
~优化了合并配置文件的方式,修复部分设备报错的bug
2020-11-05 22:14:14 +08:00
juewuy
4bceb9af59 v1.0.0beta16.8
~优化了mac地址导入和删除,现在不完全依赖dhcp服务
2020-11-05 21:54:38 +08:00
juewuy
9c0440caaf v1.0.0beta16.7
~增加tproxy——udp模式对黑白名单mac过滤的适配
~优化导入自定义配置文件功能
~修复ip6tables在不可用时仍旧强行使用导致报错的bug
~修复ipv6dns导致污染的bug
2020-11-05 20:58:17 +08:00
juewuy
8fbb88b707 v1.0.0beta16.7
~增加tproxy——udp模式对黑白名单mac过滤的适配
~优化导入自定义配置文件功能
~修复ip6tables在不可用时仍旧强行使用导致报错的bug
~修复ipv6dns导致污染的bug
2020-11-05 20:53:27 +08:00
juewuy
6957d57f1f v1.0.0beta16.7
~增加tproxy——udp模式对黑白名单mac过滤的适配
~优化导入自定义配置文件功能
~修复ip6tables在不可用时仍旧强行使用导致报错的bug
~修复ipv6dns导致污染的bug
2020-11-05 20:53:05 +08:00
juewuy
d0ecb222ab v1.0.0beta16.6
~优化自定义规则及配置的导入方式,增加示例文件
~优化mac白名单导致部分设备ip6tables报错的问题,待测试
2020-11-05 15:03:53 +08:00
juewuy
771082da78 v1.0.0beta16.6
~优化自定义规则及配置的导入方式,增加示例文件
~优化mac白名单导致部分设备ip6tables报错的问题,待测试
2020-11-05 15:03:31 +08:00
juewuy
4a371398cf v1.0.0beta16.6
~优化自定义规则及配置的导入方式,增加示例文件
~优化mac白名单导致部分设备ip6tables报错的问题,待测试
2020-11-05 14:59:37 +08:00
juewuy
b63a6c52a4 v1.0.0beta16.6
~优化自定义规则及配置的导入方式,增加示例文件
~优化mac白名单导致部分设备ip6tables报错的问题,待测试
2020-11-05 14:55:23 +08:00
juewuy
2fcbeb7655 v1.0.0beta16.6
~优化自定义规则及配置的导入方式,增加示例文件
~优化mac白名单导致部分设备ip6tables报错的问题,待测试
2020-11-05 14:54:52 +08:00
juewuy
7bb60f7aab v1.0.0beta16.5
~修复白名单模式部分情况下不可用的bug
~屏蔽不使用本地dns功能,如有需求可在dns配置中自行编辑
~屏蔽使用自定义配置功能,现在可以手动将自定义设置写入user.yaml、自定义规则写入rules.yaml,运行时会自动合并配置文件
~修复设置http代理加密后导致更新检测失败的bug
~修复添加3个以上dns时添加失败的bug
2020-11-03 23:11:16 +08:00
juewuy
9624b5456c v1.0.0beta16.5
~修复白名单模式部分情况下不可用的bug
~屏蔽不使用本地dns功能,如有需求可在dns配置中自行编辑
~屏蔽使用自定义配置功能,现在可以手动将自定义设置写入user.yaml、自定义规则写入rules.yaml,运行时会自动合并配置文件
~修复设置http代理加密后导致更新检测失败的bug
~修复添加3个以上dns时添加失败的bug
2020-11-03 23:10:57 +08:00
juewuy
fcc211a6a7 v1.0.0beta16.4
~增加mac过滤白名单功能
~屏蔽不使用本地dns功能,如有需求可在dns配置中自行编辑
~屏蔽使用自定义配置功能,现在可以手动将自定义设置写入user.yaml、自定义规则写入rules.yaml,运行时会自动合并配置文件
~修复设置http代理加密后导致更新检测失败的bug
~修复添加3个以上dns时添加失败的bug
2020-11-03 16:50:32 +08:00
juewuy
9687748b85 v1.0.0beta16.4
~增加mac过滤白名单功能
~屏蔽不使用本地dns功能,如有需求可在dns配置中自行编辑
~屏蔽使用自定义配置功能,现在可以手动将自定义设置写入user.yaml、自定义规则写入rules.yaml,运行时会自动合并配置文件
~修复设置http代理加密后导致更新检测失败的bug
~修复添加3个以上dns时添加失败的bug
2020-11-03 16:50:10 +08:00
juewuy
6949df4e3d v1.0.0beta16.4
~增加mac过滤白名单功能
~屏蔽不使用本地dns功能,如有需求可在dns配置中自行编辑
~屏蔽使用自定义配置功能,现在可以手动将配置文件写入user.yaml,运行时会自动合并配置文件
~修复设置http代理加密后导致更新检测失败的bug
2020-11-03 16:41:41 +08:00
juewuy
7ee2085ce4 v1.0.0beta16.3
~修复部分设备启动时报错的bug
~大幅度优化新手引导
~新增小闪存模式,适合ROM大小较低的设备使用
~全新的下载机制,现在会在运行时自动下载核心文件
~修复部分设备tun模式不可启用的bug
2020-11-01 20:15:11 +08:00
juewuy
e62797205c v1.0.0beta16.2
~大幅度优化新手引导
~新增小闪存模式,适合ROM大小较低的设备使用
~全新的下载机制,现在会在运行时自动下载核心文件
~修复部分设备tun模式不可启用的bug
2020-11-01 12:13:14 +08:00
juewuy
5b7a31f044 v1.0.0beta16.2
~大幅度优化新手引导
~新增小闪存模式,适合ROM大小较低的设备使用
~全新的下载机制,现在会在运行时自动下载核心文件
~修复部分设备tun模式不可启用的bug
2020-11-01 12:12:50 +08:00
juewuy
33ca5f3969 v1.0.0beta16.1
~回退最新premium核心,修复bug
2020-11-01 11:41:55 +08:00
11 changed files with 254 additions and 133 deletions

View File

@@ -96,6 +96,10 @@ ubus/iproute-doc 极低 缺少时无法正常获取本机host地址
### [详见博客](https://juewuy.github.io)
## 捐赠此项目:
### [前往页面](https://juewuy.github.io/yOF4Yf06Q/)
友情推广:
--
### [顶级8K专线机场-墙洞](https://dler.best/auth/register?affid=89698)

Binary file not shown.

Binary file not shown.

Binary file not shown.

4
bin/release_version Normal file
View File

@@ -0,0 +1,4 @@
1.0.0beta15
1.0.0beta11
1.0.0beta5
0.9.7

View File

@@ -1,4 +1,4 @@
clash_v=1.2.0
versionsh=1.0.0beta16
clashpre_v=2020.10.26
GeoIP_v=20201031
GeoIP_v=20201108
versionsh=1.0.0beta17

Binary file not shown.

View File

@@ -40,8 +40,8 @@ if [ "$test" -gt 0 ];then
[ "$test" -eq 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi"
[ "$test" -eq 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi"
else
webget /tmp/clashrelease https://github.com.cnpmjs.org/juewuy/ShellClash/releases/latest echoon rediroff 2>/tmp/clashrelease
release_new=$( cat /tmp/clashrelease | grep -aoE "releases/tag/.*" | awk -F '[/" ]' '{print $3}')
webget /tmp/clashrelease $url@master/bin/release_version echoon rediroff 2>/tmp/clashrelease
release_new=$(cat /tmp/clashrelease | head -1)
[ -z "$release_new" ] && release_new=master
url=$url@$release_new
fi

View File

@@ -227,14 +227,14 @@ setdns(){
[ -z "$dns_nameserver" ] && dns_nameserver='114.114.114.114, 223.5.5.5'
[ -z "$dns_fallback" ] && dns_fallback='1.0.0.1, 8.8.4.4'
echo -----------------------------------------------
echo -e "当前基础DNS\033[36m$dns_nameserver\033[0m"
echo -e "当前基础DNS\033[32m$dns_nameserver\033[0m"
echo -e "fallbackDNS\033[36m$dns_fallback\033[0m"
echo -e "多个DNS地址请用\033[30;47m | \033[0m分隔一次性输入"
echo -e "\033[33m使用redir-host时fallback组暂不支持tls或者https形式的DNS\033[0m"
echo -----------------------------------------------
echo -e " 1 修改基础DNS"
echo -e " 2 修改fallback_DNS"
echo -e " 3 重置DNS配置"
echo -e " 1 修改\033[32m基础DNS\033[0m"
echo -e " 2 修改\033[36mfallback_DNS\033[0m"
echo -e " 3 \033[33m重置\033[0mDNS配置"
echo -e " 4 禁用内置DNS(慎用)"
echo -e " 0 返回上级菜单"
echo -----------------------------------------------
@@ -244,16 +244,16 @@ setdns(){
clashadv
elif [ "$num" = 1 ]; then
read -p "请输入新的DNS > " dns_nameserver
dns_nameserver=$(echo $dns_nameserver | sed 's/|/\,\ /')
dns_nameserver=$(echo $dns_nameserver | sed 's/|/\,\ /g')
if [ -n "$dns_nameserver" ]; then
setconfig dns_nameserver \'$dns_nameserver\'
setconfig dns_nameserver \'"$dns_nameserver"\'
echo -e "\033[32m设置成功\033[0m"
fi
elif [ "$num" = 2 ]; then
read -p "请输入新的DNS > " dns_fallback
dns_fallback=$(echo $dns_fallback | sed 's/|/\,\ /')
dns_fallback=$(echo $dns_fallback | sed 's/|/\,\ /g')
if [ -n "$dns_fallback" ]; then
setconfig dns_fallback \'$dns_fallback\'
setconfig dns_fallback \'"$dns_fallback"\'
echo -e "\033[32m设置成功\033[0m"
fi
elif [ "$num" = 3 ]; then
@@ -290,21 +290,30 @@ checkport(){
}
macfilter(){
add_mac(){
echo -----------------------------------------------
echo 已添加的mac地址
cat $clashdir/mac
echo -----------------------------------------------
echo -e "\033[33m序号 设备IP 设备mac地址 设备名称\033[32m"
cat $dhcpdir | awk '{print " "NR" "$3,$2,$4}'
echo -e "\033[0m 0-----------------------------------------------"
echo -e "\033[0m-----------------------------------------------"
echo -e "手动输入mac地址时仅支持\033[32mxx:xx:xx:xx:xx:xx\033[0m的形式"
echo -e " 0 或回车 结束添加"
read -p "请输入需要添加的设备的对应序号 > " num
if [ -z "$num" ]||[ "$num" -le 0 ]; then
echo -----------------------------------------------
read -p "请输入对应序号或直接输入mac地址 > " num
if [ -z "$num" -o "$num" = 0 ]; then
macfilter
elif [ $num -le $(cat $dhcpdir | awk 'END{print NR}') ]; then
elif [ -n "$(echo $num | grep -E '^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$')" ];then
if [ -z "$(cat $clashdir/mac | grep -E "$num")" ];then
echo $num | grep -oE '^([0-9A-Fa-f]{2}[:]){5}([0-9A-Fa-f]{2})$' >> $clashdir/mac
else
echo -----------------------------------------------
echo -e "\033[31m已添加的设备请勿重复添加\033[0m"
fi
elif [ $num -le $(cat $dhcpdir | awk 'END{print NR}') 2>/dev/null ]; then
macadd=$(cat $dhcpdir | awk '{print $2}' | sed -n "$num"p)
if [ -z "$(cat $clashdir/mac | grep -E "$macadd")" ];then
echo $macadd >> $clashdir/mac
echo -----------------------------------------------
echo 已添加的mac地址
cat $clashdir/mac
else
echo -----------------------------------------------
echo -e "\033[31m已添加的设备请勿重复添加\033[0m"
@@ -324,7 +333,10 @@ macfilter(){
echo -e "\033[33m序号 设备IP 设备mac地址 设备名称\033[0m"
i=1
for mac in $(cat $clashdir/mac); do
echo -e " $i \033[32m$(cat $dhcpdir | awk '{print $3,$2,$4}' | grep $mac)\033[0m"
dev_ip=$(cat $dhcpdir | grep $mac | awk '{print $3}') && [ -z "$dev_ip" ] && dev_ip='000.000.00.00'
dev_mac=$(cat $dhcpdir | grep $mac | awk '{print $2}') && [ -z "$dev_mac" ] && dev_mac=$mac
dev_name=$(cat $dhcpdir | grep $mac | awk '{print $4}') && [ -z "$dev_name" ] && dev_name='未知设备'
echo -e " $i \033[32m$dev_ip \033[36m$dev_mac \033[32m$dev_name\033[0m"
i=$((i+1))
done
echo -----------------------------------------------
@@ -346,21 +358,27 @@ macfilter(){
[ -f /var/lib/dhcp/dhcpd.leases ] && dhcpdir='/var/lib/dhcp/dhcpd.leases'
[ -f /var/lib/dhcpd/dhcpd.leases ] && dhcpdir='/var/lib/dhcpd/dhcpd.leases'
[ -f /tmp/dhcp.leases ] && dhcpdir='/tmp/dhcp.leases'
[ -z "$macfilter_type" ] && macfilter_type='黑名单'
[ "$macfilter_type" = "黑名单" ] && macfilter_over='白名单' || macfilter_over='黑名单'
######
echo -e "\033[30;47m请在此添加或移除设备\033[0m"
echo -e "当前过滤方式为:\033[33m$macfilter_type模式\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 $dhcpdir | awk '{print $3,$2,$4}' | grep $mac
dev_ip=$(cat $dhcpdir | grep $mac | awk '{print $3}') && [ -z "$dev_ip" ] && dev_ip='000.000.00.00'
dev_mac=$(cat $dhcpdir | grep $mac | awk '{print $2}') && [ -z "$dev_mac" ] && dev_mac=$mac
dev_name=$(cat $dhcpdir | grep $mac | awk '{print $4}') && [ -z "$dev_name" ] && dev_name='未知设备'
echo -e "\033[32m$dev_ip \033[36m$dev_mac \033[32m$dev_name\033[0m"
done
echo -----------------------------------------------
fi
echo -e " 1 \033[31m清空整个列表\033[0m"
echo -e " 1 切换为\033[33m$macfilter_over模式\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 " 3 \033[36m移除指定设备\033[0m"
echo -e " 4 \033[31m清空整个列表\033[0m"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
@@ -369,20 +387,19 @@ macfilter(){
elif [ "$num" = 0 ]; then
clashcfg
elif [ "$num" = 1 ]; then
:>$clashdir/mac
macfilter_type=$macfilter_over
setconfig macfilter_type $macfilter_type
echo -----------------------------------------------
echo -e "\033[31m设备列表已清空\033[0m"
echo -e "\033[31m已切换为$macfilter_type模式\033[0m"
macfilter
elif [ "$num" = 2 ]; then
add_mac
elif [ "$num" = 3 ]; then
del_mac
elif [ "$num" = 4 ]; then
echo -----------------------------------------------
cat $dhcpdir | awk '{print $2}' > $clashdir/mac
echo -e "\033[32m已经将所有设备全部添加进过滤列表\033[0m"
echo -e "\033[33m请搭配【移除指定设备】功能使用\033[0m"
sleep 1
elif [ "$num" = 4 ]; then
:>$clashdir/mac
echo -----------------------------------------------
echo -e "\033[31m设备列表已清空\033[0m"
macfilter
else
errornum
@@ -486,9 +503,14 @@ clashcfg(){
modinfo tun >/dev/null 2>&1
if [ "$?" != 0 ];then
echo -----------------------------------------------
echo -e "\033[31m当前设备内核不支持开启Tun/混合模式,请使用其他模式\033[0m"
sleep 1
set_redir_mod
echo -e "\033[31m当前设备内核可能不支持开启Tun/混合模式!\033[0m"
read -p "是否强制开启?可能无法正常使用!(1/0) > " res
if [ "$res" = 1 ];then
redir_mod=Tun模式
dns_mod=fake-ip
else
set_redir_mod
fi
elif [ "$clashcore" = "clash" ] || [ "$clashcore" = "clashr" ];then
echo -----------------------------------------------
echo -e "\033[31m当前核心不支持开启Tun模式请先切换clash核心\033[0m"
@@ -501,10 +523,13 @@ clashcfg(){
elif [ "$num" = 3 ]; then
modinfo tun >/dev/null 2>&1
if [ "$?" != 0 ];then
echo -----------------------------------------------
echo -e "\033[31m当前设备内核不支持开启Tun/混合模式,请使用其他模式!\033[0m"
sleep 1
set_redir_mod
echo -e "\033[31m当前设备内核可能不支持开启Tun/混合模式!\033[0m"
read -p "是否强制开启?可能无法正常使用!(1/0) > " res
if [ "$res" = 1 ];then
redir_mod=混合模式
else
set_redir_mod
fi
elif [ "$clashcore" = "clash" ] || [ "$clashcore" = "clashr" ];then
echo -----------------------------------------------
echo -e "\033[31m当前核心不支持开启Tun模式请先切换clash核心\033[0m"
@@ -575,9 +600,8 @@ clashcfg(){
echo -e " 2 切换DNS运行模式 \033[36m$dns_mod\033[0m"
echo -e " 3 跳过本地证书验证: \033[36m$skip_cert\033[0m ————解决节点证书验证错误"
echo -e " 4 只代理常用端口: \033[36m$common_ports\033[0m ————用于屏蔽P2P流量"
echo -e " 5 过滤局域网mac地址 \033[36m$mac_return\033[0m ————列表内设备不走代理"
echo -e " 6 不使用本地DNS服务 \033[36m$dns_over\033[0m ————防止redir-host模式的dns污染"
echo -e " 7 设置本机代理服务: \033[36m$local_proxy\033[0m ————使用环境变量或GUI/api配置本机代理"
echo -e " 5 过滤局域网mac地址 \033[36m$mac_return\033[0m ————当前为$macfilter_type模式"
echo -e " 6 设置本机代理服务: \033[36m$local_proxy\033[0m ————使用环境变量或GUI/api配置本机代理"
echo -----------------------------------------------
echo -e " 9 \033[32m重启\033[0mclash服务"
echo -e " 0 返回上级菜单 \033[0m"
@@ -630,21 +654,6 @@ clashcfg(){
macfilter
elif [ "$num" = 6 ]; then
echo -----------------------------------------------
if [ "$dns_over" = "未开启" ] > /dev/null 2>&1; then
echo -e "\033[33m已设置DNS为不走本地dnsmasq服务器\033[0m"
echo -e "可能会对浏览速度产生一定影响,介意勿用!"
dns_over=已开启
else
/etc/init.d/clash enable
echo -e "\033[32m已设置DNS通过本地dnsmasq服务器\033[0m"
echo -e "redir-host模式下部分网站可能会被运营商dns污染导致无法打开"
dns_over=未开启
fi
setconfig dns_over $dns_over
clashcfg
elif [ "$num" = 7 ]; then
localproxy
sleep 1
clashcfg
@@ -670,13 +679,13 @@ clashadv(){
echo -e "\033[33m如您不是很了解clash的运行机制请勿更改\033[0m"
echo -e "\033[32m修改配置后请手动重启clash服务\033[0m"
echo -----------------------------------------------
echo -e " 1 使用自定义配置: \033[36m$modify_yaml\033[0m ————不使用内置规则修饰config.yaml"
echo -e " 1 使用保守方式启动: \033[36m$start_old\033[0m ————切换时会停止clash服务"
echo -e " 2 启用ipv6支持: \033[36m$ipv6_support\033[0m ————实验性功能,可能不稳定"
echo -e " 3 使用保守方式启动: \033[36m$start_old\033[0m ————切换时会停止clash服务"
echo -e " 4 Redir模式udp转发: \033[36m$tproxy_mod\033[0m ————依赖iptables-mod-tproxy"
echo -e " 5 启用小闪存模式: \033[36m$mini_clash\033[0m ————启动时方下载核心及数据库文件"
echo -e " 6 配置内置DNS服务: \033[36m$dns_no\033[0m"
echo -e " 7 手动指定clash运行端口及秘钥"
echo -e " 3 Redir模式udp转发: \033[36m$tproxy_mod\033[0m ————依赖iptables-mod-tproxy"
echo -e " 4 启用小闪存模式: \033[36m$mini_clash\033[0m ————启动时方下载核心及数据库文件"
echo -e " 5 配置内置DNS服务: \033[36m$dns_no\033[0m"
echo -e " 6 手动指定clash运行端口及秘钥"
echo -e " 7 使用自定义配置"
echo -----------------------------------------------
echo -e " 8 \033[31m重置\033[0m配置文件"
echo -e " 9 \033[32m重启\033[0mclash服务"
@@ -688,21 +697,6 @@ clashadv(){
clashsh
elif [ "$num" = 0 ]; then
clashsh
elif [ "$num" = 1 ]; then
echo -----------------------------------------------
if [ "$modify_yaml" = "未开启" ] > /dev/null 2>&1; then
echo -e "\033[33m已设为使用用户完全自定义的配置文件"
echo -e "\033[36m不明白原理的用户切勿随意开启此选项"
echo -e "\033[31m必然会导致上不了网!\033[0m"
modify_yaml=已开启
sleep 3
else
echo -e "\033[32m已设为使用脚本内置规则管理config.yaml配置文件\033[0m"
modify_yaml=未开启
fi
setconfig modify_yaml $modify_yaml
clashadv
elif [ "$num" = 2 ]; then
echo -----------------------------------------------
@@ -718,7 +712,7 @@ clashadv(){
setconfig ipv6_support $ipv6_support
clashadv
elif [ "$num" = 3 ]; then
elif [ "$num" = 1 ]; then
echo -----------------------------------------------
if [ "$start_old" = "未开启" ] > /dev/null 2>&1; then
echo -e "\033[33m改为使用保守方式启动clash服务\033[0m"
@@ -740,7 +734,7 @@ clashadv(){
fi
clashadv
elif [ "$num" = 4 ]; then
elif [ "$num" = 3 ]; then
echo -----------------------------------------------
if [ "$tproxy_mod" = "未开启" ]; then
if [ -n "$(iptables -j TPROXY 2>&1 | grep 'on-port')" ];then
@@ -758,7 +752,7 @@ clashadv(){
sleep 1
clashadv
elif [ "$num" = 5 ]; then
elif [ "$num" = 4 ]; then
echo -----------------------------------------------
dir_size=$(df $clashdir | awk '{print $4}' | sed 1d)
if [ "$mini_clash" = "未开启" ]; then
@@ -785,14 +779,42 @@ clashadv(){
sleep 1
clashadv
elif [ "$num" = 6 ]; then
elif [ "$num" = 5 ]; then
setdns
clashadv
elif [ "$num" = 7 ]; then
elif [ "$num" = 6 ]; then
setport
clashadv
elif [ "$num" = 7 ]; then
[ ! -f $clashdir/user.yaml ] && cat > $clashdir/user.yaml <<EOF
#用于编写自定义设定(可参考https://lancellc.gitbook.io/clash),例如
#port: 7890
#hosts:
# '*.clash.dev': 127.0.0.1
# 'alpha.clash.dev': ::1
EOF
[ ! -f $clashdir/rules.yaml ] && cat > $clashdir/rules.yaml <<EOF
#用于编写自定义规则(此处规则将优先生效)(可参考https://lancellc.gitbook.io/clash/clash-config-file/rules)
#例如“🚀 节点选择”、“🎯 全球直连”这样的自定义规则组必须与config.yaml中的代理规则组相匹配否则将无法运行
# - DOMAIN-SUFFIX,google.com,🚀 节点选择
# - DOMAIN-KEYWORD,baidu,🎯 全球直连
# - DOMAIN,ad.com,REJECT
# - SRC-IP-CIDR,192.168.1.201/32,DIRECT
# - IP-CIDR,127.0.0.0/8,DIRECT
# - IP-CIDR6,2620:0:2d0:200::7/32,🚀 节点选择
# - DST-PORT,80,DIRECT
# - SRC-PORT,7777,DIRECT
EOF
echo -e "\033[32m已经启用自定义配置功能\033[0m"
echo -e "Shell下(部分旧设备可能不显示中文)可\n使用【\033[36mvi $clashdir/user.yaml\033[0m】编辑自定义设定文件;\n使用【\033[36mvi $clashdir/rules.yaml\033[0m】编辑自定义规则文件。"
echo -e "Windows下请\n使用\033[33mwinscp软件\033[0m进入$clashdir目录后手动编辑\033[0m"
echo -e "其他设备请\n使用\033[32mscp命令\033[0m下载文件编辑后上传到$clashdir目录\033[0m"
echo -e "如需自定义节点可以在config.yaml文件中修改或者直接替换config.yaml文件\033[0m"
sleep 3
clashadv
elif [ "$num" = 8 ]; then
read -p "确认重置配置文件?(1/0) > " res
if [ "$res" = "1" ];then

View File

@@ -2,7 +2,7 @@
# Copyright (C) Juewuy
webget(){
[ -n "$(pidof clash)" ] && export all_proxy="http://127.0.0.1:$mix_port" #设置临时http代理
[ -n "$(pidof clash)" ] && export all_proxy="http://$authentication@127.0.0.1:$mix_port" #设置临时http代理
#参数【$1】代表下载目录【$2】代表在线地址
#参数【$3】代表输出显示【$4】不启用重定向
if curl --version > /dev/null 2>&1;then
@@ -679,6 +679,7 @@ setserver(){
echo -e " 3 Github源(test版本需开启clash服务)"
echo -e " 4 Gitee源(release版本可能滞后)"
echo -e " 5 自定义输入(请务必确保路径正确)"
echo -e " 6 切换版本(仅支持切换至release分支)"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
@@ -700,6 +701,24 @@ setserver(){
echo -e "\033[31m取消输入返回上级菜单\033[0m"
update
fi
elif [ "$num" = 6 ]; then
echo -----------------------------------------------
webget /tmp/clashrelease https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master/bin/release_version echooff rediroff 2>/tmp/clashrelease
echo -e "\033[32m请选择想要更新至的版本\033[0m"
cat /tmp/clashrelease | awk '{print " "NR" "$1}'
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" -o "$num" = 0 ]; then
setserver
elif [ $num -le $(cat /tmp/clashrelease | awk 'END{print NR}') 2>/dev/null ]; then
release_version=$(cat /tmp/clashrelease | awk '{print $1}' | sed -n "$num"p)
update_url="https://cdn.jsdelivr.net/gh/juewuy/ShellClash@$release_version"
echo -e "\033[32m设置成功\033[0m"
else
echo -----------------------------------------------
echo -e "\033[31m输入有误请重新输入\033[0m"
fi
elif [ "$num" = 9 ]; then
update_url='http://192.168.31.30:8080/clash-for-Miwifi'
else
@@ -716,13 +735,13 @@ setserver(){
checkupdate(){
if [ -z "$release_new" ];then
if [ "$update_url" = "https://cdn.jsdelivr.net/gh/juewuy/ShellClash" ];then
webget /tmp/clashrelease https://github.com.cnpmjs.org/juewuy/ShellClash/releases/latest echoon rediroff 2>/tmp/clashrelease
release_new=$( cat /tmp/clashrelease | grep -aoE "releases/tag/.*" | awk -F '[/" ]' '{print $3}')
webget /tmp/clashrelease $update_url@master/bin/release_version echoon rediroff 2>/tmp/clashrelease
release_new=$(cat /tmp/clashrelease | head -1)
[ -z "$release_new" ] && release_new=master
update_url=$update_url@$release_new
fi
webget /tmp/clashversion $update_url/bin/version echooff
[ "$result" = "200" ] && source /tmp/clashversion || echo -e "\033[31m检查更新失败\033[0m"
[ "$result" = "200" ] && source /tmp/clashversion || echo -e "\033[31m检查更新失败请检查网络连接或更换安装源!\033[0m"
[ -z "$release_new" ] && release_new=$versionsh
rm -rf /tmp/clashversion
rm -rf /tmp/clashrelease
@@ -936,6 +955,12 @@ testcommand(){
iptables -t nat -L clash --line-numbers
echo -----------------------------------------------
iptables -t nat -L clash_dns --line-numbers
echo -----------------------------------------------
ip6tables -t nat -L PREROUTING --line-numbers
echo -----------------------------------------------
ip6tables -t nat -L clashv6 --line-numbers
echo -----------------------------------------------
ip6tables -t nat -L clashv6_dns --line-numbers
exit;
elif [ "$num" = 5 ]; then
echo -----------------------------------------------

View File

@@ -27,7 +27,7 @@ getconfig(){
[ -z "$dns_nameserver" ] && dns_nameserver='114.114.114.114, 223.5.5.5'
[ -z "$dns_fallback" ] && dns_fallback='1.0.0.1, 8.8.4.4'
#是否代理常用端口
[ "$common_ports" = "已开启" ] && ports='-m multiport --dports 53,587,465,995,993,143,80,443 '
[ "$common_ports" = "已开启" ] && ports='-m multiport --dports 53,587,465,995,993,143,80,443'
}
setconfig(){
#参数1代表变量名参数2代表变量值,参数3即文件路径
@@ -35,8 +35,15 @@ setconfig(){
sed -i "/${1}*/"d $configpath
echo "${1}=${2}" >> $configpath
}
compare(){
if command -v cmp >/dev/null 2>&1; then
cmp -s $1 $2
else
[ "$(cat $1)" = "$(cat $2)" ] && return 0 || return 1
fi
}
webget(){
[ -n "$(pidof clash)" ] && export all_proxy="http://127.0.0.1:$mix_port" #设置临时http代理
[ -n "$(pidof clash)" ] && export all_proxy="http://$authentication@127.0.0.1:$mix_port" #设置临时http代理
#参数【$1】代表下载目录【$2】代表在线地址
#参数【$3】代表输出显示【$4】不启用重定向
if curl --version > /dev/null 2>&1;then
@@ -169,7 +176,7 @@ EOF`
fi
#如果不同则备份并替换文件
if [ -f $yaml ];then
cmp -s $yamlnew $yaml
compare $yamlnew $yaml
[ "$?" = 0 ] && rm -f $yamlnew || mv -f $yaml $yaml.bak && mv -f $yamlnew $yaml
else
mv -f $yamlnew $yaml
@@ -203,13 +210,11 @@ modify_yaml(){
[ "$redir_mod" != "Redir模式" ] && tun='tun: {enable: true, stack: system}' || tun='tun: {enable: false}'
exper='experimental: {ignore-resolve-fail: true, interface-name: en0}'
#dns配置
[ "$dns_over" = "未开启" ] && dns_local=', 127.0.0.1:53'
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: ['$dns_nameserver', 127.0.0.1:53], fallback: ['$dns_fallback'], fallback-filter: {geoip: true}}'
else
dns='dns: {enable: true, ipv6: true, listen: 0.0.0.0:'$dns_port', use-hosts: true, enhanced-mode: redir-host, nameserver: ['$dns_nameserver$dns_local'], fallback: ['$dns_fallback'], fallback-filter: {geoip: true}}'
fi
###################################
#设置目录
yaml=$clashdir/config.yaml
tmpdir=/tmp/clash_$USER
@@ -218,10 +223,11 @@ modify_yaml(){
b=$(grep -n "^prox" $yaml | head -1 | cut -d ":" -f 1)
b=$((b-1))
mkdir -p $tmpdir > /dev/null
sed "${a},${b}d" $yaml > $tmpdir/rule.yaml
sed "${a},${b}d" $yaml > $tmpdir/proxy.yaml
#跳过本地tls证书验证
[ "$skip_cert" = "已开启" ] && sed -i '10,99s/skip-cert-verify: false/skip-cert-verify: true/' $tmpdir/rule.yaml
[ "$skip_cert" = "已开启" ] && sed -i '10,99s/skip-cert-verify: false/skip-cert-verify: true/' $tmpdir/proxy.yaml
#添加配置
###################################
cat > $tmpdir/set.yaml <<EOF
mixed-port: $mix_port
redir-port: $redir_port
@@ -237,13 +243,26 @@ $tun
$exper
$dns
EOF
cat $tmpdir/set.yaml $tmpdir/rule.yaml > $tmpdir/config.yaml
if [ "$tmpdir" != "$bindir" ];then #如果没有使用小闪存模式
cmp -s $tmpdir/config.yaml $yaml
###################################
[ -f $clashdir/user.yaml ] && yaml_user=$clashdir/user.yaml
#合并文件
cut -c 1- $tmpdir/set.yaml $yaml_user $tmpdir/proxy.yaml > $tmpdir/config.yaml
#插入自定义规则
if [ -f $clashdir/rules.yaml ];then
while read line;do
[ -z "$(echo "$line" | grep '#')" ] && \
[ -n "$(echo "$line" | grep '\-\ ')" ] && \
sed -i "/$line/d" $tmpdir/config.yaml && \
sed -i "/^rules:/a\ $line" $tmpdir/config.yaml
done < $clashdir/rules.yaml
fi
#如果没有使用小闪存模式
if [ "$tmpdir" != "$bindir" ];then
compare $tmpdir/config.yaml $yaml
[ "$?" != 0 ] && mv -f $tmpdir/config.yaml $yaml || rm -f $tmpdir/config.yaml
fi
rm -f $tmpdir/set.yaml
rm -f $tmpdir/rule.yaml
rm -f $tmpdir/proxy.yaml
}
#设置路由规则
start_redir(){
@@ -257,19 +276,35 @@ start_redir(){
iptables -t nat -A clash -d 192.168.0.0/16 -j RETURN
iptables -t nat -A clash -d 224.0.0.0/4 -j RETURN
iptables -t nat -A clash -d 240.0.0.0/4 -j RETURN
for mac in $(cat $clashdir/mac); do
iptables -t nat -A clash -m mac --mac-source $mac -j RETURN
done
#设置防火墙流量转发
iptables -t nat -A clash -p tcp $ports-j REDIRECT --to-ports $redir_port
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
#mac白名单
for mac in $(cat $clashdir/mac); do
iptables -t nat -A clash -p tcp $ports -m mac --mac-source $mac -j REDIRECT --to-ports $redir_port
done
else
#mac黑名单
for mac in $(cat $clashdir/mac); do
iptables -t nat -A clash -m mac --mac-source $mac -j RETURN
done
iptables -t nat -A clash -p tcp $ports -j REDIRECT --to-ports $redir_port
fi
iptables -t nat -A PREROUTING -p tcp -j clash
#设置ipv6转发
if [ -n "ip6_nat" -a "$ipv6_support" = "已开启" ];then
ip6_nat=$(ip6tables -t nat -L 2>&1 | grep -o 'Chain')
if [ -n "$ip6_nat" -a "$ipv6_support" = "已开启" ];then
ip6tables -t nat -N clashv6
for mac in $(cat $clashdir/mac); do
ip6tables -t nat -A clashv6 -m mac --mac-source $mac -j RETURN
done
ip6tables -t nat -A clashv6 -p tcp $ports-j REDIRECT --to-ports $redir_port
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
#mac白名单
for mac in $(cat $clashdir/mac); do
ip6tables -t nat -A clashv6 -p tcp $ports -m mac --mac-source $mac -j REDIRECT --to-ports $redir_port
done
else
#mac黑名单
for mac in $(cat $clashdir/mac); do
ip6tables -t nat -A clashv6 -m mac --mac-source $mac -j RETURN
done
ip6tables -t nat -A clashv6 -p tcp $ports -j REDIRECT --to-ports $redir_port
fi
ip6tables -t nat -A PREROUTING -p tcp -j clashv6
fi
}
@@ -281,27 +316,46 @@ start_dns(){
fi
#设置dns转发
iptables -t nat -N clash_dns
for mac in $(cat $clashdir/mac); do
iptables -t nat -A clash_dns -m mac --mac-source $mac -j RETURN
done
iptables -t nat -A clash_dns -p udp --dport 53 -j REDIRECT --to $dns_port
iptables -t nat -A clash_dns -p tcp --dport 53 -j REDIRECT --to $dns_port
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
#mac白名单
for mac in $(cat $clashdir/mac); do
iptables -t nat -A clash_dns -p udp --dport 53 -m mac --mac-source $mac -j REDIRECT --to $dns_port
iptables -t nat -A clash_dns -p tcp --dport 53 -m mac --mac-source $mac -j REDIRECT --to $dns_port
done
else
#mac黑名单
for mac in $(cat $clashdir/mac); do
iptables -t nat -A clash_dns -m mac --mac-source $mac -j RETURN
done
iptables -t nat -A clash_dns -p udp --dport 53 -j REDIRECT --to $dns_port
iptables -t nat -A clash_dns -p tcp --dport 53 -j REDIRECT --to $dns_port
fi
iptables -t nat -A PREROUTING -p udp -j clash_dns
#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.4.4 -j clash_dns
#ipv6DNS
ip6_nat=$(ip6tables -t nat -L 2>&1|grep -o 'Chain')
if [ -n "ip6_nat" ];then
ip6_nat=$(ip6tables -t nat -L 2>&1 | grep -o 'Chain')
if [ -n "$ip6_nat" ];then
ip6tables -t nat -N clashv6_dns > /dev/null 2>&1
for mac in $(cat $clashdir/mac); do
ip6tables -t nat -A clashv6_dns -m mac --mac-source $mac -j RETURN > /dev/null 2>&1
done
ip6tables -t nat -A clashv6_dns -p udp --dport 53 -j REDIRECT --to $dns_port > /dev/null 2>&1
ip6tables -t nat -A PREROUTING -p udp -j clashv6_dns > /dev/null 2>&1
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
#mac白名单
for mac in $(cat $clashdir/mac); do
ip6tables -t nat -A clashv6_dns -p udp --dport 53 -m mac --mac-source $mac -j REDIRECT --to $dns_port
ip6tables -t nat -A clashv6_dns -p tcp --dport 53 -m mac --mac-source $mac -j REDIRECT --to $dns_port
done
else
#mac黑名单
for mac in $(cat $clashdir/mac); do
ip6tables -t nat -A clashv6_dns -m mac --mac-source $mac -j RETURN
done
ip6tables -t nat -A clashv6_dns -p udp --dport 53 -j REDIRECT --to $dns_port
ip6tables -t nat -A clashv6_dns -p tcp --dport 53 -j REDIRECT --to $dns_port
fi
ip6tables -t nat -A PREROUTING -p udp -j clashv6_dns
else
ip6tables -I INPUT -p tcp --dport 53 -j REJECT
ip6tables -I INPUT -p udp --dport 53 -j REJECT
ip6tables -I INPUT -p tcp --dport 53 -j REJECT > /dev/null 2>&1
ip6tables -I INPUT -p udp --dport 53 -j REJECT > /dev/null 2>&1
fi
}
start_udp(){
@@ -316,7 +370,18 @@ start_udp(){
iptables -t mangle -A clash -d 192.168.0.0/16 -j RETURN
iptables -t mangle -A clash -d 224.0.0.0/4 -j RETURN
iptables -t mangle -A clash -d 240.0.0.0/4 -j RETURN
iptables -t mangle -A clash -p udp -j TPROXY --on-port $redir_port --tproxy-mark 1
if [ "$macfilter_type" = "白名单" -a -n "$(cat $clashdir/mac)" ];then
#mac白名单
for mac in $(cat $clashdir/mac); do
iptables -t mangle -A clash -p udp -m mac --mac-source $mac -j TPROXY --on-port $redir_port --tproxy-mark 1
done
else
#mac黑名单
for mac in $(cat $clashdir/mac); do
iptables -t mangle -A clash -m mac --mac-source $mac -j RETURN
done
iptables -t mangle -A clash -p udp -j TPROXY --on-port $redir_port --tproxy-mark 1
fi
iptables -t mangle -A PREROUTING -p udp -j clash
}
stop_iptables(){
@@ -358,8 +423,8 @@ web_save(){
}
#使用get_save获取面板节点设置
get_save http://localhost:${db_port}/proxies | awk -F "{" '{for(i=1;i<=NF;i++) print $i}' | grep -E '^"all".*"Selector"' | grep -oE '"name".*"now".*",' | sed 's/"name"://g' | sed 's/"now"://g'| sed 's/"//g' > /tmp/clash_web_save_$USER
#对比文件,如果有变动则写入磁盘,否则清除缓存
cmp -s /tmp/clash_web_save_$USER $clashdir/web_save
#对比文件,如果有变动且不为空则写入磁盘,否则清除缓存
[ ! -s /tmp/clash_web_save_$USER ] && compare /tmp/clash_web_save_$USER $clashdir/web_save
[ "$?" = 0 ] && rm -rf /tmp/clash_web_save_$USER || mv -f /tmp/clash_web_save_$USER $clashdir/web_save
}
web_restore(){
@@ -390,7 +455,6 @@ web_restore(){
now_name=$(awk -F ',' 'NR=="'${i}'" {print $2}' $clashdir/web_save)
put_save http://localhost:${db_port}/proxies/${group_name} "{\"name\":\"${now_name}\"}"
done
exit 0
}
#启动相关
catpac(){
@@ -414,10 +478,12 @@ function FindProxyForURL(url, host) {
return "SOCKS5 $host:$mix_port; PROXY $host:$mix_port; DIRECT;"
}
EOF
cmp -s /tmp/clash_pac $bindir/ui/pac
compare /tmp/clash_pac $bindir/ui/pac
[ "$?" = 0 ] && rm -rf /tmp/clash_pac || mv -f /tmp/clash_pac $bindir/ui/pac
}
bfstart(){
#读取配置文件
getconfig
[ ! -d $bindir/ui ] && mkdir -p $bindir/ui
[ -z "$update_url" ] && update_url=https://cdn.jsdelivr.net/gh/juewuy/ShellClash@master
#检查clash核心
@@ -426,7 +492,7 @@ bfstart(){
mv $clashdir/clash $bindir/clash && chmod 777 $bindir/clash
else
logger "未找到clash核心正在下载" 33
[ -z "$clashcore" ] && clashcore=clash
[ -z "$clashcore" ] && [ "$redir_mod" = "混合模式" -o "$redir_mod" = "Tun模式" ] && clashcore=clashpre || clashcore=clash
[ -z "$cpucore" ] && source $clashdir/getdate.sh && getcpucore
[ -z "$cpucore" ] && logger 找不到设备的CPU信息请手动指定处理器架构类型 31 && setcpucore
webget $bindir/clash "$update_url/bin/$clashcore/clash-linux-$cpucore"
@@ -484,16 +550,15 @@ afstart(){
else
logger "clash服务启动失败请查看报错信息" 31
logger `$bindir/clash -t -d $bindir 1>&0` 0
$0 stop &
$0 stop
exit 1
fi
exit 0
}
start_old(){
#使用传统后台执行二进制文件的方式执行
$bindir/clash -d $bindir >/dev/null &
afstart
daemon
$0 daemon
}
case "$1" in
@@ -509,6 +574,7 @@ start)
getconfig
#检测必须文件并下载
bfstart
stop_iptables #清理iptables
#使用内置规则强行覆盖config配置文件
[ "$modify_yaml" != "已开启" ] && modify_yaml
#使用不同方式启动clash服务
@@ -524,7 +590,7 @@ start)
;;
stop)
getconfig
web_save #保存面板配置
[ -n "$(pidof clash)" ] && web_save #保存面板配置
#删除守护进程&面板配置自动保存
cronset "clash保守模式守护进程"
cronset "保存节点配置"