fix(脚本): 修复sing-box naive无法删除用户问题、修复sing-box卸载dns分流报错问题

pull/1006/head
mack-a 2024-04-09 16:13:27 +08:00
parent 5830e6bfb8
commit 4ae549a5bb
1 changed files with 31 additions and 8 deletions

View File

@ -4424,6 +4424,7 @@ EOF
removeSingBoxConfig cn_block_route
removeSingBoxConfig 01_direct_outbound
removeSingBoxConfig block_domain_outbound
removeSingBoxConfig dns
}
# 初始化 sing-box订阅配置
initSubscribeLocalConfig() {
@ -5590,7 +5591,7 @@ removeUser() {
if [[ "${coreInstallType}" == "1" ]]; then
jq -r -c .inbounds[0].settings.clients[].email ${configPath}${userConfigType}.json | awk '{print NR""":"$0}'
elif [[ "${coreInstallType}" == "2" ]]; then
jq -r -c .inbounds[0].users[].name ${configPath}${userConfigType}.json | awk '{print NR""":"$0}'
jq -r -c .inbounds[0].users[].name//.inbounds[0].users[].username ${configPath}${userConfigType}.json | awk '{print NR""":"$0}'
fi
read -r -p "请选择要删除的用户编号[仅支持单个删除]:" delUserIndex
@ -5622,19 +5623,19 @@ removeUser() {
if echo ${currentInstallProtocolType} | grep -q ",3,"; then
local vmessWSResult
vmessWSResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}05_VMess_WS_inbounds.json)
vmessWSResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' ${configPath}05_VMess_WS_inbounds.json)
echo "${vmessWSResult}" | jq . >${configPath}05_VMess_WS_inbounds.json
fi
if echo ${currentInstallProtocolType} | grep -q ",5,"; then
local vlessGRPCResult
vlessGRPCResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}06_VLESS_gRPC_inbounds.json)
vlessGRPCResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' ${configPath}06_VLESS_gRPC_inbounds.json)
echo "${vlessGRPCResult}" | jq . >${configPath}06_VLESS_gRPC_inbounds.json
fi
if echo ${currentInstallProtocolType} | grep -q ",4,"; then
local trojanTCPResult
trojanTCPResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}04_trojan_TCP_inbounds.json)
trojanTCPResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' ${configPath}04_trojan_TCP_inbounds.json)
echo "${trojanTCPResult}" | jq . >${configPath}04_trojan_TCP_inbounds.json
fi
@ -5651,14 +5652,19 @@ removeUser() {
if echo ${currentInstallProtocolType} | grep -q ",6,"; then
local hysteriaResult
hysteriaResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}06_hysteria2_inbounds.json")
hysteriaResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}06_hysteria2_inbounds.json")
echo "${hysteriaResult}" | jq . >"${singBoxConfigPath}06_hysteria2_inbounds.json"
fi
if echo ${currentInstallProtocolType} | grep -q ",9,"; then
local tuicResult
tuicResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}09_tuic_inbounds.json")
tuicResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}09_tuic_inbounds.json")
echo "${tuicResult}" | jq . >"${singBoxConfigPath}09_tuic_inbounds.json"
fi
if echo ${currentInstallProtocolType} | grep -q ",10,"; then
local naiveResult
naiveResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}10_naive_inbounds.json")
echo "${naiveResult}" | jq . >"${singBoxConfigPath}10_naive_inbounds.json"
fi
reloadCore
fi
manageAccount 1
@ -7265,6 +7271,7 @@ setUnlockDNS() {
# 移除 DNS分流
removeUnlockDNS() {
if [[ "${coreInstallType}" == "1" && -f "${configPath}11_dns.json" ]]; then
cat <<EOF >${configPath}11_dns.json
{
"dns": {
@ -7274,6 +7281,22 @@ removeUnlockDNS() {
}
}
EOF
fi
if [[ "${coreInstallType}" == "2" && -f "${singBoxConfigPath}dns.json" ]]; then
cat <<EOF >${singBoxConfigPath}dns.json
{
"dns": {
"servers":[
{
"address":"local"
}
]
}
}
EOF
fi
reloadCore
echoContent green " ---> 卸载成功"
@ -8801,7 +8824,7 @@ menu() {
cd "$HOME" || exit
echoContent red "\n=============================================================="
echoContent green "作者mack-a"
echoContent green "当前版本v3.2.37"
echoContent green "当前版本v3.2.38"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c"
showInstallStatus