mirror of https://github.com/mack-a/v2ray-agent
feat(脚本): 添加warp、IPv6 sing-box全局分流
parent
6f3400168f
commit
b38261f8e4
198
install.sh
198
install.sh
|
@ -3245,11 +3245,25 @@ removeSingBoxRouteRule() {
|
||||||
addSingBoxOutbound() {
|
addSingBoxOutbound() {
|
||||||
local tag=$1
|
local tag=$1
|
||||||
local type="ipv4"
|
local type="ipv4"
|
||||||
|
local detour=$2
|
||||||
if echo "${tag}" | grep -q "IPv6"; then
|
if echo "${tag}" | grep -q "IPv6"; then
|
||||||
type=ipv6
|
type=ipv6
|
||||||
fi
|
fi
|
||||||
|
if [[ -n "${detour}" ]]; then
|
||||||
cat <<EOF >"${singBoxConfigPath}config/${tag}.json"
|
cat <<EOF >"${singBoxConfigPath}config/${tag}.json"
|
||||||
|
{
|
||||||
|
"outbounds": [
|
||||||
|
{
|
||||||
|
"type": "direct",
|
||||||
|
"tag": "${tag}",
|
||||||
|
"detour": "${detour}",
|
||||||
|
"domain_strategy": "${type}_only"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat <<EOF >"${singBoxConfigPath}config/${tag}.json"
|
||||||
{
|
{
|
||||||
"outbounds": [
|
"outbounds": [
|
||||||
{
|
{
|
||||||
|
@ -3260,30 +3274,28 @@ addSingBoxOutbound() {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 移除sing-box出站
|
||||||
|
removeSingBoxOutbound() {
|
||||||
|
|
||||||
|
local tag=$1
|
||||||
|
if [[ -f "${singBoxConfigPath}config/${tag}.json" ]]; then
|
||||||
|
rm "${singBoxConfigPath}config/${tag}.json"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
# 初始化wireguard出站信息
|
# 初始化wireguard出站信息
|
||||||
addSingBoxWireGuardOut() {
|
addSingBoxWireGuardOut() {
|
||||||
readConfigWarpReg
|
readConfigWarpReg
|
||||||
|
|
||||||
cat <<EOF >"${singBoxConfigPath}config/wireguard_outbound.json"
|
cat <<EOF >"${singBoxConfigPath}config/wireguard_outbound.json"
|
||||||
{
|
{
|
||||||
"outbounds": [
|
"outbounds": [
|
||||||
{
|
|
||||||
"type": "direct",
|
|
||||||
"tag": "wireguard-out-IPv4",
|
|
||||||
"detour": "wireguard-out",
|
|
||||||
"domain_strategy": "ipv4_only"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "direct",
|
|
||||||
"tag": "wireguard-out-IPv6",
|
|
||||||
"detour": "wireguard-out",
|
|
||||||
"domain_strategy": "ipv6_only"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "wireguard",
|
"type": "wireguard",
|
||||||
"tag": "wireguard-out",
|
"tag": "wireguard_out",
|
||||||
"server": "162.159.192.1",
|
"server": "162.159.192.1",
|
||||||
"server_port": 2408,
|
"server_port": 2408,
|
||||||
"local_address": [
|
"local_address": [
|
||||||
|
@ -3485,18 +3497,18 @@ EOF
|
||||||
"settings":{
|
"settings":{
|
||||||
"domainStrategy":"UseIPv4"
|
"domainStrategy":"UseIPv4"
|
||||||
},
|
},
|
||||||
"tag":"IPv4-out"
|
"tag":"IPv4_out"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"protocol":"freedom",
|
"protocol":"freedom",
|
||||||
"settings":{
|
"settings":{
|
||||||
"domainStrategy":"UseIPv6"
|
"domainStrategy":"UseIPv6"
|
||||||
},
|
},
|
||||||
"tag":"IPv6-out"
|
"tag":"IPv6_out"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"protocol":"blackhole",
|
"protocol":"blackhole",
|
||||||
"tag":"blackhole-out"
|
"tag":"blackhole_out"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -3933,14 +3945,14 @@ EOF
|
||||||
"settings":{
|
"settings":{
|
||||||
"domainStrategy":"UseIPv4"
|
"domainStrategy":"UseIPv4"
|
||||||
},
|
},
|
||||||
"tag":"IPv4-out"
|
"tag":"IPv4_out"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"protocol":"freedom",
|
"protocol":"freedom",
|
||||||
"settings":{
|
"settings":{
|
||||||
"domainStrategy":"UseIPv6"
|
"domainStrategy":"UseIPv6"
|
||||||
},
|
},
|
||||||
"tag":"IPv6-out"
|
"tag":"IPv6_out"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"protocol":"freedom",
|
"protocol":"freedom",
|
||||||
|
@ -3949,7 +3961,7 @@ EOF
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"protocol":"blackhole",
|
"protocol":"blackhole",
|
||||||
"tag":"blackhole-out"
|
"tag":"blackhole_out"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -5747,7 +5759,7 @@ ipv6Routing() {
|
||||||
read -r -p "请选择:" ipv6Status
|
read -r -p "请选择:" ipv6Status
|
||||||
if [[ "${ipv6Status}" == "1" ]]; then
|
if [[ "${ipv6Status}" == "1" ]]; then
|
||||||
|
|
||||||
jq -r -c '.routing.rules[]|select (.outboundTag=="IPv6-out")|.domain' ${configPath}09_routing.json | jq -r
|
jq -r -c '.routing.rules[]|select (.outboundTag=="IPv6_out")|.domain' ${configPath}09_routing.json | jq -r
|
||||||
exit 0
|
exit 0
|
||||||
elif [[ "${ipv6Status}" == "2" ]]; then
|
elif [[ "${ipv6Status}" == "2" ]]; then
|
||||||
echoContent red "=============================================================="
|
echoContent red "=============================================================="
|
||||||
|
@ -5756,21 +5768,21 @@ ipv6Routing() {
|
||||||
echoContent yellow "# 使用教程:https://www.v2ray-agent.com/archives/ba-he-yi-jiao-ben-yu-ming-fen-liu-jiao-cheng \n"
|
echoContent yellow "# 使用教程:https://www.v2ray-agent.com/archives/ba-he-yi-jiao-ben-yu-ming-fen-liu-jiao-cheng \n"
|
||||||
|
|
||||||
read -r -p "请按照上面示例录入域名:" domainList
|
read -r -p "请按照上面示例录入域名:" domainList
|
||||||
addInstallRouting IPv6-out outboundTag "${domainList}"
|
addInstallRouting IPv6_out outboundTag "${domainList}"
|
||||||
|
|
||||||
unInstallOutbounds IPv6-out
|
unInstallOutbounds IPv6_out
|
||||||
|
|
||||||
outbounds=$(jq -r '.outbounds += [{"protocol":"freedom","settings":{"domainStrategy":"UseIPv6"},"tag":"IPv6-out"}]' ${configPath}10_ipv4_outbounds.json)
|
outbounds=$(jq -r '.outbounds += [{"protocol":"freedom","settings":{"domainStrategy":"UseIPv6"},"tag":"IPv6_out"}]' ${configPath}10_ipv4_outbounds.json)
|
||||||
|
|
||||||
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
||||||
|
|
||||||
configurationSingBoxRoute add IPv6-out "${domainList}"
|
configurationSingBoxRoute add IPv6_out "${domainList}"
|
||||||
addSingBoxOutbound IPv6-out
|
addSingBoxOutbound IPv6_out
|
||||||
|
addSingBoxOutbound IPv4_out
|
||||||
echoContent green " ---> 添加成功"
|
echoContent green " ---> 添加成功"
|
||||||
|
|
||||||
elif [[ "${ipv6Status}" == "3" ]]; then
|
elif [[ "${ipv6Status}" == "3" ]]; then
|
||||||
echoContent green " ---> 不可用"
|
|
||||||
exit 0
|
|
||||||
echoContent red "=============================================================="
|
echoContent red "=============================================================="
|
||||||
echoContent yellow "# 注意事项\n"
|
echoContent yellow "# 注意事项\n"
|
||||||
echoContent yellow "1.会删除设置的所有分流规则"
|
echoContent yellow "1.会删除设置的所有分流规则"
|
||||||
|
@ -5786,13 +5798,22 @@ ipv6Routing() {
|
||||||
"settings":{
|
"settings":{
|
||||||
"domainStrategy":"UseIPv6"
|
"domainStrategy":"UseIPv6"
|
||||||
},
|
},
|
||||||
"tag":"IPv6-out"
|
"tag":"IPv6_out"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
rm ${configPath}09_routing.json >/dev/null 2>&1
|
rm ${configPath}09_routing.json >/dev/null 2>&1
|
||||||
echoContent green " ---> IPv6全局出站设置成功"
|
echoContent green " ---> IPv6全局出站设置成功"
|
||||||
|
|
||||||
|
configurationSingBoxRoute delete wireguard_out_IPv4
|
||||||
|
configurationSingBoxRoute delete wireguard_out_IPv6
|
||||||
|
removeSingBoxOutbound IPv4_out
|
||||||
|
removeSingBoxOutbound wireguard_out_IPv4
|
||||||
|
removeSingBoxOutbound wireguard_outbound
|
||||||
|
|
||||||
|
addSingBoxOutbound IPv6_out
|
||||||
|
|
||||||
else
|
else
|
||||||
echoContent green " ---> 放弃设置"
|
echoContent green " ---> 放弃设置"
|
||||||
exit 0
|
exit 0
|
||||||
|
@ -5800,14 +5821,14 @@ EOF
|
||||||
|
|
||||||
elif [[ "${ipv6Status}" == "4" ]]; then
|
elif [[ "${ipv6Status}" == "4" ]]; then
|
||||||
|
|
||||||
unInstallRouting IPv6-out outboundTag
|
unInstallRouting IPv6_out outboundTag
|
||||||
|
|
||||||
unInstallOutbounds IPv6-out
|
unInstallOutbounds IPv6_out
|
||||||
|
|
||||||
configurationSingBoxRoute delete IPv6-out
|
configurationSingBoxRoute delete IPv6_out
|
||||||
|
|
||||||
if ! grep -q "IPv4-out" <"${configPath}10_ipv4_outbounds.json"; then
|
if ! grep -q "IPv4_out" <"${configPath}10_ipv4_outbounds.json"; then
|
||||||
outbounds=$(jq -r '.outbounds += [{"protocol":"freedom","settings": {"domainStrategy": "UseIPv4"},"tag":"IPv4-out"}]' ${configPath}10_ipv4_outbounds.json)
|
outbounds=$(jq -r '.outbounds += [{"protocol":"freedom","settings": {"domainStrategy": "UseIPv4"},"tag":"IPv4_out"}]' ${configPath}10_ipv4_outbounds.json)
|
||||||
|
|
||||||
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
||||||
fi
|
fi
|
||||||
|
@ -5845,9 +5866,9 @@ btTools() {
|
||||||
|
|
||||||
if [[ -f "${configPath}09_routing.json" ]]; then
|
if [[ -f "${configPath}09_routing.json" ]]; then
|
||||||
|
|
||||||
unInstallRouting blackhole-out outboundTag
|
unInstallRouting blackhole_out outboundTag
|
||||||
|
|
||||||
routing=$(jq -r '.routing.rules += [{"type":"field","outboundTag":"blackhole-out","protocol":["bittorrent"]}]' ${configPath}09_routing.json)
|
routing=$(jq -r '.routing.rules += [{"type":"field","outboundTag":"blackhole_out","protocol":["bittorrent"]}]' ${configPath}09_routing.json)
|
||||||
|
|
||||||
echo "${routing}" | jq . >${configPath}09_routing.json
|
echo "${routing}" | jq . >${configPath}09_routing.json
|
||||||
|
|
||||||
|
@ -5859,7 +5880,7 @@ btTools() {
|
||||||
"rules": [
|
"rules": [
|
||||||
{
|
{
|
||||||
"type": "field",
|
"type": "field",
|
||||||
"outboundTag": "blackhole-out",
|
"outboundTag": "blackhole_out",
|
||||||
"protocol": [ "bittorrent" ]
|
"protocol": [ "bittorrent" ]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -5870,9 +5891,9 @@ EOF
|
||||||
|
|
||||||
installSniffing
|
installSniffing
|
||||||
|
|
||||||
unInstallOutbounds blackhole-out
|
unInstallOutbounds blackhole_out
|
||||||
|
|
||||||
outbounds=$(jq -r '.outbounds += [{"protocol":"blackhole","tag":"blackhole-out"}]' ${configPath}10_ipv4_outbounds.json)
|
outbounds=$(jq -r '.outbounds += [{"protocol":"blackhole","tag":"blackhole_out"}]' ${configPath}10_ipv4_outbounds.json)
|
||||||
|
|
||||||
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
||||||
|
|
||||||
|
@ -5882,9 +5903,9 @@ EOF
|
||||||
|
|
||||||
unInstallSniffing
|
unInstallSniffing
|
||||||
|
|
||||||
unInstallRouting blackhole-out outboundTag bittorrent
|
unInstallRouting blackhole_out outboundTag bittorrent
|
||||||
|
|
||||||
# unInstallOutbounds blackhole-out
|
# unInstallOutbounds blackhole_out
|
||||||
|
|
||||||
echoContent green " ---> BT下载打开成功"
|
echoContent green " ---> BT下载打开成功"
|
||||||
else
|
else
|
||||||
|
@ -5913,7 +5934,7 @@ blacklist() {
|
||||||
|
|
||||||
read -r -p "请选择:" blacklistStatus
|
read -r -p "请选择:" blacklistStatus
|
||||||
if [[ "${blacklistStatus}" == "1" ]]; then
|
if [[ "${blacklistStatus}" == "1" ]]; then
|
||||||
jq -r -c '.routing.rules[]|select (.outboundTag=="blackhole-out")|.domain' ${configPath}09_routing.json | jq -r
|
jq -r -c '.routing.rules[]|select (.outboundTag=="blackhole_out")|.domain' ${configPath}09_routing.json | jq -r
|
||||||
exit 0
|
exit 0
|
||||||
elif [[ "${blacklistStatus}" == "2" ]]; then
|
elif [[ "${blacklistStatus}" == "2" ]]; then
|
||||||
echoContent red "=============================================================="
|
echoContent red "=============================================================="
|
||||||
|
@ -5926,22 +5947,22 @@ blacklist() {
|
||||||
read -r -p "请按照上面示例录入域名:" domainList
|
read -r -p "请按照上面示例录入域名:" domainList
|
||||||
|
|
||||||
if [[ -f "${configPath}09_routing.json" ]]; then
|
if [[ -f "${configPath}09_routing.json" ]]; then
|
||||||
addInstallRouting blackhole-out outboundTag "${domainList}"
|
addInstallRouting blackhole_out outboundTag "${domainList}"
|
||||||
fi
|
fi
|
||||||
unInstallOutbounds blackhole-out
|
unInstallOutbounds blackhole_out
|
||||||
|
|
||||||
outbounds=$(jq -r '.outbounds += [{"protocol":"blackhole","tag":"blackhole-out"}]' ${configPath}10_ipv4_outbounds.json)
|
outbounds=$(jq -r '.outbounds += [{"protocol":"blackhole","tag":"blackhole_out"}]' ${configPath}10_ipv4_outbounds.json)
|
||||||
|
|
||||||
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
||||||
|
|
||||||
echoContent green " ---> 添加成功"
|
echoContent green " ---> 添加成功"
|
||||||
|
|
||||||
elif [[ "${blacklistStatus}" == "3" ]]; then
|
elif [[ "${blacklistStatus}" == "3" ]]; then
|
||||||
addInstallRouting blackhole-out outboundTag "cn"
|
addInstallRouting blackhole_out outboundTag "cn"
|
||||||
|
|
||||||
unInstallOutbounds blackhole-out
|
unInstallOutbounds blackhole_out
|
||||||
|
|
||||||
outbounds=$(jq -r '.outbounds += [{"protocol":"blackhole","tag":"blackhole-out"}]' ${configPath}10_ipv4_outbounds.json)
|
outbounds=$(jq -r '.outbounds += [{"protocol":"blackhole","tag":"blackhole_out"}]' ${configPath}10_ipv4_outbounds.json)
|
||||||
|
|
||||||
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
||||||
|
|
||||||
|
@ -5949,7 +5970,7 @@ blacklist() {
|
||||||
|
|
||||||
elif [[ "${blacklistStatus}" == "4" ]]; then
|
elif [[ "${blacklistStatus}" == "4" ]]; then
|
||||||
|
|
||||||
unInstallRouting blackhole-out outboundTag
|
unInstallRouting blackhole_out outboundTag
|
||||||
|
|
||||||
echoContent green " ---> 域名黑名单删除成功"
|
echoContent green " ---> 域名黑名单删除成功"
|
||||||
else
|
else
|
||||||
|
@ -6016,7 +6037,7 @@ EOF
|
||||||
done < <(echo "${domain}" | tr ',' '\n')
|
done < <(echo "${domain}" | tr ',' '\n')
|
||||||
|
|
||||||
unInstallRouting "${tag}" "${type}"
|
unInstallRouting "${tag}" "${type}"
|
||||||
if ! grep -q "gstatic.com" ${configPath}09_routing.json && [[ "${tag}" == "blackhole-out" ]]; then
|
if ! grep -q "gstatic.com" ${configPath}09_routing.json && [[ "${tag}" == "blackhole_out" ]]; then
|
||||||
local routing=
|
local routing=
|
||||||
routing=$(jq -r ".routing.rules += [{\"type\": \"field\",\"domain\": [\"gstatic.com\"],\"outboundTag\": \"direct\"}]" ${configPath}09_routing.json)
|
routing=$(jq -r ".routing.rules += [{\"type\": \"field\",\"domain\": [\"gstatic.com\"],\"outboundTag\": \"direct\"}]" ${configPath}09_routing.json)
|
||||||
echo "${routing}" | jq . >${configPath}09_routing.json
|
echo "${routing}" | jq . >${configPath}09_routing.json
|
||||||
|
@ -6181,8 +6202,8 @@ EOF
|
||||||
|
|
||||||
unInstallOutbounds warp-socks-out
|
unInstallOutbounds warp-socks-out
|
||||||
|
|
||||||
if ! grep -q "IPv4-out" <"${configPath}10_ipv4_outbounds.json"; then
|
if ! grep -q "IPv4_out" <"${configPath}10_ipv4_outbounds.json"; then
|
||||||
outbounds=$(jq -r '.outbounds += [{"protocol":"freedom","settings": {"domainStrategy": "UseIPv4"},"tag":"IPv4-out"}]' ${configPath}10_ipv4_outbounds.json)
|
outbounds=$(jq -r '.outbounds += [{"protocol":"freedom","settings": {"domainStrategy": "UseIPv4"},"tag":"IPv4_out"}]' ${configPath}10_ipv4_outbounds.json)
|
||||||
|
|
||||||
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
||||||
fi
|
fi
|
||||||
|
@ -6236,7 +6257,7 @@ installWarpReg() {
|
||||||
showWireGuardDomain() {
|
showWireGuardDomain() {
|
||||||
# todo
|
# todo
|
||||||
# xray
|
# xray
|
||||||
jq -r -c '.routing.rules[]|select (.outboundTag=="wireguard-out-'"${type}"'")|.domain' ${configPath}09_routing.json | jq -r
|
jq -r -c '.routing.rules[]|select (.outboundTag=="wireguard_out_'"${type}"'")|.domain' ${configPath}09_routing.json | jq -r
|
||||||
# sing-box
|
# sing-box
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6248,10 +6269,10 @@ addWireGuardRoute() {
|
||||||
# xray
|
# xray
|
||||||
if [[ -n "${configPath}" ]]; then
|
if [[ -n "${configPath}" ]]; then
|
||||||
|
|
||||||
addInstallRouting wireguard-out-"${type}" "${tag}" "${domainList}"
|
addInstallRouting wireguard_out_"${type}" "${tag}" "${domainList}"
|
||||||
unInstallOutbounds wireguard-out-"${type}"
|
unInstallOutbounds wireguard_out_"${type}"
|
||||||
local outbounds
|
local outbounds
|
||||||
outbounds=$(jq -r '.outbounds += [{"protocol":"wireguard","settings":{"secretKey":"'"${secretKeyWarpReg}"'","address":["'"${address}"'"],"peers":[{"publicKey":"'"${publicKeyWarpReg}"'","allowedIPs":["0.0.0.0/0","::/0"],"endpoint":"162.159.192.1:2408"}],"reserved":'"${reservedWarpReg}"',"mtu":1280},"tag":"wireguard-out-'"${type}"'"}]' ${configPath}10_ipv4_outbounds.json)
|
outbounds=$(jq -r '.outbounds += [{"protocol":"wireguard","settings":{"secretKey":"'"${secretKeyWarpReg}"'","address":["'"${address}"'"],"peers":[{"publicKey":"'"${publicKeyWarpReg}"'","allowedIPs":["0.0.0.0/0","::/0"],"endpoint":"162.159.192.1:2408"}],"reserved":'"${reservedWarpReg}"',"mtu":1280},"tag":"wireguard_out_'"${type}"'"}]' ${configPath}10_ipv4_outbounds.json)
|
||||||
|
|
||||||
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
||||||
fi
|
fi
|
||||||
|
@ -6259,7 +6280,8 @@ addWireGuardRoute() {
|
||||||
if [[ -n "${singBoxConfigPath}" ]]; then
|
if [[ -n "${singBoxConfigPath}" ]]; then
|
||||||
|
|
||||||
# rule
|
# rule
|
||||||
addSingBoxRouteRule "wireguard-out-${type}" "${domainList}"
|
addSingBoxRouteRule "wireguard_out_${type}" "${domainList}"
|
||||||
|
addSingBoxOutbound "wireguard_out_${type}" "wireguard_out"
|
||||||
# outbound
|
# outbound
|
||||||
addSingBoxWireGuardOut
|
addSingBoxWireGuardOut
|
||||||
fi
|
fi
|
||||||
|
@ -6271,18 +6293,18 @@ unInstallWireGuard() {
|
||||||
if [[ -n "${configPath}" ]]; then
|
if [[ -n "${configPath}" ]]; then
|
||||||
|
|
||||||
if [[ "${type}" == "IPv4" ]]; then
|
if [[ "${type}" == "IPv4" ]]; then
|
||||||
if ! grep -q "wireguard-out-IPv6" <${configPath}10_ipv4_outbounds.json; then
|
if ! grep -q "wireguard_out_IPv6" <${configPath}10_ipv4_outbounds.json; then
|
||||||
rm -rf /etc/v2ray-agent/warp/config >/dev/null 2>&1
|
rm -rf /etc/v2ray-agent/warp/config >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
elif [[ "${type}" == "IPv6" ]]; then
|
elif [[ "${type}" == "IPv6" ]]; then
|
||||||
if ! grep -q "wireguard-out-IPv4" <${configPath}10_ipv4_outbounds.json; then
|
if ! grep -q "wireguard_out_IPv4" <${configPath}10_ipv4_outbounds.json; then
|
||||||
rm -rf /etc/v2ray-agent/warp/config >/dev/null 2>&1
|
rm -rf /etc/v2ray-agent/warp/config >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${singBoxConfigPath}" ]]; then
|
if [[ -n "${singBoxConfigPath}" ]]; then
|
||||||
if [[ ! -f "${singBoxConfigPath}config/wireguard-out-IPv6_route.json" && ! -f "${singBoxConfigPath}config/wireguard-out-IPv4_route.json" ]]; then
|
if [[ ! -f "${singBoxConfigPath}config/wireguard_out_IPv6_route.json" && ! -f "${singBoxConfigPath}config/wireguard_out_IPv4_route.json" ]]; then
|
||||||
rm ${singBoxConfigPath}config/wireguard_outbound.json >/dev/null 2>&1
|
rm ${singBoxConfigPath}config/wireguard_outbound.json >/dev/null 2>&1
|
||||||
rm -rf /etc/v2ray-agent/warp/config >/dev/null 2>&1
|
rm -rf /etc/v2ray-agent/warp/config >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
@ -6295,11 +6317,11 @@ removeWireGuardRoute() {
|
||||||
# xray
|
# xray
|
||||||
if [[ -n "${configPath}" ]]; then
|
if [[ -n "${configPath}" ]]; then
|
||||||
|
|
||||||
unInstallRouting wireguard-out-"${type}" outboundTag
|
unInstallRouting wireguard_out_"${type}" outboundTag
|
||||||
|
|
||||||
unInstallOutbounds wireguard-out-"${type}"
|
unInstallOutbounds wireguard_out_"${type}"
|
||||||
|
|
||||||
if ! grep -q "IPv4-out" <"${configPath}10_ipv4_outbounds.json"; then
|
if ! grep -q "IPv4_out" <"${configPath}10_ipv4_outbounds.json"; then
|
||||||
|
|
||||||
cat <<EOF >${configPath}10_ipv4_outbounds.json
|
cat <<EOF >${configPath}10_ipv4_outbounds.json
|
||||||
{
|
{
|
||||||
|
@ -6309,18 +6331,18 @@ removeWireGuardRoute() {
|
||||||
"settings":{
|
"settings":{
|
||||||
"domainStrategy":"UseIPv4"
|
"domainStrategy":"UseIPv4"
|
||||||
},
|
},
|
||||||
"tag":"IPv4-out"
|
"tag":"IPv4_out"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"protocol":"freedom",
|
"protocol":"freedom",
|
||||||
"settings":{
|
"settings":{
|
||||||
"domainStrategy":"UseIPv6"
|
"domainStrategy":"UseIPv6"
|
||||||
},
|
},
|
||||||
"tag":"IPv6-out"
|
"tag":"IPv6_out"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"protocol":"blackhole",
|
"protocol":"blackhole",
|
||||||
"tag":"blackhole-out"
|
"tag":"blackhole_out"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -6332,7 +6354,7 @@ EOF
|
||||||
|
|
||||||
# sing-box
|
# sing-box
|
||||||
if [[ -n "${singBoxConfigPath}" ]]; then
|
if [[ -n "${singBoxConfigPath}" ]]; then
|
||||||
removeSingBoxRouteRule "wireguard-out-${type}"
|
removeSingBoxRouteRule "wireguard_out_${type}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unInstallWireGuard "${type}"
|
unInstallWireGuard "${type}"
|
||||||
|
@ -6370,20 +6392,10 @@ warpRoutingReg() {
|
||||||
|
|
||||||
read -r -p "请按照上面示例录入域名:" domainList
|
read -r -p "请按照上面示例录入域名:" domainList
|
||||||
addWireGuardRoute "${type}" outboundTag "${domainList}"
|
addWireGuardRoute "${type}" outboundTag "${domainList}"
|
||||||
|
|
||||||
# unInstallOutbounds wireguard-out-"${type}"
|
|
||||||
|
|
||||||
# local outbounds
|
|
||||||
# outbounds=$(jq -r '.outbounds += [{"protocol":"wireguard","settings":{"secretKey":"'"${secretKeyWarpReg}"'","address":["'"${address}"'"],"peers":[{"publicKey":"'"${publicKeyWarpReg}"'","allowedIPs":["0.0.0.0/0","::/0"],"endpoint":"162.159.192.1:2408"}],"reserved":'"${reservedWarpReg}"',"mtu":1280},"tag":"wireguard-out-'"${type}"'"}]' ${configPath}10_ipv4_outbounds.json)
|
|
||||||
#
|
|
||||||
# echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
|
|
||||||
|
|
||||||
echoContent green " ---> 添加成功"
|
echoContent green " ---> 添加成功"
|
||||||
|
|
||||||
elif [[ "${warpStatus}" == "3" ]]; then
|
elif [[ "${warpStatus}" == "3" ]]; then
|
||||||
|
|
||||||
echoContent green " ---> 不可用"
|
|
||||||
exit 0
|
|
||||||
echoContent red "=============================================================="
|
echoContent red "=============================================================="
|
||||||
echoContent yellow "# 注意事项\n"
|
echoContent yellow "# 注意事项\n"
|
||||||
echoContent yellow "1.会删除设置的所有分流规则"
|
echoContent yellow "1.会删除设置的所有分流规则"
|
||||||
|
@ -6416,12 +6428,29 @@ warpRoutingReg() {
|
||||||
"reserved": ${reservedWarpReg},
|
"reserved": ${reservedWarpReg},
|
||||||
"mtu": 1280
|
"mtu": 1280
|
||||||
},
|
},
|
||||||
"tag": "wireguard-out-${type}"
|
"tag": "wireguard_out_${type}"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
rm ${configPath}09_routing.json >/dev/null 2>&1
|
rm ${configPath}09_routing.json >/dev/null 2>&1
|
||||||
|
|
||||||
|
configurationSingBoxRoute delete IPv4
|
||||||
|
configurationSingBoxRoute delete IPv6
|
||||||
|
removeSingBoxOutbound IPv4_out
|
||||||
|
removeSingBoxOutbound IPv6_out
|
||||||
|
|
||||||
|
if [[ "${type}" == "IPv4" ]]; then
|
||||||
|
configurationSingBoxRoute delete wireguard_out_IPv6
|
||||||
|
removeSingBoxOutbound wireguard_out_IPv6
|
||||||
|
else
|
||||||
|
configurationSingBoxRoute delete wireguard_out_IPv4
|
||||||
|
removeSingBoxOutbound wireguard_out_IPv4
|
||||||
|
fi
|
||||||
|
|
||||||
|
# outbound
|
||||||
|
addSingBoxOutbound "wireguard_out_${type}" "wireguard_out"
|
||||||
|
addSingBoxWireGuardOut
|
||||||
echoContent green " ---> WARP全局出站设置成功"
|
echoContent green " ---> WARP全局出站设置成功"
|
||||||
else
|
else
|
||||||
echoContent green " ---> 放弃设置"
|
echoContent green " ---> 放弃设置"
|
||||||
|
@ -6701,7 +6730,7 @@ EOF
|
||||||
unInstallRouting dokodemoDoor-443 inboundTag
|
unInstallRouting dokodemoDoor-443 inboundTag
|
||||||
|
|
||||||
local routing
|
local routing
|
||||||
routing=$(jq -r ".routing.rules += [{\"source\":[\"${setIPs//,/\",\"}\"],\"domains\":${domains},\"type\":\"field\",\"inboundTag\":[\"dokodemoDoor-80\",\"dokodemoDoor-443\"],\"outboundTag\":\"direct\"},{\"type\":\"field\",\"inboundTag\":[\"dokodemoDoor-80\",\"dokodemoDoor-443\"],\"outboundTag\":\"blackhole-out\"}]" ${configPath}09_routing.json)
|
routing=$(jq -r ".routing.rules += [{\"source\":[\"${setIPs//,/\",\"}\"],\"domains\":${domains},\"type\":\"field\",\"inboundTag\":[\"dokodemoDoor-80\",\"dokodemoDoor-443\"],\"outboundTag\":\"direct\"},{\"type\":\"field\",\"inboundTag\":[\"dokodemoDoor-80\",\"dokodemoDoor-443\"],\"outboundTag\":\"blackhole_out\"}]" ${configPath}09_routing.json)
|
||||||
echo "${routing}" | jq . >${configPath}09_routing.json
|
echo "${routing}" | jq . >${configPath}09_routing.json
|
||||||
else
|
else
|
||||||
|
|
||||||
|
@ -6727,7 +6756,7 @@ EOF
|
||||||
"dokodemoDoor-80",
|
"dokodemoDoor-80",
|
||||||
"dokodemoDoor-443"
|
"dokodemoDoor-443"
|
||||||
],
|
],
|
||||||
"outboundTag": "blackhole-out"
|
"outboundTag": "blackhole_out"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -8359,6 +8388,9 @@ singBoxVersionManageMenu() {
|
||||||
handleSingBox start
|
handleSingBox start
|
||||||
elif [[ "${selectTuicType}" == "5" ]]; then
|
elif [[ "${selectTuicType}" == "5" ]]; then
|
||||||
singBoxLog ${logStatus}
|
singBoxLog ${logStatus}
|
||||||
|
if [[ "${logStatus}" == "false" ]]; then
|
||||||
|
tail -f "${singBoxConfigPath}../box.log"
|
||||||
|
fi
|
||||||
elif [[ "${selectTuicType}" == "6" ]]; then
|
elif [[ "${selectTuicType}" == "6" ]]; then
|
||||||
tail -f "${singBoxConfigPath}../box.log"
|
tail -f "${singBoxConfigPath}../box.log"
|
||||||
fi
|
fi
|
||||||
|
@ -8397,7 +8429,7 @@ menu() {
|
||||||
cd "$HOME" || exit
|
cd "$HOME" || exit
|
||||||
echoContent red "\n=============================================================="
|
echoContent red "\n=============================================================="
|
||||||
echoContent green "作者:mack-a"
|
echoContent green "作者:mack-a"
|
||||||
echoContent green "当前版本:v2.11.9"
|
echoContent green "当前版本:v2.11.10"
|
||||||
echoContent green "Github:https://github.com/mack-a/v2ray-agent"
|
echoContent green "Github:https://github.com/mack-a/v2ray-agent"
|
||||||
echoContent green "描述:八合一共存脚本\c"
|
echoContent green "描述:八合一共存脚本\c"
|
||||||
showInstallStatus
|
showInstallStatus
|
||||||
|
|
Loading…
Reference in New Issue