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

View File

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