v1.0.0beta15.4

~Redir模式增加基于tproxy的udp代理
~修复更新检测失败的bug
This commit is contained in:
juewuy
2020-10-25 10:01:58 +08:00
parent 0f6fc088d8
commit 1b39b2ebd4
6 changed files with 162 additions and 114 deletions

Binary file not shown.

View File

@@ -1,4 +1,4 @@
clash_v=1.2.0 clash_v=1.2.0
clashpre_v=2020.10.09 clashpre_v=2020.10.09
GeoIP_v=20201021 GeoIP_v=20201021
versionsh=1.0.0beta15.3 versionsh=1.0.0beta15.4

View File

@@ -40,14 +40,16 @@ if [ "$test" -gt 0 ];then
[ "$test" -eq 2 ] && url="http://192.168.31.30:8080/clash-for-Miwifi" [ "$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" [ "$test" -eq 3 ] && url="http://192.168.123.90:8080/clash-for-Miwifi"
else else
release_new=$(webget /dev/null https://github.com.cnpmjs.org/juewuy/ShellClash/releases/latest echoon rediroff 2>&1 | grep -oE "releases/tag/.*" | awk -F '[/" ]' '{print $3}') 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}')
[ -z "$release_new" ] && release_new=master [ -z "$release_new" ] && release_new=master
url=$url@$release_new url=$url@$release_new
fi fi
webget /tmp/clashversion $url/bin/version echooff webget /tmp/clashversion $url/bin/version echooff
[ "$result" = "200" ] && source /tmp/clashversion || echo -e "\033[31m检查更新失败\033[0m" [ "$result" = "200" ] && versionsh=$(cat /tmp/clashversion | grep "versionsh" | awk -F "=" '{print $2}')
[ -z "$release_new" ] && release_new=$versionsh [ -z "$release_new" ] && release_new=$versionsh
rm -rf /tmp/clashversion rm -rf /tmp/clashversion
rm -rf /tmp/clashrelease
[ -z "$release_new" ] && echo "无法连接服务器!" && exit [ -z "$release_new" ] && echo "无法连接服务器!" && exit
tarurl=$url/bin/clashfm.tar.gz tarurl=$url/bin/clashfm.tar.gz

View File

@@ -76,7 +76,7 @@ getconfig(){
[ -n "$cronpath" ] && sed -i "1i\cronpath=\'$cronpath\'" $ccfg [ -n "$cronpath" ] && sed -i "1i\cronpath=\'$cronpath\'" $ccfg
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
@@ -142,7 +142,7 @@ setport(){
clashadv clashadv
fi fi
fi fi
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e " 1 修改Http/Sock5端口 \033[36m$mix_port\033[0m" echo -e " 1 修改Http/Sock5端口 \033[36m$mix_port\033[0m"
echo -e " 2 设置Http/Sock5密码 \033[36m$authentication\033[0m" echo -e " 2 设置Http/Sock5密码 \033[36m$authentication\033[0m"
echo -e " 3 修改静态路由端口: \033[36m$redir_port\033[0m" echo -e " 3 修改静态路由端口: \033[36m$redir_port\033[0m"
@@ -209,7 +209,7 @@ setdns(){
fi fi
[ -z "$dns_nameserver" ] && dns_nameserver='114.114.114.114, 223.5.5.5' [ -z "$dns_nameserver" ] && dns_nameserver='114.114.114.114, 223.5.5.5'
[ -z "$dns_fallback" ] && dns_fallback='1.0.0.1, 8.8.4.4' [ -z "$dns_fallback" ] && dns_fallback='1.0.0.1, 8.8.4.4'
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "当前基础DNS\033[36m$dns_nameserver\033[0m" echo -e "当前基础DNS\033[36m$dns_nameserver\033[0m"
echo -e "fallbackDNS\033[36m$dns_fallback\033[0m" echo -e "fallbackDNS\033[36m$dns_fallback\033[0m"
echo -e "多个DNS地址请用\033[30;47m | \033[0m分隔一次性输入" echo -e "多个DNS地址请用\033[30;47m | \033[0m分隔一次性输入"
@@ -262,10 +262,10 @@ setdns(){
checkport(){ checkport(){
for portx in $dns_port $mix_port $redir_port $db_port ;do for portx in $dns_port $mix_port $redir_port $db_port ;do
if [ -n "$(netstat -ntul 2>&1 |grep :$portx)" ];then if [ -n "$(netstat -ntul 2>&1 |grep :$portx)" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "检测到端口【$portx】被以下进程占用clash可能无法正常启动\033[33m" echo -e "检测到端口【$portx】被以下进程占用clash可能无法正常启动\033[33m"
echo $(netstat -ntulp | grep :$portx | head -n 1) echo $(netstat -ntulp | grep :$portx | head -n 1)
echo -e "\033[0m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo -e "\033[0m-----------------------------------------------"
echo -e "\033[36m请修改默认端口配置\033[0m" echo -e "\033[36m请修改默认端口配置\033[0m"
setport setport
source $ccfg source $ccfg
@@ -276,13 +276,13 @@ checkport(){
clashstart(){ clashstart(){
#检查clash核心 #检查clash核心
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"
source $clashdir/getdate.sh && checkupdate && getcore source $clashdir/getdate.sh && checkupdate && 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"
source $clashdir/getdate.sh && checkupdate && getgeo source $clashdir/getdate.sh && checkupdate && getgeo
fi fi
@@ -362,7 +362,7 @@ macfilter(){
fi fi
del_mac del_mac
} }
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
[ -f /var/lib/dhcp/dhcpd.leases ] && dhcpdir='/var/lib/dhcp/dhcpd.leases' [ -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 /var/lib/dhcpd/dhcpd.leases ] && dhcpdir='/var/lib/dhcpd/dhcpd.leases'
[ -f /tmp/dhcp.leases ] && dhcpdir='/tmp/dhcp.leases' [ -f /tmp/dhcp.leases ] && dhcpdir='/tmp/dhcp.leases'
@@ -411,7 +411,7 @@ macfilter(){
} }
clashcfg(){ clashcfg(){
set_redir_mod(){ set_redir_mod(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "当前代理模式为:\033[47;30m $redir_mod \033[0mClash核心为\033[47;30m $clashcore \033[0m" echo -e "当前代理模式为:\033[47;30m $redir_mod \033[0mClash核心为\033[47;30m $clashcore \033[0m"
echo -e "\033[33m切换模式后需要手动重启clash服务以生效\033[0m" echo -e "\033[33m切换模式后需要手动重启clash服务以生效\033[0m"
echo -e "\033[36mTun及混合模式必须使用clashpre核心\033[0m" echo -e "\033[36mTun及混合模式必须使用clashpre核心\033[0m"
@@ -439,7 +439,7 @@ clashcfg(){
redir_mod=Redir模式 redir_mod=Redir模式
elif [ "$num" = 2 ]; then elif [ "$num" = 2 ]; then
if [ "$clashcore" = "clash" ] || [ "$clashcore" = "clashr" ];then if [ "$clashcore" = "clash" ] || [ "$clashcore" = "clashr" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m当前核心不支持开启Tun模式请先切换clash核心\033[0m" echo -e "\033[31m当前核心不支持开启Tun模式请先切换clash核心\033[0m"
clashcfg clashcfg
fi fi
@@ -447,19 +447,19 @@ clashcfg(){
dns_mod=fake-ip dns_mod=fake-ip
elif [ "$num" = 3 ]; then elif [ "$num" = 3 ]; then
if [ "$clashcore" = "clash" ] || [ "$clashcore" = "clashr" ];then if [ "$clashcore" = "clash" ] || [ "$clashcore" = "clashr" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m当前核心不支持开启Tun模式请先切换clash核心\033[0m" echo -e "\033[31m当前核心不支持开启Tun模式请先切换clash核心\033[0m"
clashcfg clashcfg
fi fi
redir_mod=混合模式 redir_mod=混合模式
elif [ "$num" = 4 ]; then elif [ "$num" = 4 ]; then
redir_mod=纯净模式 redir_mod=纯净模式
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;47m$mix_port\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
if [ "$res" = 1 ]; then if [ "$res" = 1 ]; then
source $clashdir/getdate.sh && setpac source $clashdir/getdate.sh && setpac
@@ -472,11 +472,11 @@ clashcfg(){
sed -i "1i\redir_mod=$redir_mod" $ccfg sed -i "1i\redir_mod=$redir_mod" $ccfg
sed -i '/dns_mod*/'d $ccfg sed -i '/dns_mod*/'d $ccfg
sed -i "1i\dns_mod=$dns_mod" $ccfg sed -i "1i\dns_mod=$dns_mod" $ccfg
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[36m已设为 $redir_mod \033[0m" echo -e "\033[36m已设为 $redir_mod \033[0m"
} }
set_dns_mod(){ set_dns_mod(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "当前DNS运行模式为\033[47;30m $dns_mod \033[0m" echo -e "当前DNS运行模式为\033[47;30m $dns_mod \033[0m"
echo -e "\033[33m切换模式后需要手动重启clash服务以生效\033[0m" echo -e "\033[33m切换模式后需要手动重启clash服务以生效\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
@@ -504,7 +504,7 @@ clashcfg(){
sed -i "1i\dns_mod=$dns_mod" $ccfg sed -i "1i\dns_mod=$dns_mod" $ccfg
sed -i '/redir_mod*/'d $ccfg sed -i '/redir_mod*/'d $ccfg
sed -i "1i\redir_mod=$redir_mod" $ccfg sed -i "1i\redir_mod=$redir_mod" $ccfg
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[36m已设为 $dns_mod 模式!!\033[0m" echo -e "\033[36m已设为 $dns_mod 模式!!\033[0m"
} }
@@ -513,9 +513,10 @@ clashcfg(){
[ -z "$common_ports" ] && common_ports=已开启 [ -z "$common_ports" ] && common_ports=已开启
[ -z "$dns_mod" ] && dns_mod=redir_host [ -z "$dns_mod" ] && dns_mod=redir_host
[ -z "$dns_over" ] && dns_over=已开启 [ -z "$dns_over" ] && dns_over=已开启
[ -z "$local_proxy" ] && local_proxy=未开启
[ -z "$(cat $clashdir/mac)" ] && mac_return=未开启 || mac_return=已启用 [ -z "$(cat $clashdir/mac)" ] && mac_return=未开启 || mac_return=已启用
# #
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[30;47m欢迎使用功能设置菜单\033[0m" echo -e "\033[30;47m欢迎使用功能设置菜单\033[0m"
echo -e "\033[32m修改配置后请手动重启clash服务\033[0m" echo -e "\033[32m修改配置后请手动重启clash服务\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
@@ -525,6 +526,7 @@ clashcfg(){
echo -e " 4 只代理常用端口: \033[36m$common_ports\033[0m ————用于屏蔽P2P流量" echo -e " 4 只代理常用端口: \033[36m$common_ports\033[0m ————用于屏蔽P2P流量"
echo -e " 5 过滤局域网mac地址 \033[36m$mac_return\033[0m ————列表内设备不走代理" 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 " 6 不使用本地DNS服务 \033[36m$dns_over\033[0m ————防止redir-host模式的dns污染"
echo -e " 7 设置代理本机流量: \033[36m$local_proxy\033[0m ————使用环境变量或者PAC配置本机代理"
echo ----------------------------------------------- echo -----------------------------------------------
echo -e " 9 \033[32m重启\033[0mclash服务" echo -e " 9 \033[32m重启\033[0mclash服务"
echo -e " 0 返回上级菜单 \033[0m" echo -e " 0 返回上级菜单 \033[0m"
@@ -545,7 +547,7 @@ clashcfg(){
elif [ "$num" = 3 ]; then elif [ "$num" = 3 ]; 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
sed -i "1i\skip_cert=已开启" $ccfg sed -i "1i\skip_cert=已开启" $ccfg
echo -e "\033[33m已设为开启跳过本地证书验证\033[0m" echo -e "\033[33m已设为开启跳过本地证书验证\033[0m"
@@ -559,7 +561,7 @@ clashcfg(){
elif [ "$num" = 4 ]; then elif [ "$num" = 4 ]; then
sed -i '/common_ports*/'d $ccfg sed -i '/common_ports*/'d $ccfg
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
if [ "$common_ports" = "未开启" ] > /dev/null 2>&1; then if [ "$common_ports" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\common_ports=已开启" $ccfg sed -i "1i\common_ports=已开启" $ccfg
echo -e "\033[33m已设为仅代理22,53,587,465,995,993,143,80,443等常用端口\033[0m" echo -e "\033[33m已设为仅代理22,53,587,465,995,993,143,80,443等常用端口\033[0m"
@@ -576,7 +578,7 @@ clashcfg(){
elif [ "$num" = 6 ]; then elif [ "$num" = 6 ]; then
sed -i '/dns_over*/'d $ccfg sed -i '/dns_over*/'d $ccfg
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
if [ "$dns_over" = "未开启" ] > /dev/null 2>&1; then if [ "$dns_over" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\dns_over=已开启" $ccfg sed -i "1i\dns_over=已开启" $ccfg
echo -e "\033[33m已设置DNS为不走本地dnsmasq服务器\033[0m" echo -e "\033[33m已设置DNS为不走本地dnsmasq服务器\033[0m"
@@ -591,6 +593,25 @@ clashcfg(){
fi fi
clashcfg clashcfg
elif [ "$num" = 7 ]; then
sed -i '/local_proxy*/'d $ccfg
echo -----------------------------------------------
if [ "$local_proxy" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\local_proxy=已开启" $ccfg
local_proxy=已开启
$clashdir/start.sh set_proxy $mix_port $hostdir
echo -e "\033[32m已经成功配置本机代理~\033[0m"
echo -e "\033[36m如未生效请重新启动终端或重新连接SSH\033[0m"
else
sed -i "1i\local_proxy=未开启" $ccfg
local_proxy=未开启
$clashdir/start.sh unset_proxy
echo -e "\033[33m已经停用本机代理规则\033[0m"
echo -e "\033[36m如未生效请重新启动终端或重新连接SSH\033[0m"
fi
sleep 1
clashcfg
elif [ "$num" = 9 ]; then elif [ "$num" = 9 ]; then
clashstart clashstart
clashsh clashsh
@@ -604,9 +625,9 @@ clashadv(){
[ -z "$modify_yaml" ] && modify_yaml=未开启 [ -z "$modify_yaml" ] && modify_yaml=未开启
[ -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 "$tproxy_mod" ] && tproxy_mod=未开启
# #
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[30;47m欢迎使用进阶模式菜单\033[0m" 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"
@@ -614,7 +635,7 @@ clashadv(){
echo -e " 1 使用自定义配置: \033[36m$modify_yaml\033[0m ————不使用内置规则修饰config.yaml" echo -e " 1 使用自定义配置: \033[36m$modify_yaml\033[0m ————不使用内置规则修饰config.yaml"
echo -e " 2 启用ipv6支持: \033[36m$ipv6_support\033[0m ————实验性功能,可能不稳定" 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 ————使用环境变量或者PAC配置本机代理" echo -e " 4 Redir模式udp转发: \033[36m$tproxy_mod\033[0m ————依赖iptables-mod-tproxy"
echo -e " 5 手动指定clash运行端口及秘钥" echo -e " 5 手动指定clash运行端口及秘钥"
echo -e " 6 手动配置内置DNS服务" echo -e " 6 手动配置内置DNS服务"
echo ----------------------------------------------- echo -----------------------------------------------
@@ -631,7 +652,7 @@ clashadv(){
elif [ "$num" = 1 ]; then elif [ "$num" = 1 ]; then
sed -i '/modify_yaml*/'d $ccfg sed -i '/modify_yaml*/'d $ccfg
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
if [ "$modify_yaml" = "未开启" ] > /dev/null 2>&1; then if [ "$modify_yaml" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\modify_yaml=已开启" $ccfg sed -i "1i\modify_yaml=已开启" $ccfg
echo -e "\033[33m已设为使用用户完全自定义的配置文件" echo -e "\033[33m已设为使用用户完全自定义的配置文件"
@@ -648,7 +669,7 @@ clashadv(){
elif [ "$num" = 2 ]; then elif [ "$num" = 2 ]; then
sed -i '/ipv6_support*/'d $ccfg sed -i '/ipv6_support*/'d $ccfg
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
if [ "$ipv6_support" = "未开启" ] > /dev/null 2>&1; then if [ "$ipv6_support" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\ipv6_support=已开启" $ccfg sed -i "1i\ipv6_support=已开启" $ccfg
echo -e "\033[33m已开启对ipv6协议的支持\033[0m" echo -e "\033[33m已开启对ipv6协议的支持\033[0m"
@@ -664,7 +685,7 @@ clashadv(){
elif [ "$num" = 3 ]; then elif [ "$num" = 3 ]; then
sed -i '/start_old*/'d $ccfg sed -i '/start_old*/'d $ccfg
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
if [ "$start_old" = "未开启" ] > /dev/null 2>&1; then if [ "$start_old" = "未开启" ] > /dev/null 2>&1; then
sed -i "1i\start_old=已开启" $ccfg sed -i "1i\start_old=已开启" $ccfg
echo -e "\033[33m改为使用保守方式启动clash服务\033[0m" echo -e "\033[33m改为使用保守方式启动clash服务\033[0m"
@@ -681,20 +702,20 @@ clashadv(){
clashadv clashadv
elif [ "$num" = 4 ]; then elif [ "$num" = 4 ]; then
sed -i '/local_proxy*/'d $ccfg sed -i '/tproxy_mod*/'d $ccfg
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
if [ "$local_proxy" = "未开启" ] > /dev/null 2>&1; then if [ "$tproxy_mod" = "未开启" ]; then
sed -i "1i\local_proxy=已开启" $ccfg if [ -n "$(iptables -j TPROXY 2>&1 | grep 'on-port')" ];then
local_proxy=已开启 sed -i "1i\tproxy_mod=已开启" $ccfg
$clashdir/start.sh set_proxy $mix_port $hostdir tproxy_mod=已开启
echo -e "\033[32m已经成功配置本机代理~\033[0m" echo -e "\033[32m已经为Redir模式启用udp转发功能\033[0m"
echo -e "\033[36m如未生效请重新启动终端或重新连接SSH\033[0m" else
echo -e "\033[31m您的设备不支持tproxy模式无法开启\033[0m"
fi
else else
sed -i "1i\local_proxy=未开启" $ccfg sed -i "1i\tproxy_mod=未开启" $ccfg
local_proxy=未开启 tproxy_mod=未开启
$clashdir/start.sh unset_proxy echo -e "\033[33m已经停止使用tproxy转发udp流量\033[0m"
echo -e "\033[33m已经停用本机代理规则\033[0m"
echo -e "\033[36m如未生效请重新启动终端或重新连接SSH\033[0m"
fi fi
sleep 1 sleep 1
clashadv clashadv
@@ -746,7 +767,7 @@ clashcron(){
clashcron clashcron
elif [ "$num" = 9 ]; then elif [ "$num" = 9 ]; then
sed -i /$cronname/d $cronpath sed -i /$cronname/d $cronpath
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m定时任务$cronname已删除\033[0m" echo -e "\033[31m定时任务$cronname已删除\033[0m"
clashcron clashcron
elif [ "$num" = 8 ]; then elif [ "$num" = 8 ]; then
@@ -787,7 +808,7 @@ clashcron(){
if [ "$res" = '1' ]; then if [ "$res" = '1' ]; then
sed -i /$cronname/d $cronpath sed -i /$cronname/d $cronpath
echo "$min $hour * * $week $cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname" >> $cronpath echo "$min $hour * * $week $cronset >/dev/null 2>&1 #$week1的$hour点$min分$cronname" >> $cronpath
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m定时任务已添加\033[0m" echo -e "\033[31m定时任务已添加\033[0m"
chmod 600 $cronpath #修改权限 chmod 600 $cronpath #修改权限
fi fi
@@ -795,10 +816,10 @@ clashcron(){
} }
checkcron(){ checkcron(){
if [ -z "$cronpath" ];then if [ -z "$cronpath" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[33m找不到定时任务配置文件无法添加添加定时任务" echo -e "\033[33m找不到定时任务配置文件无法添加添加定时任务"
echo -e "\033[0m请手动指定定时任务配置文件文件位置可以通过【crontab -e】命令查看\033[0m" echo -e "\033[0m请手动指定定时任务配置文件文件位置可以通过【crontab -e】命令查看\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
read -p "请输入crontab文件路径(输入回车返回主菜单) > " path read -p "请输入crontab文件路径(输入回车返回主菜单) > " path
if [ -z "$path" ];then if [ -z "$path" ];then
clashsh clashsh
@@ -814,7 +835,7 @@ clashcron(){
} }
#定时任务菜单 #定时任务菜单
checkcron #检测定时任务文件 checkcron #检测定时任务文件
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[30;47m欢迎使用定时任务功能\033[0m" 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 -----------------------------------------------
@@ -890,13 +911,13 @@ clashsh(){
elif [ "$num" = 3 ]; then elif [ "$num" = 3 ]; then
$clashdir/start.sh stop $clashdir/start.sh stop
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31mClash服务已停止\033[0m" echo -e "\033[31mClash服务已停止\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
exit; exit;
elif [ "$num" = 4 ]; then elif [ "$num" = 4 ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
if [ "$start_old" = "已开启" ];then if [ "$start_old" = "已开启" ];then
sed -i "/start_old*/d" $ccfg sed -i "/start_old*/d" $ccfg
sed -i "1i\start_old=未开启" $ccfg sed -i "1i\start_old=未开启" $ccfg

View File

@@ -19,7 +19,7 @@ webget(){
export all_proxy='' export all_proxy=''
} }
linkconfig(){ 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通用版无去广告推荐
@@ -47,12 +47,12 @@ linkconfig(){
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
rule_link=$num rule_link=$num
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[32m设置成功返回上级菜单\033[0m" echo -e "\033[32m设置成功返回上级菜单\033[0m"
fi 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 -e "\033[36m 感谢 https://github.com/tindy2013/subconverter \033[0m"
echo 当前使用后端为:$server_link echo 当前使用后端为:$server_link
@@ -73,13 +73,13 @@ linkserver(){
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
server_link=$num server_link=$num
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[32m设置成功返回上级菜单\033[0m" echo -e "\033[32m设置成功返回上级菜单\033[0m"
fi fi
} }
linkfilter(){ linkfilter(){
[ -z "$exclude" ] && exclude="未设置" [ -z "$exclude" ] && exclude="未设置"
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[33m当前过滤关键字\033[47;30m$exclude\033[0m" echo -e "\033[33m当前过滤关键字\033[47;30m$exclude\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
@@ -104,7 +104,7 @@ linkfilter(){
} }
linkfilter2(){ linkfilter2(){
[ -z "$include" ] && include="未设置" [ -z "$include" ] && include="未设置"
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[33m当前筛选关键字\033[47;30m$include\033[0m" echo -e "\033[33m当前筛选关键字\033[47;30m$include\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
@@ -130,7 +130,7 @@ linkfilter2(){
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 -----------------------------------------------
@@ -172,7 +172,7 @@ linkset(){
linkset linkset
elif [ "$num" = '6' ]; then 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
sed -i "1i\skip_cert=已开启" $ccfg sed -i "1i\skip_cert=已开启" $ccfg
#echo -e "\033[33m已设为开启跳过本地证书验证\033[0m" #echo -e "\033[33m已设为开启跳过本地证书验证\033[0m"
@@ -195,7 +195,7 @@ getlink(){
i=1 i=1
while [ $i -le 99 ] 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 -e "\033[31m本功能依赖第三方网站在线服务实现脚本本身不提供任何代理服务\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
@@ -220,24 +220,24 @@ getlink(){
elif [ -z "$url" ];then elif [ -z "$url" ];then
[ -n "$Url" ] && linkset [ -n "$Url" ] && linkset
elif [ "$url" = 0 ];then elif [ "$url" = 0 ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m已撤销并删除所有已输入的链接\033[0m" echo -e "\033[31m已撤销并删除所有已输入的链接\033[0m"
Url="" Url=""
sleep 1 sleep 1
clashlink clashlink
else else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m请输入正确的订阅链接\033[0m" echo -e "\033[31m请输入正确的订阅链接\033[0m"
fi fi
done done
#### ####
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo 输入太多啦,可能会导致订阅失败! echo 输入太多啦,可能会导致订阅失败!
echo "多个较短的链接请尽量用“|”分隔以一次性输入!" echo "多个较短的链接请尽量用“|”分隔以一次性输入!"
clashlink clashlink
} }
getlink2(){ getlink2(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[33m仅限导入完整clash配置文件链接\033[0m" echo -e "\033[33m仅限导入完整clash配置文件链接\033[0m"
echo -e "可以使用\033[32m https://acl4ssr.netlify.app \033[0m在线生成配置文件" echo -e "可以使用\033[32m https://acl4ssr.netlify.app \033[0m在线生成配置文件"
echo -e "\033[36m导入后如无法运行请使用【导入订阅】功能" echo -e "\033[36m导入后如无法运行请使用【导入订阅】功能"
@@ -248,7 +248,7 @@ getlink2(){
test=$(echo $Https | grep -iE "http.*://" ) test=$(echo $Https | grep -iE "http.*://" )
Https=`echo ${Https/\ \(*\)/''}` #删除恶心的超链接内容 Https=`echo ${Https/\ \(*\)/''}` #删除恶心的超链接内容
if [ -n "$Https" -a -n "$test" ];then if [ -n "$Https" -a -n "$test" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e 请检查输入的链接是否正确: echo -e 请检查输入的链接是否正确:
echo -e "\033[4m$Https\033[0m" echo -e "\033[4m$Https\033[0m"
read -p "确认导入配置文件原配置文件将被更名为config.yaml.bak![1/0] > " res read -p "确认导入配置文件原配置文件将被更名为config.yaml.bak![1/0] > " res
@@ -265,7 +265,7 @@ getlink2(){
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" echo -e "\033[33m链接地址必须是http或者https开头的形式\033[0m"
clashlink clashlink
@@ -282,7 +282,7 @@ clashlink(){
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并生成Clash配置文件" echo -e " 1 在线导入\033[36m订阅\033[0m并生成Clash配置文件"
@@ -302,14 +302,14 @@ clashlink(){
clashsh clashsh
elif [ "$num" = 1 ];then elif [ "$num" = 1 ];then
if [ -n "$Url" ];then if [ -n "$Url" ];then
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
Url="" Url=""
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m链接已清空\033[0m" echo -e "\033[31m链接已清空\033[0m"
fi fi
fi fi
@@ -317,14 +317,14 @@ clashlink(){
elif [ "$num" = 2 ];then elif [ "$num" = 2 ];then
if [ -n "$Url" ];then if [ -n "$Url" ];then
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
Url="" Url=""
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m链接已清空\033[0m" echo -e "\033[31m链接已清空\033[0m"
fi fi
fi fi
@@ -349,18 +349,18 @@ clashlink(){
elif [ "$num" = 7 ];then elif [ "$num" = 7 ];then
yamlbak=$yaml.bak yamlbak=$yaml.bak
if [ ! -f "$yaml".bak ];then if [ ! -f "$yaml".bak ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m没有找到配置文件的备份\033[0m" echo -e "\033[31m没有找到配置文件的备份\033[0m"
else else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e 备份文件共有"\033[32m`wc -l < $yamlbak`\033[0m"行内容,当前文件共有"\033[32m`wc -l < $yaml`\033[0m"行内容 echo -e 备份文件共有"\033[32m`wc -l < $yamlbak`\033[0m"行内容,当前文件共有"\033[32m`wc -l < $yaml`\033[0m"行内容
read -p "确认还原配置文件?此操作不可逆![1/0] > " res read -p "确认还原配置文件?此操作不可逆![1/0] > " res
if [ "$res" = '1' ]; then if [ "$res" = '1' ]; then
mv $yamlbak $yaml mv $yamlbak $yaml
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[32m配置文件已还原请手动重启clash服务\033[0m" echo -e "\033[32m配置文件已还原请手动重启clash服务\033[0m"
else else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m操作已取消返回上级菜单\033[0m" echo -e "\033[31m操作已取消返回上级菜单\033[0m"
fi fi
fi fi
@@ -368,15 +368,15 @@ clashlink(){
elif [ "$num" = 8 ];then elif [ "$num" = 8 ];then
if [ -z "$Url" -a -z "$Https" ];then if [ -z "$Url" -a -z "$Https" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m没有找到你的订阅链接请先输入链接\033[0m" echo -e "\033[31m没有找到你的订阅链接请先输入链接\033[0m"
sleep 2 sleep 2
clashlink clashlink
else else
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
$clashdir/start.sh getyaml $clashdir/start.sh getyaml
@@ -400,7 +400,7 @@ gettar(){
webget /tmp/clashfm.tar.gz $tarurl webget /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/
@@ -486,7 +486,7 @@ getcore(){
fi fi
} }
### ###
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
[ -z "$cpucore" ] && getcputype [ -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 $cpucore \033[0m" echo -e "当前系统处理器架构:\033[32m $cpucore \033[0m"
@@ -535,15 +535,15 @@ getcore(){
fi fi
#生成链接 #生成链接
corelink="$update_url/bin/$clashcore/clash-linux-$cpucore" corelink="$update_url/bin/$clashcore/clash-linux-$cpucore"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo 正在连接服务器获取clash核心文件…………链接地址为 echo 正在连接服务器获取clash核心文件…………链接地址为
echo -e "\033[4;32m$corelink\033[0m" echo -e "\033[4;32m$corelink\033[0m"
echo 如无法正常下载可以手动复制到浏览器下载核心文件! echo 如无法正常下载可以手动复制到浏览器下载核心文件!
echo -e "\033[36m~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" echo -e "\033[36m-----------------------------------------------"
echo -e "| |" echo -e "| |"
echo -e "| 需要一点时间,请耐心等待! |" echo -e "| 需要一点时间,请耐心等待! |"
echo -e "| \033[0m如长时间没有数据请用ctrl+c退出 |" echo -e "| \033[0m如长时间没有数据请用ctrl+c退出 |"
echo -e "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\033[0m" echo -e "-----------------------------------------------\033[0m"
#获取在线clash核心文件 #获取在线clash核心文件
webget /tmp/clash.new $corelink webget /tmp/clash.new $corelink
if [ "$result" != "200" ];then if [ "$result" != "200" ];then
@@ -560,7 +560,7 @@ getcore(){
sed -i '/clashv=*/'d $ccfg sed -i '/clashv=*/'d $ccfg
sed -i "1i\clashv=$version" $ccfg sed -i "1i\clashv=$version" $ccfg
rm -rf /tmp/clashversion rm -rf /tmp/clashversion
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[32m$clashcore核心安装成功\033[0m" echo -e "\033[32m$clashcore核心安装成功\033[0m"
fi fi
} }
@@ -571,16 +571,16 @@ getgeo(){
echo ----------------------------------------------- echo -----------------------------------------------
read -p "是否更新数据库文件?[1/0] > " res read -p "是否更新数据库文件?[1/0] > " res
if [ "$res" = '1' ]; then if [ "$res" = '1' ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo 正在从服务器获取数据库文件………… echo 正在从服务器获取数据库文件…………
webget /tmp/Country.mmdb $update_url/bin/Country.mmdb webget /tmp/Country.mmdb $update_url/bin/Country.mmdb
if [ "$result" != "200" ];then if [ "$result" != "200" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m文件下载失败\033[0m" echo -e "\033[31m文件下载失败\033[0m"
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
getgeo getgeo
else else
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[32mGeoIP数据库文件下载成功\033[0m" echo -e "\033[32mGeoIP数据库文件下载成功\033[0m"
mv /tmp/Country.mmdb $clashdir/Country.mmdb mv /tmp/Country.mmdb $clashdir/Country.mmdb
sed -i '/Geo_v=*/'d $ccfg sed -i '/Geo_v=*/'d $ccfg
@@ -588,11 +588,11 @@ getgeo(){
rm -rf /tmp/clashversion rm -rf /tmp/clashversion
fi fi
else else
clashsh update
fi fi
} }
getdb(){ getdb(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[36m安装本地版dashboard管理面板\033[0m" echo -e "\033[36m安装本地版dashboard管理面板\033[0m"
echo -e "\033[32m打开管理面板的速度更快且更稳定\033[0m" echo -e "\033[32m打开管理面板的速度更快且更稳定\033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
@@ -715,7 +715,7 @@ setpac(){
#检测目录 #检测目录
[ -n "$authentication" ] && echo 检测到已经设置http代理密码pac不支持加密代理请先取消加密 && sleep 1 && clashadv [ -n "$authentication" ] && echo 检测到已经设置http代理密码pac不支持加密代理请先取消加密 && sleep 1 && clashadv
[ ! -d /www/clash -a ! -d $clashdir/ui ] && echo 未检测到本地Dashboard面板请先安装面板 && sleep 1 && getdb [ ! -d /www/clash -a ! -d $clashdir/ui ] && echo 未检测到本地Dashboard面板请先安装面板 && sleep 1 && getdb
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"
[ -f $dbdir/pac ] && echo -e "PAC地址\033[32mhttp://$host$dbdir/pac\033[0m" [ -f $dbdir/pac ] && echo -e "PAC地址\033[32mhttp://$host$dbdir/pac\033[0m"
@@ -740,7 +740,7 @@ setpac(){
} }
setserver(){ setserver(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 -----------------------------------------------
@@ -763,10 +763,10 @@ setserver(){
elif [ "$num" = 4 ]; then elif [ "$num" = 4 ]; then
update_url='https://gitee.com/juewuy/ShellClash/raw/master' update_url='https://gitee.com/juewuy/ShellClash/raw/master'
elif [ "$num" = 5 ]; then elif [ "$num" = 5 ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
read -p "请输入个人源路径 > " update_url read -p "请输入个人源路径 > " update_url
if [ -z "$update_url" ];then if [ -z "$update_url" ];then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[31m取消输入返回上级菜单\033[0m" echo -e "\033[31m取消输入返回上级菜单\033[0m"
update update
fi fi
@@ -779,7 +779,7 @@ setserver(){
#写入mark文件 #写入mark文件
sed -i '/update_url*/'d $ccfg 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="" release_new=""
update update
@@ -787,7 +787,8 @@ setserver(){
checkupdate(){ checkupdate(){
if [ -z "$release_new" ];then if [ -z "$release_new" ];then
if [ "$update_url" = "https://cdn.jsdelivr.net/gh/juewuy/ShellClash" ];then if [ "$update_url" = "https://cdn.jsdelivr.net/gh/juewuy/ShellClash" ];then
release_new=$(webget /dev/null https://github.com.cnpmjs.org/juewuy/ShellClash/releases/latest echoon rediroff 2>&1 | grep -oE "releases/tag/.*" | awk -F '[/" ]' '{print $3}') 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}')
[ -z "$release_new" ] && release_new=master [ -z "$release_new" ] && release_new=master
update_url=$update_url@$release_new update_url=$update_url@$release_new
fi fi
@@ -795,11 +796,12 @@ if [ -z "$release_new" ];then
[ "$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 [ -z "$release_new" ] && release_new=$versionsh
rm -rf /tmp/clashversion rm -rf /tmp/clashversion
rm -rf /tmp/clashrelease
fi fi
} }
update(){ update(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[33m正在检查更新\033[0m" echo -ne "\033[32m正在检查更新\033[0m\r"
checkupdate checkupdate
[ "$clashcore" = "clash" ] && clash_n=$clash_v || clash_n=$clashpre_v [ "$clashcore" = "clash" ] && clash_n=$clash_v || clash_n=$clashpre_v
echo -e "\033[30;47m欢迎使用更新功能\033[0m" echo -e "\033[30;47m欢迎使用更新功能\033[0m"
@@ -844,7 +846,7 @@ update(){
setserver setserver
elif [ "$num" = 8 ]; then elif [ "$num" = 8 ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "感谢:\033[32mClash \033[0m作者\033[36m Dreamacro\033[0m 项目地址:\033[32mhttps://github.com/Dreamacro/clash\033[0m" echo -e "感谢:\033[32mClash \033[0m作者\033[36m Dreamacro\033[0m 项目地址:\033[32mhttps://github.com/Dreamacro/clash\033[0m"
echo -e "感谢:\033[32msubconverter \033[0m作者\033[36m tindy2013\033[0m 项目地址:\033[32mhttps://github.com/tindy2013/subconverter\033[0m" echo -e "感谢:\033[32msubconverter \033[0m作者\033[36m tindy2013\033[0m 项目地址:\033[32mhttps://github.com/tindy2013/subconverter\033[0m"
echo -e "感谢:\033[32malecthw提供的GeoIP数据库\033[0m 项目地址:\033[32mhttps://github.com/alecthw/mmdb_china_ip_list\033[0m" echo -e "感谢:\033[32malecthw提供的GeoIP数据库\033[0m 项目地址:\033[32mhttps://github.com/alecthw/mmdb_china_ip_list\033[0m"
@@ -893,7 +895,7 @@ userguide(){
clashlink clashlink
} }
testcommand(){ testcommand(){
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "\033[30;47m这里是测试命令菜单\033[0m" echo -e "\033[30;47m这里是测试命令菜单\033[0m"
echo -e "\033[33m如遇问题尽量运行相应命令后截图发群\033[0m" echo -e "\033[33m如遇问题尽量运行相应命令后截图发群\033[0m"
echo -e "磁盘占用/所在目录:" echo -e "磁盘占用/所在目录:"
@@ -923,34 +925,34 @@ testcommand(){
echo -e "\033[31m如有报错请截图后到TG群询问\033[0m" echo -e "\033[31m如有报错请截图后到TG群询问\033[0m"
exit; exit;
elif [ "$num" = 2 ]; then elif [ "$num" = 2 ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
netstat -ntulp |grep 53 netstat -ntulp |grep 53
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
echo -e "可以使用\033[44m netstat -ntulp |grep xxx \033[0m来查询任意(xxx)端口" echo -e "可以使用\033[44m netstat -ntulp |grep xxx \033[0m来查询任意(xxx)端口"
exit; exit;
elif [ "$num" = 3 ]; then elif [ "$num" = 3 ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
openssl speed -multi 4 -evp aes-128-gcm openssl speed -multi 4 -evp aes-128-gcm
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
exit; exit;
elif [ "$num" = 4 ]; then elif [ "$num" = 4 ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
iptables -t nat -L PREROUTING --line-numbers iptables -t nat -L PREROUTING --line-numbers
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
iptables -t nat -L clash --line-numbers iptables -t nat -L clash --line-numbers
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
iptables -t nat -L clash_dns --line-numbers iptables -t nat -L clash_dns --line-numbers
exit; exit;
elif [ "$num" = 5 ]; then elif [ "$num" = 5 ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
sed -n '1,40p' $yaml sed -n '1,40p' $yaml
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
exit; exit;
elif [ "$num" = 6 ]; then elif [ "$num" = 6 ]; then
echo "注意依赖curl(不支持wget),且测试结果不保证一定准确!" echo "注意依赖curl(不支持wget),且测试结果不保证一定准确!"
delay=`curl -kx ${authentication}@127.0.0.1:$mix_port -o /dev/null -s -w '%{time_starttransfer}' 'https://google.tw' & { sleep 3 ; kill $! & }` > /dev/null 2>&1 delay=`curl -kx ${authentication}@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
echo -e "\033[32m连接成功响应时间为"$delay" ms\033[0m" echo -e "\033[32m连接成功响应时间为"$delay" ms\033[0m"
else else
@@ -960,7 +962,7 @@ testcommand(){
elif [ "$num" = 7 ]; then elif [ "$num" = 7 ]; then
userguide userguide
elif [ "$num" = 9 ]; then elif [ "$num" = 9 ]; then
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo -----------------------------------------------
cat $clashdir/log cat $clashdir/log
exit; exit;
else else

View File

@@ -26,7 +26,7 @@ getconfig(){
[ "$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 '
} }
logger(){ logger(){
echo -e "\033[31m$1\033[0m" [ -z "$1" ] && echo -e "\033[31m$1\033[0m"
echo `date "+%G-%m-%d %H:%M:%S"` $1 >> $clashdir/log echo `date "+%G-%m-%d %H:%M:%S"` $1 >> $clashdir/log
[ "$(wc -l $clashdir/log | awk '{print $1}')" -gt 30 ] && sed -i '1d' $clashdir/log [ "$(wc -l $clashdir/log | awk '{print $1}')" -gt 30 ] && sed -i '1d' $clashdir/log
} }
@@ -87,8 +87,9 @@ EOF`
exit 1 exit 1
else else
retry=$((retry+1)) retry=$((retry+1))
logger "配置文件获取失败!"
echo -e "\033[32m尝试使用其他服务器获取配置\033[0m" echo -e "\033[32m尝试使用其他服务器获取配置\033[0m"
logger "正在试第$retry次/共5次" logger "正在试第$retry次/共5次"
sed -i '/server_link=*/'d $ccfg sed -i '/server_link=*/'d $ccfg
if [ "$server_link" -ge 5 ]; then if [ "$server_link" -ge 5 ]; then
server_link=0 server_link=0
@@ -150,6 +151,8 @@ EOF`
$clashdir/clash -t -d $clashdir $clashdir/clash -t -d $clashdir
echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ echo ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
exit 1 exit 1
else
logger "配置文件获取成功clash服务已启动" echooff
fi fi
fi fi
} }
@@ -234,6 +237,21 @@ start_redir(){
ip6tables -t nat -A PREROUTING -p tcp -j clashv6 ip6tables -t nat -A PREROUTING -p tcp -j clashv6
fi fi
} }
start_udp(){
ip rule add fwmark 1 table 100
ip route add local default dev lo table 100
iptables -t mangle -N clash
iptables -t mangle -A clash -d 0.0.0.0/8 -j RETURN
iptables -t mangle -A clash -d 10.0.0.0/8 -j RETURN
iptables -t mangle -A clash -d 127.0.0.0/8 -j RETURN
iptables -t mangle -A clash -d 169.254.0.0/16 -j RETURN
iptables -t mangle -A clash -d 172.16.0.0/12 -j RETURN
iptables -t mangle -A clash -d 192.168.0.0/16 -j RETURN
iptables -t mangle -A clash -d 224.0.0.0/4 -j RETURN
iptables -t mangle -A clash -d 240.0.0.0/4 -j RETURN
iptables -t mangle -A clash -p udp -j TPROXY --on-port $redir_port --tproxy-mark 1
iptables -t mangle -A PREROUTING -p udp -j clash
}
stop_iptables(){ stop_iptables(){
#重置iptables规则 #重置iptables规则
iptables -t nat -D PREROUTING -p tcp -j clash > /dev/null 2>&1 iptables -t nat -D PREROUTING -p tcp -j clash > /dev/null 2>&1
@@ -245,6 +263,10 @@ stop_iptables(){
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 iptables -D FORWARD -o utun -j ACCEPT > /dev/null 2>&1
#重置udp规则
iptables -t mangle -D PREROUTING -p udp -j clash > /dev/null 2>&1
iptables -t mangle -F clash > /dev/null 2>&1
iptables -t mangle -X clash > /dev/null 2>&1
#重置ipv6规则 #重置ipv6规则
ip6tables -t nat -D PREROUTING -p tcp -j clashv6 > /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 clashv6_dns > /dev/null 2>&1 ip6tables -t nat -D PREROUTING -p udp -j clashv6_dns > /dev/null 2>&1
@@ -356,6 +378,7 @@ afstart(){
#修改iptables规则使流量进入clash #修改iptables规则使流量进入clash
[ "$redir_mod" != "纯净模式" ] && [ "$dns_no" != "true" ] && start_dns [ "$redir_mod" != "纯净模式" ] && [ "$dns_no" != "true" ] && start_dns
[ "$redir_mod" != "纯净模式" ] && [ "$redir_mod" != "Tun模式" ] && start_redir [ "$redir_mod" != "纯净模式" ] && [ "$redir_mod" != "Tun模式" ] && start_redir
[ "$redir_mod" = "Redir模式" ] && [ "$tproxy_mod" = "已开启" ] && start_udp
#标记启动时间 #标记启动时间
mark_time mark_time
#设置本机代理 #设置本机代理