feat(脚本): 添加用户/移除用户移除trojan-go、ipv6分流任意门解锁移除不支持trojan的提示、注释trojan-go相关代码

pull/534/merge
mack-a 2021-06-25 15:57:37 +08:00
parent 117ec36625
commit 46f82d6e2f
1 changed files with 192 additions and 127 deletions

View File

@ -331,7 +331,7 @@ showInstallStatus() {
fi fi
if echo ${currentInstallProtocolType} | grep -q 4; then if echo ${currentInstallProtocolType} | grep -q 4; then
echoContent yellow "Trojan+TCP/WS[TLS] \c" echoContent yellow "Trojan+TCP[TLS] \c"
fi fi
if echo ${currentInstallProtocolType} | grep -q 5; then if echo ${currentInstallProtocolType} | grep -q 5; then
@ -1285,50 +1285,50 @@ updateXray() {
fi fi
} }
# 更新Trojan-Go # 更新Trojan-Go
updateTrojanGo() { #updateTrojanGo() {
echoContent skyBlue "\n进度 $1/${totalProgress} : 更新Trojan-Go" # echoContent skyBlue "\n进度 $1/${totalProgress} : 更新Trojan-Go"
if [[ ! -d "/etc/v2ray-agent/trojan/" ]]; then # if [[ ! -d "/etc/v2ray-agent/trojan/" ]]; then
echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容" # echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容"
menu # menu
exit 0 # exit 0
fi # fi
if find /etc/v2ray-agent/trojan/ | grep -q "trojan-go"; then # if find /etc/v2ray-agent/trojan/ | grep -q "trojan-go"; then
version=$(curl -s https://api.github.com/repos/p4gefau1t/trojan-go/releases | jq -r .[0].tag_name) # version=$(curl -s https://api.github.com/repos/p4gefau1t/trojan-go/releases | jq -r .[0].tag_name)
echoContent green " ---> Trojan-Go版本:${version}" # echoContent green " ---> Trojan-Go版本:${version}"
if [[ -n $(wget --help | grep show-progress) ]]; then # if [[ -n $(wget --help | grep show-progress) ]]; then
wget -c -q --show-progress -P /etc/v2ray-agent/trojan/ "https://github.com/p4gefau1t/trojan-go/releases/download/${version}/${trojanGoCPUVendor}.zip" # wget -c -q --show-progress -P /etc/v2ray-agent/trojan/ "https://github.com/p4gefau1t/trojan-go/releases/download/${version}/${trojanGoCPUVendor}.zip"
else # else
wget -c -P /etc/v2ray-agent/trojan/ "https://github.com/p4gefau1t/trojan-go/releases/download/${version}/${trojanGoCPUVendor}.zip" >/dev/null 2>&1 # wget -c -P /etc/v2ray-agent/trojan/ "https://github.com/p4gefau1t/trojan-go/releases/download/${version}/${trojanGoCPUVendor}.zip" >/dev/null 2>&1
fi # fi
unzip -o /etc/v2ray-agent/trojan/${trojanGoCPUVendor}.zip -d /etc/v2ray-agent/trojan >/dev/null # unzip -o /etc/v2ray-agent/trojan/${trojanGoCPUVendor}.zip -d /etc/v2ray-agent/trojan >/dev/null
rm -rf /etc/v2ray-agent/trojan/${trojanGoCPUVendor}.zip # rm -rf /etc/v2ray-agent/trojan/${trojanGoCPUVendor}.zip
handleTrojanGo stop # handleTrojanGo stop
handleTrojanGo start # handleTrojanGo start
else # else
echoContent green " ---> 当前Trojan-Go版本:$(/etc/v2ray-agent/trojan/trojan-go --version | awk '{print $2}' | head -1)" # echoContent green " ---> 当前Trojan-Go版本:$(/etc/v2ray-agent/trojan/trojan-go --version | awk '{print $2}' | head -1)"
if [[ -n $(/etc/v2ray-agent/trojan/trojan-go --version) ]]; then # if [[ -n $(/etc/v2ray-agent/trojan/trojan-go --version) ]]; then
version=$(curl -s https://api.github.com/repos/p4gefau1t/trojan-go/releases | jq -r .[0].tag_name) # version=$(curl -s https://api.github.com/repos/p4gefau1t/trojan-go/releases | jq -r .[0].tag_name)
if [[ "${version}" == "$(/etc/v2ray-agent/trojan/trojan-go --version | awk '{print $2}' | head -1)" ]]; then # if [[ "${version}" == "$(/etc/v2ray-agent/trojan/trojan-go --version | awk '{print $2}' | head -1)" ]]; then
read -r -p "当前版本与最新版相同,是否重新安装?[y/n]:" reInstalTrojanGoStatus # read -r -p "当前版本与最新版相同,是否重新安装?[y/n]:" reInstalTrojanGoStatus
if [[ "${reInstalTrojanGoStatus}" == "y" ]]; then # if [[ "${reInstalTrojanGoStatus}" == "y" ]]; then
handleTrojanGo stop # handleTrojanGo stop
rm -rf /etc/v2ray-agent/trojan/trojan-go # rm -rf /etc/v2ray-agent/trojan/trojan-go
updateTrojanGo 1 # updateTrojanGo 1
else # else
echoContent green " ---> 放弃重新安装" # echoContent green " ---> 放弃重新安装"
fi # fi
else # else
read -r -p "最新版本为:${version},是否更新?[y/n]" installTrojanGoStatus # read -r -p "最新版本为:${version},是否更新?[y/n]" installTrojanGoStatus
if [[ "${installTrojanGoStatus}" == "y" ]]; then # if [[ "${installTrojanGoStatus}" == "y" ]]; then
rm -rf /etc/v2ray-agent/trojan/trojan-go # rm -rf /etc/v2ray-agent/trojan/trojan-go
updateTrojanGo 1 # updateTrojanGo 1
else # else
echoContent green " ---> 放弃更新" # echoContent green " ---> 放弃更新"
fi # fi
fi # fi
fi # fi
fi # fi
} #}
# 验证整个服务是否可用 # 验证整个服务是否可用
checkGFWStatue() { checkGFWStatue() {
@ -1640,9 +1640,44 @@ EOF
# 回落nginx # 回落nginx
local fallbacksList='{"dest":31300,"xver":0},{"alpn":"h2","dest":31302,"xver":0}' local fallbacksList='{"dest":31300,"xver":0},{"alpn":"h2","dest":31302,"xver":0}'
if echo "${selectCustomInstallType}" | grep -q 4 || [[ "$1" == "all" ]]; then # if echo "${selectCustomInstallType}" | grep -q 4 || [[ "$1" == "all" ]]; then
# 回落trojan-go # # 回落trojan-go
fallbacksList='{"dest":31296,"xver":0},{"alpn":"h2","dest":31302,"xver":0}' # fallbacksList='{"dest":31296,"xver":1},{"alpn":"h2","dest":31302,"xver":0}'
# fi
if [[ -n $(echo "${selectCustomInstallType}" | grep 4) || "$1" == "all" ]]; then
# fallbacksList=${fallbacksList}',{"path":"/'${customPath}'tcp","dest":31298,"xver":1}'
fallbacksList='{"dest":31296,"xver":1},{"alpn":"h2","dest":31302,"xver":0}'
cat <<EOF >/etc/v2ray-agent/v2ray/conf/04_trojan_TCP_inbounds.json
{
"inbounds":[
{
"port": 31296,
"listen": "127.0.0.1",
"protocol": "trojan",
"tag":"trojanTCP",
"settings": {
"clients": [
{
"password": "${uuid}",
"email": "${domain}_trojan_tcp"
}
],
"fallbacks":[
{"dest":"31300"}
]
},
"streamSettings": {
"network": "tcp",
"security": "none",
"tcpSettings": {
"acceptProxyProtocol": true
}
}
}
]
}
EOF
fi fi
# VLESS_WS_TLS # VLESS_WS_TLS
@ -2511,40 +2546,52 @@ showAccounts() {
fi fi
fi fi
# trojan-go # trojan tcp
if [[ -d "/etc/v2ray-agent/" ]] && [[ -d "/etc/v2ray-agent/trojan/" ]] && [[ -f "/etc/v2ray-agent/trojan/config_full.json" ]]; then if echo ${currentInstallProtocolType} | grep -q 4 || [[ -z "${currentInstallProtocolType}" ]]; then
show=1
# local trojanUUID=`cat /etc/v2ray-agent/trojan/config_full.json |jq .password[0]|awk -F '["]' '{print $2}'`
local trojanGoPath
trojanGoPath=$(jq -r .websocket.path /etc/v2ray-agent/trojan/config_full.json)
local trojanGoAdd
trojanGoAdd=$(jq .websocket.add /etc/v2ray-agent/trojan/config_full.json | awk -F '["]' '{print $2}')
echoContent skyBlue "\n================================== Trojan TLS ==================================\n" echoContent skyBlue "\n================================== Trojan TLS ==================================\n"
# cat /etc/v2ray-agent/trojan/config_full.json | jq .password jq .inbounds[0].settings.clients ${configPath}04_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
jq -r -c '.password[]' /etc/v2ray-agent/trojan/config_full.json | while read -r user; do echoContent skyBlue "\n ---> 帐号:$(echo "${user}" | jq -r .email )_$(echo "${user}" | jq -r .password)"
trojanUUID=${user}
if [[ -n "${trojanUUID}" ]]; then
echoContent skyBlue " ---> 帐号:${currentHost}_trojan_${trojanUUID}\n"
echo echo
defaultBase64Code trojan trojan ${trojanUUID} ${currentHost} defaultBase64Code trojan trojan $(echo "${user}" | jq -r .password) ${currentHost}
fi
done
echoContent skyBlue "\n================================ Trojan WS TLS ================================\n"
if [[ -z ${trojanGoAdd} ]]; then
trojanGoAdd=${currentHost}
fi
jq -r -c '.password[]' /etc/v2ray-agent/trojan/config_full.json | while read -r user; do
trojanUUID=${user}
if [[ -n "${trojanUUID}" ]]; then
echoContent skyBlue " ---> 帐号:${trojanGoAdd}_trojan_ws_${trojanUUID}"
echo
defaultBase64Code trojangows trojan ${trojanUUID} ${currentHost} ${trojanGoPath} ${trojanGoAdd}
fi
done done
fi fi
# # trojan-go
# if [[ -d "/etc/v2ray-agent/" ]] && [[ -d "/etc/v2ray-agent/trojan/" ]] && [[ -f "/etc/v2ray-agent/trojan/config_full.json" ]]; then
# show=1
# # local trojanUUID=`cat /etc/v2ray-agent/trojan/config_full.json |jq .password[0]|awk -F '["]' '{print $2}'`
# local trojanGoPath
# trojanGoPath=$(jq -r .websocket.path /etc/v2ray-agent/trojan/config_full.json)
# local trojanGoAdd
# trojanGoAdd=$(jq .websocket.add /etc/v2ray-agent/trojan/config_full.json | awk -F '["]' '{print $2}')
# echoContent skyBlue "\n================================== Trojan TLS ==================================\n"
# # cat /etc/v2ray-agent/trojan/config_full.json | jq .password
# jq -r -c '.password[]' /etc/v2ray-agent/trojan/config_full.json | while read -r user; do
# trojanUUID=${user}
# if [[ -n "${trojanUUID}" ]]; then
# echoContent skyBlue " ---> 帐号:${currentHost}_trojan_${trojanUUID}\n"
# echo
# defaultBase64Code trojan trojan ${trojanUUID} ${currentHost}
# fi
# done
#
# echoContent skyBlue "\n================================ Trojan WS TLS ================================\n"
# if [[ -z ${trojanGoAdd} ]]; then
# trojanGoAdd=${currentHost}
# fi
#
# jq -r -c '.password[]' /etc/v2ray-agent/trojan/config_full.json | while read -r user; do
# trojanUUID=${user}
# if [[ -n "${trojanUUID}" ]]; then
# echoContent skyBlue " ---> 帐号:${trojanGoAdd}_trojan_ws_${trojanUUID}"
# echo
# defaultBase64Code trojangows trojan ${trojanUUID} ${currentHost} ${trojanGoPath} ${trojanGoAdd}
# fi
#
# done
# fi
if [[ -z ${show} ]]; then if [[ -z ${show} ]]; then
echoContent red " ---> 未安装" echoContent red " ---> 未安装"
fi fi
@ -2721,25 +2768,24 @@ updateV2RayCDN() {
fi fi
# trojan # trojan
if [[ -d "/etc/v2ray-agent/trojan" ]] && [[ -f "/etc/v2ray-agent/trojan/config_full.json" ]]; then # if [[ -d "/etc/v2ray-agent/trojan" ]] && [[ -f "/etc/v2ray-agent/trojan/config_full.json" ]]; then
add=$(jq -r .websocket.add /etc/v2ray-agent/trojan/config_full.json) # add=$(jq -r .websocket.add /etc/v2ray-agent/trojan/config_full.json)
if [[ -n ${add} ]]; then # if [[ -n ${add} ]]; then
sed -i "s/${add}/${setDomain}/g" $(grep "${add}" -rl /etc/v2ray-agent/trojan/config_full.json) # sed -i "s/${add}/${setDomain}/g" $(grep "${add}" -rl /etc/v2ray-agent/trojan/config_full.json)
fi # fi
fi # fi
if [[ -d "/etc/v2ray-agent/trojan" ]] && [[ -f "/etc/v2ray-agent/trojan/config_full.json" ]] && [[ $(jq -r .websocket.add /etc/v2ray-agent/trojan/config_full.json) == ${setDomain} ]]; then # if [[ -d "/etc/v2ray-agent/trojan" ]] && [[ -f "/etc/v2ray-agent/trojan/config_full.json" ]] && [[ $(jq -r .websocket.add /etc/v2ray-agent/trojan/config_full.json) == ${setDomain} ]]; then
echoContent green "\n ---> Trojan CDN修改成功" # echoContent green "\n ---> Trojan CDN修改成功"
handleTrojanGo stop # handleTrojanGo stop
handleTrojanGo start # handleTrojanGo start
elif [[ -d "/etc/v2ray-agent/trojan" ]] && [[ -f "/etc/v2ray-agent/trojan/config_full.json" ]]; then # elif [[ -d "/etc/v2ray-agent/trojan" ]] && [[ -f "/etc/v2ray-agent/trojan/config_full.json" ]]; then
echoContent red " ---> 修改Trojan CDN失败" # echoContent red " ---> 修改Trojan CDN失败"
fi # fi
fi fi
else else
echoContent red " ---> 未安装可用类型" echoContent red " ---> 未安装可用类型"
fi fi
menu
} }
# manageUser 用户管理 # manageUser 用户管理
@ -2899,21 +2945,33 @@ addUser() {
fi fi
if echo ${currentInstallProtocolType} | grep -q 5; then if echo ${currentInstallProtocolType} | grep -q 5; then
local vmessUsers="${users//\"flow\":\"xtls-rprx-direct\"\,/}" local vlessGRPCUsers="${users//\"flow\":\"xtls-rprx-direct\"\,/}"
vlessGRPCUsers="${vlessGRPCUsers//\,\"alterId\":0/}"
local vlessGRPCResult local vlessGRPCResult
vlessGRPCResult=$(jq -r '.inbounds[0].settings.clients += ['${vmessUsers}']' ${configPath}06_VLESS_gRPC_inbounds.json) vlessGRPCResult=$(jq -r '.inbounds[0].settings.clients += ['${vlessGRPCUsers}']' ${configPath}06_VLESS_gRPC_inbounds.json)
echo "${vlessGRPCResult}" | jq . >${configPath}06_VLESS_gRPC_inbounds.json echo "${vlessGRPCResult}" | jq . >${configPath}06_VLESS_gRPC_inbounds.json
fi fi
if echo ${currentInstallProtocolType} | grep -q 4; then if echo ${currentInstallProtocolType} | grep -q 4; then
local trojanResult local trojanUsers="${users//\"flow\":\"xtls-rprx-direct\"\,/}"
trojanResult=$(jq -r '.password += ['${trojanGoUsers}']' ${configPath}../../trojan/config_full.json) trojanUsers="${trojanUsers//id/password}"
echo "${trojanResult}" | jq . >${configPath}../../trojan/config_full.json trojanUsers="${trojanUsers//\,\"alterId\":0/}"
handleTrojanGo stop
handleTrojanGo start
local trojanTCPResult
trojanTCPResult=$(jq -r '.inbounds[0].settings.clients += ['${trojanUsers}']' ${configPath}04_trojan_TCP_inbounds.json)
echo "${trojanTCPResult}" | jq . >${configPath}04_trojan_TCP_inbounds.json
fi fi
# if echo ${currentInstallProtocolType} | grep -q 4; then
# local trojanResult
# trojanResult=$(jq -r '.password += ['${trojanGoUsers}']' ${configPath}../../trojan/config_full.json)
# echo "${trojanResult}" | jq . >${configPath}../../trojan/config_full.json
# handleTrojanGo stop
# handleTrojanGo start
# fi
reloadCore reloadCore
echoContent green " ---> 添加完成" echoContent green " ---> 添加完成"
showAccounts 1 showAccounts 1
@ -2960,12 +3018,17 @@ removeUser() {
fi fi
if echo ${currentInstallProtocolType} | grep -q 4; then if echo ${currentInstallProtocolType} | grep -q 4; then
local trojanResult local trojanTCPResult
trojanResult=$(jq -r 'del(.password['${delUserIndex}'])' ${configPath}../../trojan/config_full.json) trojanTCPResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}04_trojan_TCP_inbounds.json)
echo "${trojanResult}" | jq . >${configPath}../../trojan/config_full.json echo "${trojanTCPResult}" | jq . >${configPath}04_trojan_TCP_inbounds.json
handleTrojanGo stop
handleTrojanGo start
fi fi
# if echo ${currentInstallProtocolType} | grep -q 4; then
# local trojanResult
# trojanResult=$(jq -r 'del(.password['${delUserIndex}'])' ${configPath}../../trojan/config_full.json)
# echo "${trojanResult}" | jq . >${configPath}../../trojan/config_full.json
# handleTrojanGo stop
# handleTrojanGo start
# fi
reloadCore reloadCore
fi fi
} }
@ -3387,7 +3450,7 @@ EOF
fi fi
reloadCore reloadCore
echoContent green " ---> 添加Netflix出战解锁成功" echoContent green " ---> 添加Netflix出战解锁成功"
echoContent yellow " ---> 不支持trojan的相关节点" # echoContent yellow " ---> 不支持trojan的相关节点"
exit 0 exit 0
fi fi
echoContent red " ---> ip不可为空" echoContent red " ---> ip不可为空"
@ -3513,7 +3576,7 @@ EOF
echo "${routing}" | jq . >${configPath}09_routing.json echo "${routing}" | jq . >${configPath}09_routing.json
reloadCore reloadCore
echoContent green " ---> 添加落地机入站解锁Netflix成功" echoContent green " ---> 添加落地机入站解锁Netflix成功"
echoContent yellow " ---> trojan的相关节点不支持此操作" # echoContent yellow " ---> trojan的相关节点不支持此操作"
exit 0 exit 0
fi fi
echoContent red " ---> ip不可为空" echoContent red " ---> ip不可为空"
@ -3666,7 +3729,8 @@ customV2RayInstall() {
echoContent yellow "1.VLESS+TLS+WS[CDN]" echoContent yellow "1.VLESS+TLS+WS[CDN]"
echoContent yellow "2.VMess+TLS+TCP" echoContent yellow "2.VMess+TLS+TCP"
echoContent yellow "3.VMess+TLS+WS[CDN]" echoContent yellow "3.VMess+TLS+WS[CDN]"
echoContent yellow "4.Trojan、Trojan+WS[CDN]" # echoContent yellow "4.Trojan、Trojan+WS[CDN]"
echoContent yellow "4.Trojan"
echoContent yellow "5.VLESS+TLS+gRPC[CDN]" echoContent yellow "5.VLESS+TLS+gRPC[CDN]"
read -r -p "请选择[多选][例如:123]:" selectCustomInstallType read -r -p "请选择[多选][例如:123]:" selectCustomInstallType
echoContent skyBlue "--------------------------------------------------------------" echoContent skyBlue "--------------------------------------------------------------"
@ -3728,7 +3792,8 @@ customXrayInstall() {
echoContent yellow "1.VLESS+TLS+WS[CDN]" echoContent yellow "1.VLESS+TLS+WS[CDN]"
echoContent yellow "2.VMess+TLS+TCP" echoContent yellow "2.VMess+TLS+TCP"
echoContent yellow "3.VMess+TLS+WS[CDN]" echoContent yellow "3.VMess+TLS+WS[CDN]"
echoContent yellow "4.Trojan、Trojan+WS[CDN]" # echoContent yellow "4.Trojan、Trojan+WS[CDN]"
echoContent yellow "4.Trojan"
echoContent yellow "5.VLESS+TLS+gRPC[CDN]" echoContent yellow "5.VLESS+TLS+gRPC[CDN]"
read -r -p "请选择[多选][例如:123]:" selectCustomInstallType read -r -p "请选择[多选][例如:123]:" selectCustomInstallType
echoContent skyBlue "--------------------------------------------------------------" echoContent skyBlue "--------------------------------------------------------------"
@ -3840,12 +3905,12 @@ v2rayCoreInstall() {
# 安装V2Ray # 安装V2Ray
installV2Ray 7 installV2Ray 7
installV2RayService 8 installV2RayService 8
installTrojanGo 9 # installTrojanGo 9
installTrojanService 10 # installTrojanService 10
customCDNIP 11 customCDNIP 11
initV2RayConfig all 12 initV2RayConfig all 12
cleanUp xrayDel cleanUp xrayDel
initTrojanGoConfig 13 # initTrojanGoConfig 13
installCronTLS 14 installCronTLS 14
nginxBlog 15 nginxBlog 15
updateRedirectNginxConf updateRedirectNginxConf
@ -3853,9 +3918,9 @@ v2rayCoreInstall() {
sleep 2 sleep 2
handleV2Ray start handleV2Ray start
handleNginx start handleNginx start
handleTrojanGo stop # handleTrojanGo stop
sleep 1 # sleep 1
handleTrojanGo start # handleTrojanGo start
# 生成账号 # 生成账号
checkGFWStatue 16 checkGFWStatue 16
showAccounts 17 showAccounts 17
@ -3982,7 +4047,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.5.10" echoContent green "当前版本v2.5.10-dev_remove_trojan-go"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent" echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c" echoContent green "描述:八合一共存脚本\c"
showInstallStatus showInstallStatus
@ -4008,12 +4073,12 @@ menu() {
echoContent yellow "10.添加新端口" echoContent yellow "10.添加新端口"
echoContent skyBlue "-------------------------版本管理-----------------------------" echoContent skyBlue "-------------------------版本管理-----------------------------"
echoContent yellow "11.core管理" echoContent yellow "11.core管理"
echoContent yellow "12.更新Trojan-Go" # echoContent yellow "12.更新Trojan-Go"
echoContent yellow "13.更新脚本" echoContent yellow "12.更新脚本"
echoContent yellow "14.安装BBR、DD脚本" echoContent yellow "13.安装BBR、DD脚本"
echoContent skyBlue "-------------------------脚本管理-----------------------------" echoContent skyBlue "-------------------------脚本管理-----------------------------"
echoContent yellow "15.查看日志" echoContent yellow "14.查看日志"
echoContent yellow "16.卸载脚本" echoContent yellow "15.卸载脚本"
echoContent red "==============================================================" echoContent red "=============================================================="
mkdirTools mkdirTools
aliasInstall aliasInstall
@ -4052,19 +4117,19 @@ menu() {
11) 11)
coreVersionManageMenu 1 coreVersionManageMenu 1
;; ;;
# 12)
# updateTrojanGo 1
# ;;
12) 12)
updateTrojanGo 1
;;
13)
updateV2RayAgent 1 updateV2RayAgent 1
;; ;;
14) 13)
bbrInstall bbrInstall
;; ;;
15) 14)
checkLog 1 checkLog 1
;; ;;
16) 15)
unInstall 1 unInstall 1
;; ;;
esac esac