~适配singbox内核fakeip过滤功能

This commit is contained in:
juewuy
2024-02-05 12:19:26 +08:00
parent c79d89fb7a
commit db46408099
2 changed files with 31 additions and 25 deletions

View File

@@ -1300,9 +1300,10 @@ normal_set(){ #基础设置
echo -e " 6 设置本机代理服务: \033[36m$local_proxy\033[0m ————使本机流量经过ShellCrash内核"
echo -e " 7 屏蔽QUIC流量: \033[36m$quic_rj\033[0m ————优化视频性能"
[ "$disoverride" != "1" ] && {
[ "$dns_mod" = "fake-ip" -a "$crashcore" != "singbox" ] && \
echo -e " 8 管理Fake-ip过滤列表" || \
[ "$dns_mod" != "fake-ip" ] && \
echo -e " 8 CN_IP绕过内核: \033[36m$cn_ip_route\033[0m ————优化性能不兼容Fake-ip"
[ "$dns_mod" != "redir_host" ] && \
echo -e " 9 管理Fake-ip过滤列表"
}
echo -----------------------------------------------
echo -e " 0 返回上级菜单 \033[0m"
@@ -1396,33 +1397,31 @@ normal_set(){ #基础设置
echo -e "\033[33m当前模式默认不会代理UDP流量无需设置\033[0m"
fi
sleep 1
normal_set
normal_set
elif [ "$num" = 8 ]; then
echo -----------------------------------------------
if [ "$dns_mod" = "fake-ip" -a "$crashcore" != "singbox" ];then
fake_ip_filter
else
if [ -n "$(ipset -v 2>/dev/null)" -o -n "$(echo $redir_mod | grep Nft)" ];then
if [ "$cn_ip_route" = "未开启" ]; then
echo -e "\033[32m已开启CN_IP绕过内核功能\033[0m"
echo -e "\033[31m注意此功能会导致全局模式及一切CN相关规则失效\033[0m"
cn_ip_route=已开启
sleep 2
else
echo -e "\033[33m已禁用CN_IP绕过内核功能\033[0m"
cn_ip_route=未开启
fi
setconfig cn_ip_route $cn_ip_route
elif [ "$num" = 8 ]; then
if [ -n "$(ipset -v 2>/dev/null)" -o -n "$(echo $redir_mod | grep Nft)" ];then
if [ "$cn_ip_route" = "未开启" ]; then
echo -e "\033[32m已开启CN_IP绕过内核功能\033[0m"
echo -e "\033[31m注意此功能会导致全局模式及一切CN相关规则失效\033[0m"
cn_ip_route=已开启
sleep 2
else
echo -e "\033[31m当前设备缺少ipset模块或未使用Nft模式无法启用绕过功能!!\033[0m"
sleep 1
echo -e "\033[33m已禁用CN_IP绕过内核功能!!\033[0m"
cn_ip_route=未开启
fi
setconfig cn_ip_route $cn_ip_route
else
echo -e "\033[31m当前设备缺少ipset模块或未使用Nft模式无法启用绕过功能\033[0m"
sleep 1
fi
normal_set
normal_set
elif [ "$num" = 9 ]; then
echo -----------------------------------------------
fake_ip_filter
normal_set
elif [ "$num" = 9 ]; then
start_core
else
errornum
fi

View File

@@ -580,9 +580,15 @@ EOF
[ -z "$dns_proxy" ] && dns_proxy='1.0.0.1'
[ "$ipv6_dns" = "已开启" ] && strategy='prefer_ipv4' || strategy='ipv4_only'
[ "$dns_mod" = "redir_host" ] && final_dns=dns_direct && global_dns=dns_proxy
[ "$dns_mod" = "fake-ip" ] && final_dns=dns_fakeip && global_dns=dns_fakeip
[ "$dns_mod" = "fake-ip" ] && {
final_dns=dns_fakeip && global_dns=dns_fakeip
fake_ip_filter=$(cat ${CRASHDIR}/configs/fake_ip_filter ${CRASHDIR}/configs/fake_ip_filter.list 2>/dev/null | grep '\.' | awk '{printf "\"%s\", ",$1}' | sed "s/, $//" | sed 's/+/.+/g' | sed 's/*/.*/g')
[ -n "$fake_ip_filter" ] && fake_ip_filter="{ \"domain_regex\": [$fake_ip_filter], \"server\": \"local\" },"
}
[ "$dns_mod" = "mix" ] && {
final_dns=dns_direct && global_dns=dns_fakeip
fake_ip_filter=$(cat ${CRASHDIR}/configs/fake_ip_filter 2>/dev/null | grep '\.' | awk '{printf "\"%s\", ",$1}' | sed "s/, $//" | sed 's/+/.+/g' | sed 's/*/.*/g')
[ -n "$fake_ip_filter" ] && fake_ip_filter="{ \"domain_regex\": [$fake_ip_filter], \"server\": \"local\" },"
if [ -z "$(echo "$core_v" | grep -E '^1\.7.*')" ];then
mix_dns="{ \"rule_set\": [\"geosite-cn\"], \"invert\": true, \"server\": \"dns_fakeip\" },"
#生成add_rule_set.json
@@ -629,6 +635,7 @@ EOF
{ "outbound": ["any"], "server": "dns_resolver" },
{ "clash_mode": "Global", "server": "$global_dns" },
{ "clash_mode": "Direct", "server": "dns_direct" },
$fake_ip_filter
$mix_dns
{ "query_type": [ "A", "AAAA" ], "server": "$final_dns" }
],