From 6186730bbf103e4d5b2fcfcb1d7ad44ff0b5db2d Mon Sep 17 00:00:00 2001 From: juewuy Date: Sat, 15 Jan 2022 16:22:26 +0800 Subject: [PATCH] =?UTF-8?q?v1.4.11=20~=E5=A2=9E=E5=8A=A0=E6=B5=81=E5=AA=92?= =?UTF-8?q?=E4=BD=93=E9=A2=84=E8=A7=A3=E6=9E=90=E5=B7=A5=E5=85=B7=20~?= =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtun=E6=A8=A1=E5=BC=8F=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/clash.sh | 98 +++++++++++++++++++++++++++++++++++++++++++++--- scripts/start.sh | 38 ++++++++++++++++++- 2 files changed, 129 insertions(+), 7 deletions(-) diff --git a/scripts/clash.sh b/scripts/clash.sh index a614bb7..07199cc 100644 --- a/scripts/clash.sh +++ b/scripts/clash.sh @@ -981,6 +981,82 @@ EOF errornum fi } +streaming(){ + [ -z "$netflix_pre" ] && netflix_pre=未开启 + [ -z "$disneyP_pre" ] && disneyP_pre=未开启 + [ -z "$streaming_int" ] && streaming_int=24 + netflix_dir=$clashdir/streaming/Netflix_Domains.list + disneyp_dir=$clashdir/streaming/Disney_Plus_Domains.list + #### + echo -e "\033[30;46m欢迎使用流媒体预解析功能:\033[0m" + echo -e "\033[33m感谢OpenClash项目提供相关域名数据库!\033[0m" + echo -e "\033[31m修改后需重启服务!\033[0m" + echo ----------------------------------------------- + echo -e " 1 预解析\033[36mNetflix域名 \033[33m$netflix_pre\033[0m" + echo -e " 2 预解析\033[36mDisney+域名 \033[33m$disneyP_pre\033[0m" + echo -e " 3 设置预解析间隔 \033[32m$streaming_int小时\033[0m" + echo -e " 4 更新本地\033[32m域名数据库\033[0m" + echo -e " 0 返回上级菜单" + echo ----------------------------------------------- + read -p "请输入对应数字 > " num + if [ -z "$num" ]; then + errornum + elif [ "$num" = 0 ]; then + i= + elif [ "$num" = 1 ]; then + echo ----------------------------------------------- + if [ "$netflix_pre" = "未开启" ] > /dev/null 2>&1; then + echo -e "\033[33m已启用Netflix域名预解析功能!!\033[0m" + netflix_pre=已开启 + sleep 1 + else + echo -e "\033[31m已停用Netflix域名预解析功能!!\033[0m" + [ -f "$netflix_dir" ] && rm -rf $netflix_dir + netflix_pre=未开启 + fi + setconfig netflix_pre $netflix_pre + sleep 1 + streaming + elif [ "$num" = 2 ]; then + echo ----------------------------------------------- + if [ "$disneyP_pre" = "未开启" ] > /dev/null 2>&1; then + echo -e "\033[33m已启用Disney+域名预解析功能!!\033[0m" + disneyP_pre=已开启 + sleep 1 + else + echo -e "\033[31m已停用Disney+域名预解析功能!!\033[0m" + [ -f "$disneyp_dir" ] && rm -rf $disneyp_dir + disneyP_pre=未开启 + fi + setconfig disneyP_pre $disneyP_pre + sleep 1 + streaming + elif [ "$num" = 3 ]; then + echo ----------------------------------------------- + read -p "请输入刷新间隔(1-24小时,不支持小数) > " num + if [ -z "$num" ]; then + errornum + elif [ $num -gt 24 ] || [ $num -lt 1 ]; then + errornum + else + streaming_int=$num + setconfig streaming_int $streaming_int + echo -e "\033[32m设置成功!!!\033[0m" + fi + sleep 1 + streaming + elif [ "$num" = 4 ]; then + [ -f "$netflix_dir" ] && rm -rf $netflix_dir + [ -f "$disneyp_dir" ] && rm -rf $disneyp_dir + echo ----------------------------------------------- + echo -e "\033[32m本地文件已清理,将在下次刷新时自动更新数据库文件!!!\033[0m" + sleep 1 + streaming + else + errornum + streaming + fi +} tools(){ ssh_tools(){ [ -n "$(cat /etc/firewall.user 2>1 | grep '启用外网访问SSH服务')" ] && ssh_ol=禁止 || ssh_ol=开启 @@ -1050,7 +1126,7 @@ tools(){ [ -f "/etc/firewall.user" ] && echo -e " 2 \033[32m配置\033[0m外网访问SSH" #echo -e " 3 配置DDNS服务: \033[36m$ipv6_support\033[0m ————待施工" [ -x /usr/sbin/otapredownload ] && echo -e " 3 \033[33m$mi_update\033[0m小米系统自动更新" - #[ -w "/etc/config/firewall" ] && echo -e " 4 \033[32修复\033[0mRedir_host模式Netflix访问" + echo -e " 4 \033[32m流媒体预解析\033[0m————用于解决DNS解锁在TV应用上失效的问题" echo ----------------------------------------------- echo -e " 0 返回上级菜单 \033[0m" echo ----------------------------------------------- @@ -1076,11 +1152,21 @@ tools(){ tools elif [ "$num" = 4 ]; then - sed -i "s/drop_invalid\ \'1\'/drop_invalid\ \'0\'/g" /etc/config/firewall - echo ----------------------------------------------- - read -P "已修复,是否立即重启设备使其生效?(1/0) > " res - [ "$res" = 1 ] && reboot - sleep 1 + nslookup baidu.com > /dev/null 2>&1 + if [ "$?" = 0 ];then + checkcfg=$(cat $ccfg) + streaming + if [ -n "$PID" ];then + checkcfg_new=$(cat $ccfg) + [ "$checkcfg" != "$checkcfg_new" ] && checkrestart + fi + else + echo ----------------------------------------------- + echo "当前设备缺少nslookup命令,无法启用全媒体预解析功能!" + echo "Centos请尝试使用以下命令安装【yum -y install bind-utils】" + echo "Debian/Ubuntu等请尝试使用【sudo apt-get install dnsutils -y】" + sleep 1 + fi tools else diff --git a/scripts/start.sh b/scripts/start.sh index 642a4a1..fffb277 100644 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -29,6 +29,7 @@ getconfig(){ [ -z "$dns_redir" ] && dns_redir=未开启 [ -z "$cn_ip_route" ] && cn_ip_route=未开启 [ -z "$public_support" ] && public_support=未开启 + [ -z "$stearming_int" ] && stearming_int=24 [ -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 "$multiport" ] && multiport='22,53,587,465,995,993,143,80,443,8080' @@ -228,7 +229,7 @@ modify_yaml(){ [ -d $clashdir/ui ] && db_ui=ui if [ "$redir_mod" = "混合模式" -o "$redir_mod" = "Tun模式" ];then [ "$clashcore" = "clash.meta" ] && stack=gvisor || stack=system - tun='tun: {enable: true, stack: $stack}' + tun="tun: {enable: true, stack: $stack}" else tun='tun: {enable: false}' fi @@ -715,6 +716,11 @@ afstart(){ [ "$local_proxy" = "已开启" ] && $0 set_proxy $mix_port $db_port #加载定时任务 [ -f $clashdir/cron ] && croncmd $clashdir/cron + #流媒体预解析 + if [ "$netflix_pre" = "已开启" -o "$disneyp_pre" = "已开启" ];then + cronset '#ShellClash流媒体预解析' "* */$stearming_int * * * $clashdir/start.sh steaming #ShellClash流媒体预解析" + $0 steaming & #后台执行流媒体预解析进程 + fi #启用面板配置自动保存 if [ "$restore" = false ];then cronset '#每10分钟保存节点配置' "*/10 * * * * test -n \"\$(pidof clash)\" && $clashdir/start.sh web_save #每10分钟保存节点配置" @@ -872,6 +878,36 @@ unset_proxy) sed -i '/all_proxy/'d $profile sed -i '/ALL_PROXY/'d $profile ;; +steaming) + #设置循环检测clashDNS端口 + i=1 + while [ $i -lt 10 ];do + sleep 1 + nslookup baidu.com 127.0.0.1:${dns_port} > /dev/null 2>&1 + [ "$?" = 0 ] && i=10 + done + getconfig + steaming_dns(){ + steaming_dir=$clashdir/steaming/${steaming_type}_Domains.list + if [ ! -f "$steaming_dir" ];then + echo 未找到$steaming_type域名数据库,正在下载! + mkdir -p $clashdir/steaming + $0 webget "$steaming_dir" "$update_url/bin/${steaming_type}_Domains.list" + [ "$?" = "1" ] && logger "$steaming_type数据库文件下载失败" + fi + if [ -f "$steaming_dir" ];then + for line in $(cat $steaming_dir);do + [ -n "$line" ] && nslookup "$line" 127.0.0.1:${dns_port} + done >/dev/null 2>&1 + echo "$steaming_type域名预解析完成!" + fi + } + echo + echo "正在后台进行流媒体预解析服务,请耐心等待!" + [ "$netflix_pre" = "已开启" ] && steaming_type=Netflix && steaming_dns + [ "$disneyP_pre" = "已开启" ] && steaming_type=Disney_Plus && steaming_dns + echo "请输入回车继续!" + ;; esac exit 0