feat(脚本): ipv6分流与任意门共存(出站)

pull/534/merge
mack-a 2021-06-15 16:27:56 +08:00
parent 0b0b6c4559
commit 2ae7f30f37
1 changed files with 183 additions and 86 deletions

View File

@ -1533,6 +1533,17 @@ EOF
"domainStrategy":"UseIPv4"
},
"tag":"IPv4-out"
},
{
"protocol":"freedom",
"settings":{
"domainStrategy":"UseIPv6"
},
"tag":"IPv6-out"
},
{
"protocol":"blackhole",
"tag":"blackhole-out"
}
]
}
@ -1872,6 +1883,17 @@ EOF
"domainStrategy":"UseIPv4"
},
"tag":"IPv4-out"
},
{
"protocol":"freedom",
"settings":{
"domainStrategy":"UseIPv6"
},
"tag":"IPv6-out"
},
{
"protocol":"blackhole",
"tag":"blackhole-out"
}
]
}
@ -3002,7 +3024,7 @@ checkIPv6() {
fi
}
# ipv6 人机验证
# ipv6 分流
ipv6Routing() {
if [[ -z "${configPath}" ]]; then
echoContent red " ---> 未安装,请使用脚本安装"
@ -3028,6 +3050,20 @@ ipv6Routing() {
echoContent yellow "6.录入示例:google,youtube,facebook\n"
read -r -p "请按照上面示例录入域名:" domainList
if [[ -f "${configPath}09_routing.json" ]];then
local routing=
if grep -q "IPv6-out" ${configPath}09_routing.json;then
local ipv6OutIndex=$(jq .routing.rules[].outboundTag ${configPath}09_routing.json|awk '{print ""NR""":"$0}'|grep "IPv6-out"|awk -F "[:]" '{print $1}'|head -1)
if [[ ${ipv6OutIndex} -gt 0 ]];then
routing=$(jq -r 'del(.routing.rules['$(expr ${ipv6OutIndex} - 1)'])' ${configPath}09_routing.json)
echo "${routing}" |jq . >${configPath}09_routing.json
fi
fi
routing=$(jq -r '.routing.rules += [{"type":"field","domain":["geosite:'${domainList//,/\",\"geosite:}'"],"outboundTag":"IPv6-out"}]' ${configPath}09_routing.json)
echo "${routing}"|jq . >${configPath}09_routing.json
else
cat <<EOF >${configPath}09_routing.json
{
"routing":{
@ -3044,6 +3080,7 @@ ipv6Routing() {
}
}
EOF
fi
cat <<EOF >${configPath}10_ipv4_outbounds.json
{
@ -3061,6 +3098,10 @@ EOF
"domainStrategy":"UseIPv6"
},
"tag":"IPv6-out"
},
{
"protocol":"blackhole",
"tag":"blackhole-out"
}
]
}
@ -3079,11 +3120,22 @@ EOF
"domainStrategy":"UseIPv4"
},
"tag":"IPv4-out"
},
{
"protocol":"freedom",
"settings":{
"domainStrategy":"UseIPv6"
},
"tag":"IPv6-out"
},
{
"protocol":"blackhole",
"tag":"blackhole-out"
}
]
}
EOF
echoContent green " ---> 人机验证卸载成功"
echoContent green " ---> IPv6分流卸载成功"
else
echoContent red " ---> 选择错误"
ipv6HumanVerification
@ -3155,6 +3207,17 @@ setDokodemoDoorUnblockNetflixOutbounds() {
},
"tag":"IPv4-out"
},
{
"protocol":"freedom",
"settings":{
"domainStrategy":"UseIPv6"
},
"tag":"IPv6-out"
},
{
"protocol":"blackhole",
"tag":"blackhole-out"
},
{
"tag":"netflix-80",
"protocol":"freedom",
@ -3174,6 +3237,21 @@ setDokodemoDoorUnblockNetflixOutbounds() {
]
}
EOF
if [[ -f "${configPath}09_routing.json" ]] ;then
local routing=
if grep -q "netflix-" ${configPath}09_routing.json;then
jq .routing.rules[].outboundTag ${configPath}09_routing.json|awk '{print ""NR""":"$0}'|grep "netflix-"|awk -F "[:]" '{print $1}'| while read -r index;do
local netflixIndex=$(jq .routing.rules[].outboundTag ${configPath}09_routing.json|awk '{print ""NR""":"$0}'|grep "netflix-"|awk -F "[:]" '{print $1}'|head -1)
if [[ ${netflixIndex} -gt 0 ]];then
routing=$(jq -r 'del(.routing.rules['$(expr ${netflixIndex} - 1)'])' ${configPath}09_routing.json)
echo "${routing}" |jq . >${configPath}09_routing.json
fi
done
fi
local routing=$(jq -r '.routing.rules += [{"type":"field","port":80,"domain":["ip.sb","geosite:netflix"],"outboundTag":"netflix-80"},{"type":"field","port":443,"domain":["ip.sb","geosite:netflix"],"outboundTag":"netflix-443"}]' ${configPath}09_routing.json)
echo "${routing}"|jq . >${configPath}09_routing.json
else
cat <<EOF >${configPath}09_routing.json
{
"routing": {
@ -3201,6 +3279,7 @@ EOF
}
}
EOF
fi
reloadCore
echoContent green " ---> 添加Netflix出战解锁成功"
echoContent yellow " ---> 不支持trojan的相关节点"
@ -3273,6 +3352,13 @@ EOF
},
"tag":"IPv4-out"
},
{
"protocol":"freedom",
"settings":{
"domainStrategy":"UseIPv6"
},
"tag":"IPv6-out"
},
{
"protocol":"blackhole",
"tag":"blackhole-out"
@ -3340,6 +3426,17 @@ removeDokodemoDoorUnblockNetflix() {
"domainStrategy":"UseIPv4"
},
"tag":"IPv4-out"
},
{
"protocol":"freedom",
"settings":{
"domainStrategy":"UseIPv6"
},
"tag":"IPv6-out"
},
{
"protocol":"blackhole",
"tag":"blackhole-out"
}
]
}
@ -3799,7 +3896,7 @@ menu() {
cd "$HOME" || exit
echoContent red "\n=============================================================="
echoContent green "作者mack-a"
echoContent green "当前版本v2.4.45"
echoContent green "当前版本v2.5.1"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c"
showInstallStatus