Skip to content

Commit

Permalink
fix(脚本): 修改sing-box分流无法启动问题、修改xray-core bt下载和屏蔽cn域名冲突问题、修改api申请证书判断问题…
Browse files Browse the repository at this point in the history
…、增加sing-box分流域名改为正则匹配
  • Loading branch information
Wizard89 committed Feb 23, 2024
1 parent ea9d6d5 commit 0e9b609
Showing 1 changed file with 29 additions and 42 deletions.
71 changes: 29 additions & 42 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1537,7 +1537,7 @@ initDNSAPIConfig() {
initDNSAPIConfig "$1"
else
echo
if ! echo "${dnsTLSDomain}" | grep -q "." || [[ -z $(echo "${dnsTLSDomain}" | awk -F "[.]" '{print $1}') ]]; then
if ! echo "${dnsTLSDomain}" | grep -q "\." || [[ -z $(echo "${dnsTLSDomain}" | awk -F "[.]" '{print $1}') ]]; then
echoContent green " ---> 不支持此域名申请通配符证书,建议使用此格式[xx.xx.xx]"
exit 0
fi
Expand Down Expand Up @@ -1801,7 +1801,7 @@ nginxBlog() {
if [[ "${nginxBlogInstallStatus}" == "y" ]]; then
rm -rf "${nginxStaticPath}"
randomNum=$((RANDOM % 6 + 1))
wget -q -P "${nginxStaticPath}" https://raw.githubusercontent.com/Wizard89/v2ray-agent/master/fodder/blog/unable/html${randomNum}.zip >/dev/null
wget -q -P "${nginxStaticPath}" https://raw.githubusercontent.com/Wizard89/v2ray-agent/master/fodder/blog/unable/html${randomNum}.zip
unzip -o "${nginxStaticPath}html${randomNum}.zip" -d "${nginxStaticPath}" >/dev/null
rm -f "${nginxStaticPath}html${randomNum}.zip*"
echoContent green " ---> 添加伪装站点成功"
Expand Down Expand Up @@ -3242,7 +3242,7 @@ addSingBoxRouteRule() {
"rules": [
{
"rule_set":${ruleSetTag},
"domain":${domainRules},
"domain_regex":${domainRules},
"outbound": "${outboundTag}"
}
],
Expand Down Expand Up @@ -3523,7 +3523,6 @@ removeSingBoxConfig() {
if [[ -f "${singBoxConfigPath}${tag}.json" ]]; then
rm "${singBoxConfigPath}${tag}.json"
fi

}

# 初始化wireguard出站信息
Expand Down Expand Up @@ -4439,6 +4438,7 @@ EOF
removeSingBoxConfig wireguard_out_IPv6
removeSingBoxConfig IPv4_out
removeSingBoxConfig IPv6_out
removeSingBoxConfig IPv6_route
removeSingBoxConfig block
removeSingBoxConfig cn_block_outbound
removeSingBoxConfig cn_block_route
Expand Down Expand Up @@ -5879,7 +5879,7 @@ ipv6Routing() {

if [[ -n "${singBoxConfigPath}" ]]; then
addSingBoxRouteRule "IPv6_out" "${domainList}" "IPv6_route"
addSingBoxOutbound 01_direct_out
addSingBoxOutbound 01_direct_outbound
addSingBoxOutbound IPv6_out
addSingBoxOutbound IPv4_out
fi
Expand Down Expand Up @@ -5934,7 +5934,6 @@ ipv6Routing() {

removeXrayOutbound IPv6_out
addXrayOutbound "z_direct_outbound"

fi

if [[ -n "${singBoxConfigPath}" ]]; then
Expand Down Expand Up @@ -5966,20 +5965,20 @@ btTools() {
echoContent red "\n=============================================================="

if [[ -f ${configPath}09_routing.json ]] && grep -q bittorrent <${configPath}09_routing.json; then
echoContent yellow "当前状态:已禁用"
echoContent yellow "当前状态:已禁止下载BT"
else
echoContent yellow "当前状态:未禁用"
echoContent yellow "当前状态:允许下载BT"
fi

echoContent yellow "1.禁用"
echoContent yellow "2.打开"
echoContent yellow "1.禁止下载BT"
echoContent yellow "2.允许下载BT"
echoContent red "=============================================================="
read -r -p "请选择:" btStatus
if [[ "${btStatus}" == "1" ]]; then

if [[ -f "${configPath}09_routing.json" ]]; then

unInstallRouting blackhole_out outboundTag
unInstallRouting blackhole_out outboundTag bittorrent

routing=$(jq -r '.routing.rules += [{"type":"field","outboundTag":"blackhole_out","protocol":["bittorrent"]}]' ${configPath}09_routing.json)

Expand All @@ -6006,15 +6005,15 @@ EOF
removeXrayOutbound blackhole_out
addXrayOutbound blackhole_out

echoContent green " ---> BT下载配置完成"
echoContent green " ---> 禁止BT下载"

elif [[ "${btStatus}" == "2" ]]; then

unInstallSniffing

unInstallRouting blackhole_out outboundTag bittorrent

echoContent green " ---> BT下载打开成功"
echoContent green " ---> 允许BT下载"
else
echoContent red " ---> 选择错误"
exit 0
Expand All @@ -6035,7 +6034,7 @@ blacklist() {
echoContent red "\n=============================================================="
echoContent yellow "1.查看已屏蔽域名"
echoContent yellow "2.添加域名"
echoContent yellow "3.屏蔽国内域名"
echoContent yellow "3.屏蔽大陆域名"
echoContent yellow "4.卸载黑名单"
echoContent red "=============================================================="

Expand Down Expand Up @@ -6067,6 +6066,8 @@ blacklist() {
elif [[ "${blacklistStatus}" == "3" ]]; then

if [[ "${coreInstallType}" == "1" ]]; then
unInstallRouting blackhole_out outboundTag

addInstallRouting blackhole_out outboundTag "cn"

addXrayOutbound blackhole_out
Expand All @@ -6078,7 +6079,7 @@ blacklist() {
addSingBoxOutbound "01_direct_outbound"
fi

echoContent green " ---> 屏蔽国内域名完毕"
echoContent green " ---> 屏蔽大陆域名完毕"

elif [[ "${blacklistStatus}" == "4" ]]; then
if [[ "${coreInstallType}" == "1" ]]; then
Expand Down Expand Up @@ -6130,7 +6131,8 @@ addInstallRouting() {
EOF
fi
local routingRule=
routingRule=$(jq -r '.routing.rules[]|select(.outboundTag=="'"${tag}"'")' ${configPath}09_routing.json)
routingRule=$(jq -r ".routing.rules[]|select(.outboundTag==\"${tag}\" and (.protocol == null))" ${configPath}09_routing.json)

if [[ -z "${routingRule}" ]]; then
routingRule="{\"type\": \"field\",\"domain\": [],\"outboundTag\": \"${tag}\"}"
fi
Expand Down Expand Up @@ -6167,29 +6169,13 @@ unInstallRouting() {
local protocol=$3

if [[ -f "${configPath}09_routing.json" ]]; then
local routing
if grep -q "${tag}" ${configPath}09_routing.json && grep -q "${type}" ${configPath}09_routing.json; then

jq -c .routing.rules[] ${configPath}09_routing.json | while read -r line; do
local index=$((index + 1))
local delStatus=0
if [[ "${type}" == "outboundTag" ]] && echo "${line}" | jq .outboundTag | grep -q "${tag}"; then
delStatus=1
elif [[ "${type}" == "inboundTag" ]] && echo "${line}" | jq .inboundTag | grep -q "${tag}"; then
delStatus=1
fi

if [[ -n ${protocol} ]] && echo "${line}" | jq .protocol | grep -q "${protocol}"; then
delStatus=1
elif [[ -z ${protocol} ]] && [[ $(echo "${line}" | jq .protocol) != "null" ]]; then
delStatus=0
fi

if [[ ${delStatus} == 1 ]]; then
routing=$(jq -r 'del(.routing.rules['$((index - 1))'])' ${configPath}09_routing.json)
echo "${routing}" | jq . >${configPath}09_routing.json
fi
done
local routing=
if [[ -n "${protocol}" ]]; then
routing=$(jq -r "del(.routing.rules[] | select(.${type} == \"${tag}\" and (.protocol | index(\"${protocol}\"))))" ${configPath}09_routing.json)
echo "${routing}" | jq . >${configPath}09_routing.json
else
routing=$(jq -r "del(.routing.rules[] | select(.${type} == \"${tag}\" and (.protocol == null )))" ${configPath}09_routing.json)
echo "${routing}" | jq . >${configPath}09_routing.json
fi
fi
}
Expand Down Expand Up @@ -6765,7 +6751,7 @@ initSingBoxRules() {
if [[ "${geositeStatus}" == "null" ]]; then
ruleSet=$(echo "${ruleSet}" | jq -r ". += [{\"tag\":\"${line}_$2\",\"type\":\"remote\",\"format\":\"binary\",\"url\":\"https://raw.githubusercontent.com/SagerNet/sing-geosite/rule-set/geosite-${line}.srs\",\"download_detour\":\"01_direct_outbound\"}]")
else
domainRules=$(echo "${domainRules}" | jq -r ". += [\"${line}\"]")
domainRules=$(echo "${domainRules}" | jq -r ". += [\"^([a-zA-Z0-9_-]+\\\.)*${line//./\\\\.}\"]")
fi
done < <(echo "$1" | tr ',' '\n')
echo "{ \"domainRules\":${domainRules},\"ruleSet\":${ruleSet}}"
Expand Down Expand Up @@ -7193,7 +7179,7 @@ addSingBoxDNSConfig() {
"rules": [
{
"rule_set": ${ruleSetTag},
"domain": ${domainRules},
"domain_regex": ${domainRules},
"server":"dnsRouting"
}
]
Expand All @@ -7218,6 +7204,7 @@ setUnlockDNS() {
fi

if [[ -n "${singBoxConfigPath}" ]]; then
addSingBoxOutbound 01_direct_outbound
addSingBoxDNSConfig "${setDNS}" "${domainList}"
fi

Expand Down Expand Up @@ -8781,7 +8768,7 @@ menu() {
echoContent red "\n=============================================================="
echoContent green "原作者:mack-a"
echoContent green "作者:Wizard89"
echoContent green "当前版本:v3.0.10"
echoContent green "当前版本:v3.0.11"
echoContent green "Github:https://github.com/Wizard89/v2ray-agent"
echoContent green "描述:八合一共存脚本\c"
showInstallStatus
Expand Down

0 comments on commit 0e9b609

Please sign in to comment.