~增加流媒体预解析工具
~修复tun模式类型异常的bug
This commit is contained in:
juewuy
2022-01-15 16:22:26 +08:00
parent d2ac69c946
commit 6186730bbf
2 changed files with 129 additions and 7 deletions

View File

@@ -981,6 +981,82 @@ EOF
errornum errornum
fi 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(){ tools(){
ssh_tools(){ ssh_tools(){
[ -n "$(cat /etc/firewall.user 2>1 | grep '启用外网访问SSH服务')" ] && ssh_ol=禁止 || ssh_ol=开启 [ -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" [ -f "/etc/firewall.user" ] && echo -e " 2 \033[32m配置\033[0m外网访问SSH"
#echo -e " 3 配置DDNS服务: \033[36m$ipv6_support\033[0m ————待施工" #echo -e " 3 配置DDNS服务: \033[36m$ipv6_support\033[0m ————待施工"
[ -x /usr/sbin/otapredownload ] && echo -e " 3 \033[33m$mi_update\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 -----------------------------------------------
echo -e " 0 返回上级菜单 \033[0m" echo -e " 0 返回上级菜单 \033[0m"
echo ----------------------------------------------- echo -----------------------------------------------
@@ -1076,11 +1152,21 @@ tools(){
tools tools
elif [ "$num" = 4 ]; then elif [ "$num" = 4 ]; then
sed -i "s/drop_invalid\ \'1\'/drop_invalid\ \'0\'/g" /etc/config/firewall nslookup baidu.com > /dev/null 2>&1
echo ----------------------------------------------- if [ "$?" = 0 ];then
read -P "已修复,是否立即重启设备使其生效?(1/0) > " res checkcfg=$(cat $ccfg)
[ "$res" = 1 ] && reboot streaming
sleep 1 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 tools
else else

View File

@@ -29,6 +29,7 @@ getconfig(){
[ -z "$dns_redir" ] && dns_redir=未开启 [ -z "$dns_redir" ] && dns_redir=未开启
[ -z "$cn_ip_route" ] && cn_ip_route=未开启 [ -z "$cn_ip_route" ] && cn_ip_route=未开启
[ -z "$public_support" ] && public_support=未开启 [ -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_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'
[ -z "$multiport" ] && multiport='22,53,587,465,995,993,143,80,443,8080' [ -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 [ -d $clashdir/ui ] && db_ui=ui
if [ "$redir_mod" = "混合模式" -o "$redir_mod" = "Tun模式" ];then if [ "$redir_mod" = "混合模式" -o "$redir_mod" = "Tun模式" ];then
[ "$clashcore" = "clash.meta" ] && stack=gvisor || stack=system [ "$clashcore" = "clash.meta" ] && stack=gvisor || stack=system
tun='tun: {enable: true, stack: $stack}' tun="tun: {enable: true, stack: $stack}"
else else
tun='tun: {enable: false}' tun='tun: {enable: false}'
fi fi
@@ -715,6 +716,11 @@ afstart(){
[ "$local_proxy" = "已开启" ] && $0 set_proxy $mix_port $db_port [ "$local_proxy" = "已开启" ] && $0 set_proxy $mix_port $db_port
#加载定时任务 #加载定时任务
[ -f $clashdir/cron ] && croncmd $clashdir/cron [ -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 if [ "$restore" = false ];then
cronset '#每10分钟保存节点配置' "*/10 * * * * test -n \"\$(pidof clash)\" && $clashdir/start.sh web_save #每10分钟保存节点配置" 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
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 esac
exit 0 exit 0