29 Commits

Author SHA1 Message Date
juewuy
235886c79c v0.9.4
~调整安装初始化流程
~优化下载更新流程
~修复下载更新相关bug
2020-08-15 11:17:24 +08:00
juewuy
454f885f38 移除 2020-08-15 10:55:23 +08:00
juewuy
5cabf6559e v0.9.4
~调整安装初始化流程
~优化下载更新流程
~修复下载更新相关bug
2020-08-15 10:51:12 +08:00
juewuy
be13387179 v0.9.3
~修复文件格式bug
2020-08-14 23:04:34 +08:00
juewuy
2aaeb8c12f Merge branch 'master' of https://github.com/juewuy/clash-for-Miwifi 2020-08-14 22:26:38 +08:00
juewuy
c7e6f4a079 v0.9.2
~添加局域网设备过滤功能
~修复本地版本号不正常的bug
~修复规则偶尔显示为0的bug
2020-08-14 22:26:24 +08:00
juewuy
161e1c7602 Update README.md 2020-08-14 21:43:40 +08:00
juewuy
233dd75a67 Update README.md 2020-08-14 21:43:23 +08:00
juewuy
ab272e3a7c v0.9.2
~添加局域网设备过滤功能
~修复本地版本号不正常的bug
~修复规则偶尔显示为0的bug
2020-08-14 21:39:41 +08:00
juewuy
6d0162f65f v0.9.2
~添加局域网设备过滤功能
~修复本地版本号不正常的bug
~修复规则偶尔显示为0的bug
2020-08-14 21:38:51 +08:00
juewuy
a8f128106a v0.9.2
~添加局域网设备过滤功能
~修复本地版本号不正常的bug
~修复规则偶尔显示为0的bug
2020-08-14 21:36:44 +08:00
juewuy
85de9d0bbd v0.9.2
~添加局域网设备过滤功能
~修复本地版本号不正常的bug
2020-08-14 21:31:06 +08:00
juewuy
d2d19e01ae v0.9.2
~添加局域网设备过滤功能
2020-08-14 21:26:16 +08:00
juewuy
ad34cda6e9 v0.9.2
~添加局域网设备过滤功能
2020-08-14 20:55:15 +08:00
juewuy
691964fe3b v0.9.1
~新增更多设备支持,理论上支持小米全系路由器设备(待测试)
~增加了对设备核心架构的自动检测,适配armv5,armv7,armv8(aarch64),mipsle及x86平台
~增加了一部分acl规则模版
~修复了几处偶尔报错的小bug
2020-08-14 17:26:19 +08:00
juewuy
93f7ceb3c8 Update README.md 2020-08-14 16:46:45 +08:00
juewuy
e4aa9d702d v0.9.1
~新增更多设备支持,理论上支持小米全系路由器设备(待测试)
~增加了对设备核心架构的自动检测,适配armv5,armv7,armv8(aarch64),mipsle及x86平台
~增加了一部分acl规则模版
~修复了几处偶尔报错的小bug
2020-08-14 16:42:52 +08:00
juewuy
724968474f 增加其他核心版本支持 2020-08-14 15:26:30 +08:00
juewuy
b5561d5e20 修复安装时出现奇怪报错的bug 2020-08-14 15:22:24 +08:00
juewuy
f09a7a7599 v0.9.0
~新增定时任务功能(实验性,欢迎测试)
~修复测试命令时一个报错的小bug
~安装本地面板增加自动挂载/www目录
2020-08-14 15:00:47 +08:00
juewuy
2a60440585 修复bug 2020-08-14 14:56:38 +08:00
juewuy
11e0231506 Merge branch 'master' of https://github.com/juewuy/clash-for-Miwifi 2020-08-13 23:02:16 +08:00
juewuy
0f58916149 v0.9.0
~新增定时任务功能(实验性,欢迎测试)
~修复测试命令时一个报错的小bug
~安装本地面板增加自动挂载/www目录
2020-08-13 23:02:02 +08:00
juewuy
74ba7e2fb7 Update README.md 2020-08-13 22:47:47 +08:00
juewuy
2dee375ac0 Update README.md 2020-08-13 22:46:47 +08:00
juewuy
a0cd5c1b1f Update README.md 2020-08-13 22:46:26 +08:00
juewuy
2ed3c33b24 修改安装源 2020-08-13 22:43:17 +08:00
juewuy
2026fe5adc v0.9.0
~新增定时任务功能(实验性,欢迎测试)
~修复测试命令时一个报错的小bug
2020-08-13 22:38:51 +08:00
juewuy
0e442ce5ad 增加定时任务功能 2020-08-13 19:15:43 +08:00
18 changed files with 354 additions and 184 deletions

View File

@@ -4,7 +4,7 @@
功能简介:
--
~支持小米AX系列路由器设备使用clash做透明代理更多的设备支持可以前往TG群报名参与测试<br>
~支持小米系列路由器设备使用clash做透明代理更多的设备支持可以前往TG群报名参与测试<br>
~支持SS、SSR、v2ray、trojan、sock5等协议<br>
~支持批量导入节点链接及订阅链接<br>
~支持使用网页面板管理规则组<br>
@@ -14,6 +14,18 @@
更新日志:
--
* v0.9.2<br>
~添加局域网设备过滤功能<br>
~修复本地版本号不正常的bug<br>
~修复规则偶尔显示为0的bug<br>
* v0.9.1<br>
~新增更多设备支持,理论上支持小米全系路由器设备(待测试)<br>
~增加了对设备核心架构的自动检测适配armv5armv7armv8aarch64mipsle及x86平台<br>
~增加了一部分acl规则模版<br>
~修复了几处偶尔报错的小bug<br>
* v0.9.0<br>
~新增定时任务功能(实验性,欢迎测试)<br>
~修复测试命令时一个报错的小bug<br>
* v0.8.7<br>
~修复了脚本更新路径不正确的bug<br>
~调整了geoip数据库下载源地址<br>
@@ -61,7 +73,9 @@ ToDo
~~增加屏蔽P2P流量功能~~<br>
~~增加更新功能~~<br>
~~修复redir-host DNS以及IPV6支持~~<br>
~增加定时功能<br>
~~增加定时功能~~<br>
~~增加屏蔽局域网设备~~<br>
~~增加更多设备支持~~<br>
感谢:
--

BIN
bin/clash/clash-linux-386 Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1 +1 @@
version=1.0.0
version=20200813

BIN
bin/clashr/clash-linux-386 Normal file

Binary file not shown.

Binary file not shown.

View File

@@ -1 +1 @@
versionsh=0.8.7
versionsh=0.9.4

View File

@@ -59,14 +59,13 @@ fi
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始解压文件!
mkdir -p $dir/clash > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/ > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
#初始化文件目录
mv $dir/clash/clashservice /etc/init.d/clash #将clash服务文件移动到系统目录
chmod 777 $dir/clash/clash #授予权限
chmod 777 /etc/init.d/clash #授予权限
if [ ! -f "$dir/clash/mark" ]; then
cat >$ccfg<<EOF
cat >$dir/clash/mark<<EOF
#标识clash运行状态的文件不明勿动
EOF
fi

View File

@@ -1,87 +0,0 @@
#!/bin/sh
# Copyright (C) Juewuy
echo "***********************************************"
echo "** 欢迎使用 **"
echo "** Clash for Miwifi **"
echo "** by Juewuy **"
echo "***********************************************"
url="https://juewuy.xyz/clash/"
result=$(curl -w %{http_code} -skLo /tmp/clashversion $url/bin/version)
[ "$result" != "200" ] && echo "无法连接到服务器!" && exit 1
source /tmp/clashversion
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "~~~~版本:\033[32m$versionsh\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[44m使用中如遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -e "\033[37m目前仅支持小米AX系列3款路由器"
echo -e "\033[44m其余型号可到TG群报名参与测试\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32m 1 在默认目录(/etc)安装Clash for Miwifi"
echo -e "\033[33m 2 手动设置安装目录(不明勿用!)"
echo -e "\033[0m 0 退出安装"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
read -p "请输入相应数字 > " num
if [ -z $num ];then
echo 安装已取消
exit;
elif [[ $num == 1 ]];then
dir=/etc
elif [[ $num == 2 ]];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo '可用路径 剩余空间:'
df -h | awk '{print $6,$2}'| sed 1d
echo '路径是必须带 / 的格式,写入虚拟内存(/tmp,/sys,..)的文件会在重启后消失!!!'
read -p "请输入自定义路径 > " dir
if [ -z $dir ];then
echo 路径错误!已取消安装!
exit;
fi
else
echo 安装已取消
exit;
fi
#下载文件包
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始从服务器获取安装文件!
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
tarurl=$url/bin/clashfm.tar.gz
if command -v curl &> /dev/null; then
result=$(curl -w %{http_code} -kLo /tmp/clashfm.tar.gz $tarurl)
else $result
wget-ssl -q --no-check-certificate --tries=1 --timeout=10 -O /tmp/clashfm.tar.gz $tarurl
[ $? -eq 0 ] && result="200"
fi
[ "$result" != "200" ] && echo "文件下载失败!" && exit 1
#解压
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 开始解压文件!
mkdir -p $dir/clash > /dev/null
tar -zxvf '/tmp/clashfm.tar.gz' -C $dir/clash/ > /dev/null
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
#初始化文件目录
mv $dir/clash/clashservice /etc/init.d/clash #将clash服务文件移动到系统目录
chmod 777 $dir/clash/clash #授予权限
chmod 777 /etc/init.d/clash #授予权限
if [ ! -f "$dir/clash/mark" ]; then
cat >$ccfg<<EOF
#标识clash运行状态的文件不明勿动
EOF
fi
sed -i '/versionsh_l=*/'d $dir/clash/mark
sed -i "1i\versionsh_l=$versionsh" $dir/clash/mark
#设置环境变量
sed -i '/alias clash=*/'d /etc/profile
echo "alias clash=\"sh $dir/clash/clash.sh\"" >> /etc/profile #设置快捷命令环境变量
sed -i '/export clashdir=*/'d /etc/profile
echo "export clashdir=\"$dir/clash\"" >> /etc/profile #设置clash路径环境变量
#删除临时文件
rm -rf /tmp/clashfm.tar.gz
#提示
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo clash for Miwifi 已经安装成功!
echo -e "\033[33m直接输入\033[30;47m clash \033[0;33m命令即可管理\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -2,14 +2,12 @@
# Copyright (C) Juewuy
getconfig(){
#版本号
versionsh_l=0.8.7
#服务器地址
if [ -z $update_url ]; then
update_url=https://cdn.jsdelivr.net/gh/juewuy/clash-for-Miwifi/
if [ -z "$update_url" ]; then
update_url=https://cdn.jsdelivr.net/gh/juewuy/clash-for-Miwifi@latest
fi
#文件路径
if [ -z $clashdir ];then
if [ -z "$clashdir" ];then
clashdir=$(dirname $(readlink -f "$0"))
echo "export clashdir=\"$clashdir\"" >> /etc/profile
fi
@@ -23,6 +21,8 @@ if [ ! -f "$ccfg" ]; then
EOF
fi
source $ccfg
#检查mac地址记录
[ ! -f "$clashdir/mac" ] && touch $clashdir/mac
#获取自启状态
if [ -f /etc/rc.d/*clash ]; then
auto="\033[32m已设置开机启动\033[0m"
@@ -32,7 +32,7 @@ else
auto1="\033[36m允许\033[0mclash开机启动"
fi
#获取运行模式
if [ ! -n "$redir_mod" ]; then
if [ -z "$redir_mod" ]; then
sed -i "2i\redir_mod=Redir模式" $ccfg
redir_mod=Redir模式
fi
@@ -79,34 +79,46 @@ if [ ! -f $clashdir/Country.mmdb ];then
echo -e "\033[31m没有找到GeoIP数据库文件请先下载数据库\033[0m"
source $clashdir/getdate.sh
getgeo
clashstart
fi
}
clashstart(){
/etc/init.d/clash start
sleep 1
status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
if [ ! -f "$yaml" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m没有找到配置文件请先导入节点/订阅链接!\033[0m"
clashlink
fi
if [ $status -gt 0 ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/etc/init.d/clash stop > /dev/null 2>&1
echo -e "\033[31mClash服务已停止\033[0m"
fi
/etc/init.d/clash start
sleep 1
status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
if [[ $status -gt 0 ]];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}';)
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32mclash服务已启动\033[0m"
echo -e "可以使用\033[30;47m http://clash.razord.top \033[0m管理内置规则"
echo -e "也可以前往更新菜单安装本地Dashboard面板连接更稳定"
echo -e "Host地址:\033[36m $host \033[0m 端口:\033[36m 9999 \033[0m"
echo -e "也可前往更新菜单安装本地Dashboard面板连接更稳定\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31mclash服务启动失败请检查配置文件\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fi
}
clashlink(){
#获取订阅规则
if [ ! -n "$rule_link" ]; then
if [ -z "$rule_link" ]; then
sed -i '/rule_link=*/'d $ccfg
sed -i "4i\rule_link=1" $ccfg
rule_link=1
fi
#获取后端服务器地址
if [ ! -n "$server_link" ]; then
if [ -z "$server_link" ]; then
sed -i '/server_link=*/'d $ccfg
sed -i "5i\server_link=1" $ccfg
server_link=1
@@ -120,10 +132,9 @@ echo -e " 3 选取\033[33m代理规则\033[0m模版"
echo -e " 4 选择配置生成服务器"
echo -e " 5 \033[36m还原\033[0m配置文件"
echo -e " 6 \033[32m手动更新\033[0m订阅"
echo -e " 7 设置自动更新(未完成)"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z $num ];then
if [ -z "$num" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashsh
@@ -167,21 +178,26 @@ elif [[ $num == 3 ]];then
echo 3 ACL4SSR通用版去广告加强
echo 4 ACL4SSR精简版去广告加强
echo 5 ACL4SSR通用版无去广告
echo 6 ACL4SSR通用版无自动测速
echo 7 ACL4SSR精简版无自动测速
echo 8 ACL4SSR超重度奈飞全量
echo 0 返回上级菜单
read -p "请输入对应数字 > " num
if [ -z $num ];then
if [ -z "$num" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashlink
else
#将对应标记值写入mark
sed -i '/rule_link*/'d $ccfg
sed -i "4i\rule_link="$num"" $ccfg
rule_link=$num
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32m设置成功返回上级菜单\033[0m"
clashlink
fi
elif [[ "$num" == 0 ]];then
clashlink
else
#将对应标记值写入mark
sed -i '/rule_link*/'d $ccfg
sed -i "4i\rule_link="$num"" $ccfg
rule_link=$num
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32m设置成功返回上级菜单\033[0m"
clashlink
fi
elif [[ $num == 4 ]];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
@@ -195,14 +211,13 @@ elif [[ $num == 4 ]];then
echo 7 subconvert.dreamcloud.pw
echo 0 返回上级菜单
read -p "请输入对应数字 > " num
if [ -z $num ];then
if [ -z "$num" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashlink
else
if [[ $num == 0 ]];then
elif [[ "$num" == 0 ]];then
clashlink
fi
else
#将对应标记值写入mark
sed -i '/server_link*/'d $ccfg
sed -i "4i\server_link="$num"" $ccfg
@@ -231,7 +246,7 @@ elif [[ $num == 5 ]];then
fi
clashsh
elif [[ $num == 6 ]];then
if [ ! -n "$Url" ];then
if [ -z "$Url" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo 没有找到你的订阅链接!请先输入链接!
clashlink
@@ -258,21 +273,26 @@ fi
}
clashadv(){
#获取设置默认显示
if [ ! -n "$skip_cert" ]; then
if [ -z "$skip_cert" ]; then
skip_cert=已开启
fi
if [ ! -n "$common_ports" ]; then
if [ -z "$common_ports" ]; then
common_ports=未开启
fi
if [ ! -n "$dns_mod" ]; then
if [ -z "$dns_mod" ]; then
dns_mod=redir_host
fi
if [ ! -n "$modify_yaml" ]; then
if [ -z "$modify_yaml" ]; then
modify_yaml=未开启
fi
if [ ! -n "$ipv6_support" ]; then
if [ -z "$ipv6_support" ]; then
ipv6_support=未开启
fi
if [ -z "$(cat $clashdir/mac)" ]; then
mac_return=未开启
else
mac_return=已启用
fi
#
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[30;47m欢迎使用高级模式菜单\033[0m"
@@ -284,6 +304,7 @@ echo -e " 3 跳过本地证书验证: \033[36m$skip_cert\033[0m ————
echo -e " 4 只代理常用端口: \033[36m$common_ports\033[0m ————用于屏蔽P2P流量"
echo -e " 5 不修饰config.yaml: \033[36m$modify_yaml\033[0m ————用于使用自定义配置"
echo -e " 6 启用ipv6支持: \033[36m$ipv6_support\033[0m ————实验性且不兼容Fake_ip"
echo -e " 7 过滤局域网mac地址 \033[36m$mac_return\033[0m ————列表内设备不走代理"
echo -e " 9 \033[32m重启\033[0mclash服务"
echo -e " 0 返回上级菜单 \033[0m"
read -p "请输入对应数字 > " num
@@ -307,7 +328,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
echo " 不推荐使用redir-host"
echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z $num ]; then
if [ -z "$num" ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashadv
@@ -354,7 +375,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
echo " 不支持Tun模式"
echo " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z $num ]; then
if [ -z "$num" ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashadv
@@ -440,7 +461,74 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
ipv6_support=未开启
fi
clashadv
elif [[ $num == 7 ]]; then
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
clashadv
elif [ $num -le 0 ]; then
clashadv
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"
clashadv
elif [[ $num == 0 ]]; then
clashadv
elif [[ $num == 1 ]]; then
:>$clashdir/mac
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m设备列表已清空\033[0m"
sleep 1
clashadv
elif [[ $num == 2 ]]; then
add_mac
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashadv
fi
clashadv
elif [[ $num == 9 ]]; then
if [ $status -gt 0 ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -490,6 +578,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
elif [[ $num == 3 ]]; then
source $clashdir/getdate.sh
getgeo
update
elif [[ $num == 4 ]]; then
source $clashdir/getdate.sh
@@ -525,6 +614,135 @@ else
fi
exit;
}
clashcron(){
setcron(){
echo -----------------------------------------------
echo -e " 正在设置:\033[32m$cronname\033[0m定时任务"
echo -e " 输入 1-7 对应\033[33m每周相应天\033[0m运行"
echo -e " 输入 8 设为\033[33m每天定时\033[0m运行"
echo -e " 输入 1,3,6 代表\033[36m每周1,3,6\033[0m运行(注意用小写逗号分隔)"
echo -e " 输入 9 \033[31m删除定时任务\033[0m"
echo -e " 输入 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashcron
elif [[ $num == 0 ]]; then
clashcron
elif [[ $num == 9 ]]; then
sed -i /$cronname/d $cronpath
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m定时任务$cronname已删除\033[0m"
clashcron
elif [[ $num == 8 ]]; then
week='*'
week1=每天
echo 已设为每天定时运行!
else
week=$num
week1=每周$week
echo 已设为每周 $num 运行!
fi
#设置具体时间
echo -----------------------------------------------
read -p "请输入小时0-23 > " num
if [ -z "$num" ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
setcron
elif [ $num -gt 23 ] || [ $num -lt 0 ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
setcron
else
hour=$num
fi
echo -----------------------------------------------
read -p "请输入分钟0-60 > " num
if [ -z "$num" ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
setcron
elif [ $num -gt 60 ] || [ $num -lt 0 ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
setcron
else
min=$num
fi
echo -----------------------------------------------
echo 将在$week1的$hour点$min分$cronname(旧的任务会被覆盖)
read -p "是否确认添加定时任务?(1/0) > " res
if [ "$res" = '1' ]; then
sed -i /$cronname/d $cronpath
echo "$min $hour * * $week $cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname" >> $cronpath
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m定时任务已添加\033[0m"
fi
clashcron
}
checkcron(){
if [ -d /etc/crontabs/ ]; then
cronpath="/etc/crontabs/root"
elif [ -d /var/spool/cron/ ]; then
cronpath="/var/spool/cron/root"
elif [ -d /var/spool/cron/crontabs/ ]; then
cronpath="/var/spool/cron/crontabs/root"
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo "找不到定时任务文件,无法添加定时任务!"
clashsh
fi
}
#定时任务菜单
checkcron #检测定时任务文件
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[30;47m欢迎使用定时任务功能\033[0m"
echo -e "\033[44m 实验性功能遇问题请加TG群反馈\033[42;30m t.me/clashfm \033[0m"
echo -----------------------------------------------
echo -e "\033[33m当前已经添加的定时任务有\033[36m"
crontab -l | egrep -o '#.*'
echo -e "\033[0m"-----------------------------------------------
echo -e " 1 设置\033[33m定时重启\033[0mclash服务"
echo -e " 2 设置\033[31m定时停止\033[0mclash服务"
echo -e " 3 设置\033[32m定时开启\033[0mclash服务"
echo -e " 4 设置\033[33m定时更新\033[0m订阅链接(实验性,可能不稳定)"
echo -e " 0 返回上级菜单"
read -p "请输入对应数字 > " num
if [ -z "$num" ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashsh
elif [[ $num == 0 ]]; then
clashsh
elif [[ $num == 1 ]]; then
cronname=重启clash服务
cronset='/etc/init.d/clash restart'
setcron
elif [[ $num == 2 ]]; then
cronname=停止clash服务
cronset='/etc/init.d/clash stop'
setcron
elif [[ $num == 3 ]]; then
cronname=开启clash服务
cronset='/etc/init.d/clash start'
setcron
elif [[ $num == 4 ]]; then
cronname=更新订阅链接
cronset="source /etc/profile && source $clashdir/getdate.sh && getyaml"
setcron
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashsh
fi
}
clashsh(){
#############################
getconfig
@@ -533,7 +751,7 @@ echo -e " 1 \033[32m启动/重启\033[0mclash服务"
echo -e " 2 clash\033[33m高级设置\033[0m"
echo -e " 3 \033[31m停止\033[0mclash服务"
echo -e " 4 $auto1"
echo -e " 5 设置定时任务(施工中)"
echo -e " 5 设置定时任务"
echo -e " 6 导入\033[32m节点/订阅\033[0m链接"
echo -e " 8 \033[35m测试菜单\033[0m"
echo -e " 9 \033[36m更新/卸载\033[0m"
@@ -544,18 +762,9 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
exit;
elif [[ $num == 1 ]]; then
if [ ! -f "$yaml" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m没有找到配置文件请先导入节点/订阅链接!\033[0m"
clashlink
fi
if [ $status -gt 0 ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/etc/init.d/clash stop > /dev/null 2>&1
echo -e "\033[31mClash服务已停止\033[0m"
fi
clashstart
clashsh
exit;
elif [[ $num == 2 ]]; then
clashadv
@@ -579,14 +788,7 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
clashsh
elif [[ $num == 5 ]]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m正在施工中敬请期待\033[0m"
echo -e "\033[32m正在施工中敬请期待\033[0m"
echo -e "\033[33m正在施工中敬请期待\033[0m"
echo -e "\033[34m正在施工中敬请期待\033[0m"
echo -e "\033[35m正在施工中敬请期待\033[0m"
echo -e "\033[36m正在施工中敬请期待\033[0m"
clashsh
clashcron
elif [[ $num == 6 ]]; then
clashlink
@@ -604,14 +806,14 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
echo " 6 测试代理服务器连通性google.tw)"
echo " 0 返回上级目录!"
read -p "请输入对应数字 > " num
if [ -z $num ]; then
if [ -z "$num" ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[31m请输入正确的数字\033[0m"
clashsh
elif [[ $num == 0 ]]; then
clashsh
elif [[ $num == 1 ]]; then
etc/init.d/clash stop
/etc/init.d/clash stop
echo -e "\033[31m如有报错请截图后到TG群询问\033[0m"
$clashdir/clash -d $clashdir & { sleep 3 ; kill $! & }
echo -e "\033[31m如有报错请截图后到TG群询问\033[0m"
@@ -630,6 +832,9 @@ if [[ $num -le 9 ]] > /dev/null 2>&1; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
iptables -t nat -L PREROUTING --line-numbers
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
iptables -t nat -L clash --line-numbers
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
iptables -t nat -L clash_dns --line-numbers
exit;
elif [[ $num == 5 ]]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@@ -94,31 +94,55 @@ 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 7892
iptables -t nat -A PREROUTING -p tcp -j clash
if [ "$ipv6_support" = "已开启" ];then
ip6tables -t nat -N clashv6
ip6tables -t nat -A clashv6 -p tcp $ports-j REDIRECT --to-ports 7892
ip6tables -t nat -A PREROUTING -p tcp -j clashv6
ip6tables -t nat -N clash
for mac in $(cat $clashdir/mac); do
ip6tables -t nat -A clash -m mac --mac-source $mac -j RETURN
done
ip6tables -t nat -A clash -p tcp $ports-j REDIRECT --to-ports 7892
ip6tables -t nat -A PREROUTING -p tcp -j clash
fi
}
stop_iptables(){
#重置iptables规则
iptables -t nat -D PREROUTING -p tcp -j clash > /dev/null 2>&1
iptables -t nat -D PREROUTING -p udp -j clash_dns > /dev/null 2>&1
iptables -t nat -F clash > /dev/null 2>&1
iptables -t nat -X clash > /dev/null 2>&1
iptables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 > /dev/null 2>&1
ip6tables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to 1053 > /dev/null 2>&1
ip6tables -t nat -D PREROUTING -p tcp -j clashv6 > /dev/null 2>&1
ip6tables -t nat -F clashv6 > /dev/null 2>&1
ip6tables -t nat -X clashv6 > /dev/null 2>&1
iptables -t nat -F clash_dns > /dev/null 2>&1
iptables -t nat -X clash_dns > /dev/null 2>&1
#重置ipv6规则
ip6tables -t nat -D PREROUTING -p tcp -j clash > /dev/null 2>&1
ip6tables -t nat -D PREROUTING -p udp -j clash_dns > /dev/null 2>&1
ip6tables -t nat -F clash > /dev/null 2>&1
ip6tables -t nat -X clash > /dev/null 2>&1
ip6tables -t nat -F clash_dns > /dev/null 2>&1
ip6tables -t nat -X clash_dns > /dev/null 2>&1
}
start_dns(){
#允许tun网卡接受流量
iptables -I FORWARD -o utun -j ACCEPT
ip6tables -I FORWARD -o utun -j ACCEPT
#设置dns转发
iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
ip6tables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to 1053
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 1053
iptables -t nat -A PREROUTING -p udp -j clash_dns
#ipv6DNS
ip6tables -t nat -N clash_dns
for mac in $(cat $clashdir/mac); do
ip6tables -t nat -A clash_dns -m mac --mac-source $mac -j RETURN
done
ip6tables -t nat -A clash_dns -p udp --dport 53 -j REDIRECT --to 1053
ip6tables -t nat -A PREROUTING -p udp -j clash_dns
}
start_service() {
getconfig

View File

@@ -2,6 +2,7 @@
# Copyright (C) Juewuy
getyaml(){
ccfg=$clashdir/mark
source $ccfg
#前后端订阅服务器地址索引,可在此处添加!
Server=`sed -n ""$server_link"p"<<EOF
@@ -19,9 +20,13 @@ https://raw.githubusercontent.com/ACL4SSR/ACL4SSR/master/Clash/config/ACL4SSR_On
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_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
EOF`
#如果传来的是Url链接则合成Https链接否则直接使用Https链接
if [ -z $Https ];then
echo $Url
Https="https://$Server/sub?target=clashr&new_name=true&url=$Url&insert=false&config=$Config"
markhttp=1
fi
@@ -36,6 +41,7 @@ echo -e "| 需要一点时间,请耐心等待! |"
echo -e "| \033[0m如长时间没有数据请用ctrl+c退出\033[36m |"
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\033[0m"
#获取在线yaml文件
yaml=$clashdir/config.yaml
yamlnew=$yaml.new
rm -rf $yamlnew > /dev/null 2>&1
result=$(curl -w %{http_code} -kLo $yamlnew $Https)
@@ -50,15 +56,16 @@ if [ "$result" != "200" ];then
read -p "是否更换后端地址后重试?[1/0] > " res
if [ "$res" = '1' ]; then
sed -i '/server_link=*/'d $ccfg
if [ "$server_link" = '7' ]; then
if [[ $server_link == 7 ]]; then
server_link=0
fi
server_link=$(($server_link + 1))
#echo $server_link
echo $server_link
sed -i "1i\server_link=$server_link" $ccfg
Https=""
getyaml
fi
exit;
#exit;
fi
else
if cat $yamlnew | grep ', server:' >/dev/null;then
@@ -67,20 +74,20 @@ else
mv $yaml $yaml.bak
fi
mv $yamlnew $yaml
echo 配置文件已生成!正在启clash使其生效
echo 配置文件已生成!正在启clash使其生效
#重启clash服务
/etc/init.d/clash restart
/etc/init.d/clash stop > /dev/null 2>&1
/etc/init.d/clash start
sleep 1
status=`ps |grep -w 'clash -d'|grep -v grep|wc -l`
if [[ $status -gt 0 ]];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}';)
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32mclash服务已启动\033[0m"
echo -e "可以使用\033[30;47m http://clash.razord.top \033[0m管理clash内置规则"
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}';)
echo -e "Host地址:\033[30;46m $host \033[0m;端口:\033[30;46m 9999 \033[0m"
#将用户链接写入mark
sed -i '/Https=*/'d $ccfg
sed -i "7i\Https=\'$Https\'" $ccfg
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 "也可前往更新菜单安装本地Dashboard面板连接更稳定\033[0m"
sleep 1
clashsh
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -88,9 +95,11 @@ else
echo -e "\033[31mclash服务启动失败已还原配置文件并重启clash\033[0m"
mv $yaml.bak $yaml
/etc/init.d/clash start
sleep 1
clashsh
else
echo -e "\033[31mclash服务启动失败请利用测试菜单排查问题\033[0m"
sleep 1
clashsh
fi
fi
@@ -103,9 +112,9 @@ else
echo -e "\033[33m请检查如上配置文件信息:\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fi
exit;
#exit;
fi
exit
#exit
}
getlink(){
#设置输入循环
@@ -148,6 +157,7 @@ do
sed -i '/Url=*/'d $ccfg
sed -i '/Https=*/'d $ccfg
sed -i "6i\Url=\'$Url\'" $ccfg
Https=""
#获取在线yaml文件
getyaml
fi
@@ -245,9 +255,10 @@ if [ "$res" = '1' ]; then
[ $? -ne 0 ] && echo "文件解压失败!" && exit 1
#初始化文件目录
mv $clashdir/clashservice /etc/init.d/clash #将clash服务文件移动到系统目录
chmod 777 $clashdir/clash #授予权限
chmod 777 /etc/init.d/clash #授予权限
#写入版本号
sed -i '/versionsh_l=*/'d $ccfg
sed -i "1i\versionsh_l=$versionsh" $ccfg
#删除临时文件
rm -rf /tmp/clashfm.tar.gz
rm -rf /tmp/clashversion
@@ -267,9 +278,15 @@ if [ ! -f $clashdir/clash ]; then
clashcore=没有安装核心!
clashv=''
fi
cpucore=armv7
clashcore_n=$clashcore
#获取设备处理器架构
cpucore=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]')
[ -n "$(echo $cpucore | grep -E "linux.*aarch64.*")" ] && cpucore="armv8"
[ -n "$(echo $cpucore | grep -E "linux.*armv7.*")" ] && cpucore="armv7"
[ -n "$(echo $cpucore | grep -E "linux.*armv.*")" ] && cpucore="armv5"
[ -n "$(echo $cpucore | grep -E "linux.*mips.*")" ] && cpucore="mipsle-softfloat"
[ -n "$(echo $cpucore | grep -E "linux.*x86.*")" ] && cpucore="386"
###
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "当前clash核心\033[47;30m $clashcore \033[46;30m$clashv\033[0m"
echo -e "\033[32m请选择需要下载的核心版本\033[0m"
@@ -386,9 +403,7 @@ read -p "请输入对应数字 > " num
else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[32mGeoIP数据库文件下载成功\033[0m"
update
fi
update
}
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}';)
@@ -443,7 +458,7 @@ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
echo -e "\033[30;47m您可以在此处切换在线更新时使用的资源地址\033[0m"
echo -e "当前源:\033[4;32m$update_url\033[0m"
echo -----------------------------------------------
echo -e " 1 CDN源(感谢\033[4;32mwww.jsdelivr.com\033[0m推荐)"
echo -e " 1 CDN源(可能有一定的同步延迟)"
echo -e " 2 Github源(不稳定,不推荐)"
echo -e " 3 Github源+clash代理(需开启clash服务推荐)"
echo -e " 4 自定义输入(请务必确保路径正确)"
@@ -454,7 +469,7 @@ if [ -z $num ]; then
echo -e "\033[31m请输入正确的数字\033[0m"
update
elif [[ $num == 1 ]]; then
update_url="https://cdn.jsdelivr.net/gh/juewuy/clash-for-Miwifi"
update_url="https://cdn.jsdelivr.net/gh/juewuy/clash-for-Miwifi@latest"
elif [[ $num == 9 ]]; then
update_url="https://juewuy.xyz/clash"
elif [[ $num == 2 ]]; then