mirror of https://github.com/mack-a/v2ray-agent
feat(脚本): sing-box支持dns分流、订阅增加开机自启
parent
aff357930e
commit
aa79eac0a0
151
install.sh
151
install.sh
|
@ -5826,7 +5826,7 @@ ipv6Routing() {
|
||||||
|
|
||||||
if [[ -n "${singBoxConfigPath}" ]]; then
|
if [[ -n "${singBoxConfigPath}" ]]; then
|
||||||
addSingBoxRouteRule "IPv6_out" "${domainList}" "IPv6_route"
|
addSingBoxRouteRule "IPv6_out" "${domainList}" "IPv6_route"
|
||||||
|
addSingBoxOutbound direct
|
||||||
addSingBoxOutbound IPv6_out
|
addSingBoxOutbound IPv6_out
|
||||||
addSingBoxOutbound IPv4_out
|
addSingBoxOutbound IPv4_out
|
||||||
fi
|
fi
|
||||||
|
@ -6400,7 +6400,7 @@ routingToolsMenu() {
|
||||||
echoContent yellow "4.Socks5分流"
|
echoContent yellow "4.Socks5分流"
|
||||||
echoContent yellow "5.DNS分流"
|
echoContent yellow "5.DNS分流"
|
||||||
# echoContent yellow "6.VMess+WS+TLS分流"
|
# echoContent yellow "6.VMess+WS+TLS分流"
|
||||||
# echoContent yellow "7.SNI反向代理分流"
|
echoContent yellow "7.SNI反向代理分流"
|
||||||
|
|
||||||
read -r -p "请选择:" selectType
|
read -r -p "请选择:" selectType
|
||||||
|
|
||||||
|
@ -6418,9 +6418,6 @@ routingToolsMenu() {
|
||||||
socks5Routing
|
socks5Routing
|
||||||
;;
|
;;
|
||||||
5)
|
5)
|
||||||
if [[ -n "${singBoxConfigPath}" ]]; then
|
|
||||||
echoContent red "\n ---> 此功能不支持Hysteria2、Tuic"
|
|
||||||
fi
|
|
||||||
dnsRouting 1
|
dnsRouting 1
|
||||||
;;
|
;;
|
||||||
# 6)
|
# 6)
|
||||||
|
@ -7039,62 +7036,105 @@ EOF
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 添加xray dns 配置
|
||||||
|
addXrayDNSConfig() {
|
||||||
|
local ip=$1
|
||||||
|
local domainList=$2
|
||||||
|
local domains=[]
|
||||||
|
while read -r line; do
|
||||||
|
local geositeStatus
|
||||||
|
geositeStatus=$(curl -s "https://api.github.com/repos/v2fly/domain-list-community/contents/data/${line}" | jq .message)
|
||||||
|
|
||||||
|
if [[ "${geositeStatus}" == "null" ]]; then
|
||||||
|
domains=$(echo "${domains}" | jq -r '. += ["geosite:'"${line}"'"]')
|
||||||
|
else
|
||||||
|
domains=$(echo "${domains}" | jq -r '. += ["domain:'"${line}"'"]')
|
||||||
|
fi
|
||||||
|
done < <(echo "${domainList}" | tr ',' '\n')
|
||||||
|
|
||||||
|
if [[ "${coreInstallType}" == "1" ]]; then
|
||||||
|
|
||||||
|
cat <<EOF >${configPath}11_dns.json
|
||||||
|
{
|
||||||
|
"dns": {
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"address": "${ip}",
|
||||||
|
"port": 53,
|
||||||
|
"domains": ${domains}
|
||||||
|
},
|
||||||
|
"localhost"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# 添加sing-box dns配置
|
||||||
|
addSingBoxDNSConfig() {
|
||||||
|
local ip=$1
|
||||||
|
local domainList=$2
|
||||||
|
|
||||||
|
local rules=
|
||||||
|
rules=$(initSingBoxRules "${domainList}" "dns")
|
||||||
|
# domain精确匹配规则
|
||||||
|
local domainRules=
|
||||||
|
domainRules=$(echo "${rules}" | jq .domainRules)
|
||||||
|
|
||||||
|
# ruleSet规则集
|
||||||
|
local ruleSet=
|
||||||
|
ruleSet=$(echo "${rules}" | jq .ruleSet)
|
||||||
|
|
||||||
|
# ruleSet规则tag
|
||||||
|
local ruleSetTag=[]
|
||||||
|
if [[ "$(echo "${ruleSet}" | jq '.|length')" != "0" ]]; then
|
||||||
|
ruleSetTag=$(echo "${ruleSet}" | jq '.|map(.tag)')
|
||||||
|
fi
|
||||||
|
if [[ -n "${singBoxConfigPath}" ]]; then
|
||||||
|
cat <<EOF >"${singBoxConfigPath}dns.json"
|
||||||
|
{
|
||||||
|
"dns": {
|
||||||
|
"servers": [
|
||||||
|
{
|
||||||
|
"tag": "local",
|
||||||
|
"address": "local"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tag": "dnsRouting",
|
||||||
|
"address": "${ip}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"rules": [
|
||||||
|
{
|
||||||
|
"rule_set": ${ruleSetTag},
|
||||||
|
"domain": ${domainRules},
|
||||||
|
"server":"dnsRouting"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"route":{
|
||||||
|
"rule_set":${ruleSet}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
}
|
||||||
# 设置dns
|
# 设置dns
|
||||||
setUnlockDNS() {
|
setUnlockDNS() {
|
||||||
read -r -p "请输入分流的DNS:" setDNS
|
read -r -p "请输入分流的DNS:" setDNS
|
||||||
if [[ -n ${setDNS} ]]; then
|
if [[ -n ${setDNS} ]]; then
|
||||||
echoContent red "=============================================================="
|
echoContent red "=============================================================="
|
||||||
echoContent yellow "录入示例:netflix,disney,hulu"
|
echoContent yellow "录入示例:netflix,disney,hulu"
|
||||||
echoContent yellow "默认方案请输入1,默认方案包括以下内容"
|
|
||||||
echoContent yellow "netflix,bahamut,hulu,hbo,disney,bbc,4chan,fox,abema,dmm,niconico,pixiv,bilibili,viu"
|
|
||||||
read -r -p "请按照上面示例录入域名:" domainList
|
read -r -p "请按照上面示例录入域名:" domainList
|
||||||
if [[ "${domainList}" == "1" ]]; then
|
|
||||||
cat <<EOF >${configPath}11_dns.json
|
if [[ "${coreInstallType}" == "1" ]]; then
|
||||||
{
|
addXrayDNSConfig "${setDNS}" "${domainList}"
|
||||||
"dns": {
|
fi
|
||||||
"servers": [
|
|
||||||
{
|
if [[ -n "${singBoxConfigPath}" ]]; then
|
||||||
"address": "${setDNS}",
|
addSingBoxDNSConfig "${setDNS}" "${domainList}"
|
||||||
"port": 53,
|
|
||||||
"domains": [
|
|
||||||
"geosite:netflix",
|
|
||||||
"geosite:bahamut",
|
|
||||||
"geosite:hulu",
|
|
||||||
"geosite:hbo",
|
|
||||||
"geosite:disney",
|
|
||||||
"geosite:bbc",
|
|
||||||
"geosite:4chan",
|
|
||||||
"geosite:fox",
|
|
||||||
"geosite:abema",
|
|
||||||
"geosite:dmm",
|
|
||||||
"geosite:niconico",
|
|
||||||
"geosite:pixiv",
|
|
||||||
"geosite:bilibili",
|
|
||||||
"geosite:viu"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"localhost"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
elif [[ -n "${domainList}" ]]; then
|
|
||||||
cat <<EOF >${configPath}11_dns.json
|
|
||||||
{
|
|
||||||
"dns": {
|
|
||||||
"servers": [
|
|
||||||
{
|
|
||||||
"address": "${setDNS}",
|
|
||||||
"port": 53,
|
|
||||||
"domains": [
|
|
||||||
"geosite:${domainList//,/\",\"geosite:}"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"localhost"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
reloadCore
|
reloadCore
|
||||||
|
@ -7600,6 +7640,7 @@ server {
|
||||||
EOF
|
EOF
|
||||||
handleNginx stop
|
handleNginx stop
|
||||||
handleNginx start
|
handleNginx start
|
||||||
|
systemctl enable nginx
|
||||||
fi
|
fi
|
||||||
if [[ -z $(pgrep -f "nginx") ]]; then
|
if [[ -z $(pgrep -f "nginx") ]]; then
|
||||||
handleNginx start
|
handleNginx start
|
||||||
|
@ -8657,7 +8698,7 @@ menu() {
|
||||||
cd "$HOME" || exit
|
cd "$HOME" || exit
|
||||||
echoContent red "\n=============================================================="
|
echoContent red "\n=============================================================="
|
||||||
echoContent green "作者:mack-a"
|
echoContent green "作者:mack-a"
|
||||||
echoContent green "当前版本:v3.2.1"
|
echoContent green "当前版本:v3.2.2"
|
||||||
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