mirror of https://github.com/mack-a/v2ray-agent
feat(脚本): sing-box增加trojan
parent
a77963f75a
commit
28d792067d
59
install.sh
59
install.sh
|
@ -179,6 +179,7 @@ initVar() {
|
||||||
singBoxVLESSRealityVisionPort=
|
singBoxVLESSRealityVisionPort=
|
||||||
singBoxVLESSRealityGRPCPort=
|
singBoxVLESSRealityGRPCPort=
|
||||||
singBoxHysteria2Port=
|
singBoxHysteria2Port=
|
||||||
|
singBoxTrojanPort=
|
||||||
singBoxTuicPort=
|
singBoxTuicPort=
|
||||||
singBoxNaivePort=
|
singBoxNaivePort=
|
||||||
singBoxVMessWSPort=
|
singBoxVMessWSPort=
|
||||||
|
@ -196,7 +197,7 @@ initVar() {
|
||||||
# xray-core reality serverName publicKey
|
# xray-core reality serverName publicKey
|
||||||
xrayVLESSRealityServerName=
|
xrayVLESSRealityServerName=
|
||||||
xrayVLESSRealityPort=
|
xrayVLESSRealityPort=
|
||||||
xrayVLESSRealityPublicKey=
|
# xrayVLESSRealityPublicKey=
|
||||||
|
|
||||||
# interfaceName=
|
# interfaceName=
|
||||||
# 端口跳跃
|
# 端口跳跃
|
||||||
|
@ -394,13 +395,15 @@ readInstallProtocolType() {
|
||||||
xrayVLESSRealityPort=
|
xrayVLESSRealityPort=
|
||||||
xrayVLESSRealityServerName=
|
xrayVLESSRealityServerName=
|
||||||
# xrayVLESSRealityPrivateKey=
|
# xrayVLESSRealityPrivateKey=
|
||||||
xrayVLESSRealityPublicKey=
|
# xrayVLESSRealityPublicKey=
|
||||||
|
|
||||||
currentRealityPrivateKey=
|
currentRealityPrivateKey=
|
||||||
currentRealityPublicKey=
|
currentRealityPublicKey=
|
||||||
|
|
||||||
singBoxVLESSVisionPort=
|
singBoxVLESSVisionPort=
|
||||||
singBoxHysteria2Port=
|
singBoxHysteria2Port=
|
||||||
|
singBoxTrojanPort=
|
||||||
|
|
||||||
frontingTypeReality=
|
frontingTypeReality=
|
||||||
singBoxVLESSRealityVisionPort=
|
singBoxVLESSRealityVisionPort=
|
||||||
singBoxVLESSRealityVisionServerName=
|
singBoxVLESSRealityVisionServerName=
|
||||||
|
@ -434,6 +437,10 @@ readInstallProtocolType() {
|
||||||
fi
|
fi
|
||||||
if echo "${row}" | grep -q trojan_TCP_inbounds; then
|
if echo "${row}" | grep -q trojan_TCP_inbounds; then
|
||||||
currentInstallProtocolType="${currentInstallProtocolType},4,"
|
currentInstallProtocolType="${currentInstallProtocolType},4,"
|
||||||
|
if [[ "${coreInstallType}" == "2" ]]; then
|
||||||
|
frontingType=04_trojan_TCP_inbounds
|
||||||
|
singBoxTrojanPort=$(jq .inbounds[0].listen_port "${row}.json")
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if echo "${row}" | grep -q VLESS_gRPC_inbounds; then
|
if echo "${row}" | grep -q VLESS_gRPC_inbounds; then
|
||||||
currentInstallProtocolType="${currentInstallProtocolType},5,"
|
currentInstallProtocolType="${currentInstallProtocolType},5,"
|
||||||
|
@ -2700,11 +2707,18 @@ initSingBoxClients() {
|
||||||
currentUser="{\"uuid\":\"${uuid}\",\"flow\":\"xtls-rprx-vision\",\"name\":\"${name}-VLESS_TCP/TLS_Vision\"}"
|
currentUser="{\"uuid\":\"${uuid}\",\"flow\":\"xtls-rprx-vision\",\"name\":\"${name}-VLESS_TCP/TLS_Vision\"}"
|
||||||
users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
|
users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
|
||||||
fi
|
fi
|
||||||
|
# VMess ws
|
||||||
if echo "${type}" | grep -q ",3,"; then
|
if echo "${type}" | grep -q ",3,"; then
|
||||||
currentUser="{\"uuid\":\"${uuid}\",\"name\":\"${name}-VMess_WS\",\"alterId\": 0}"
|
currentUser="{\"uuid\":\"${uuid}\",\"name\":\"${name}-VMess_WS\",\"alterId\": 0}"
|
||||||
users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
|
users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# trojan
|
||||||
|
if echo "${type}" | grep -q ",4,"; then
|
||||||
|
currentUser="{\"password\":\"${uuid}\",\"name\":\"${name}-Trojan_TCP\"}"
|
||||||
|
users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
|
||||||
|
fi
|
||||||
|
|
||||||
# VLESS Reality Vision
|
# VLESS Reality Vision
|
||||||
if echo "${type}" | grep -q ",7,"; then
|
if echo "${type}" | grep -q ",7,"; then
|
||||||
currentUser="{\"uuid\":\"${uuid}\",\"flow\":\"xtls-rprx-vision\",\"name\":\"${name}-VLESS_Reality_Vision\"}"
|
currentUser="{\"uuid\":\"${uuid}\",\"flow\":\"xtls-rprx-vision\",\"name\":\"${name}-VLESS_Reality_Vision\"}"
|
||||||
|
@ -2719,7 +2733,6 @@ initSingBoxClients() {
|
||||||
# hysteria2
|
# hysteria2
|
||||||
if echo "${type}" | grep -q ",6,"; then
|
if echo "${type}" | grep -q ",6,"; then
|
||||||
currentUser="{\"password\":\"${uuid}\",\"name\":\"${name}-singbox_hysteria2\"}"
|
currentUser="{\"password\":\"${uuid}\",\"name\":\"${name}-singbox_hysteria2\"}"
|
||||||
|
|
||||||
users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
|
users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -4313,6 +4326,34 @@ EOF
|
||||||
rm /etc/v2ray-agent/sing-box/conf/config/06_hysteria2_inbounds.json >/dev/null 2>&1
|
rm /etc/v2ray-agent/sing-box/conf/config/06_hysteria2_inbounds.json >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if echo "${selectCustomInstallType}" | grep -q ",4," || [[ "$1" == "all" ]]; then
|
||||||
|
echoContent yellow "\n================== 配置 Trojan ==================\n"
|
||||||
|
echoContent skyBlue "\n开始配置Trojan协议端口"
|
||||||
|
echo
|
||||||
|
mapfile -t result < <(initSingBoxPort "${singBoxTrojanPort}")
|
||||||
|
echoContent green "\n ---> Trojan端口:${result[-1]}"
|
||||||
|
cat <<EOF >/etc/v2ray-agent/sing-box/conf/config/04_trojan_TCP_inbounds.json
|
||||||
|
{
|
||||||
|
"inbounds": [
|
||||||
|
{
|
||||||
|
"type": "trojan",
|
||||||
|
"listen": "::",
|
||||||
|
"listen_port": ${result[-1]},
|
||||||
|
"users": $(initSingBoxClients 4),
|
||||||
|
"tls": {
|
||||||
|
"enabled": true,
|
||||||
|
"server_name":"${sslDomain}",
|
||||||
|
"certificate_path": "/etc/v2ray-agent/tls/${sslDomain}.crt",
|
||||||
|
"key_path": "/etc/v2ray-agent/tls/${sslDomain}.key"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
elif [[ -z "$3" ]]; then
|
||||||
|
rm /etc/v2ray-agent/sing-box/conf/config/04_trojan_TCP_inbounds.json >/dev/null 2>&1
|
||||||
|
fi
|
||||||
|
|
||||||
if echo "${selectCustomInstallType}" | grep -q ",9," || [[ "$1" == "all" ]]; then
|
if echo "${selectCustomInstallType}" | grep -q ",9," || [[ "$1" == "all" ]]; then
|
||||||
echoContent yellow "\n==================== 配置 Tuic =====================\n"
|
echoContent yellow "\n==================== 配置 Tuic =====================\n"
|
||||||
echoContent skyBlue "\n开始配置Tuic协议端口"
|
echoContent skyBlue "\n开始配置Tuic协议端口"
|
||||||
|
@ -4804,12 +4845,12 @@ showAccounts() {
|
||||||
# trojan tcp
|
# trojan tcp
|
||||||
if echo ${currentInstallProtocolType} | grep -q ",4,"; then
|
if echo ${currentInstallProtocolType} | grep -q ",4,"; then
|
||||||
echoContent skyBlue "\n================================== Trojan TLS [不推荐] ==================================\n"
|
echoContent skyBlue "\n================================== Trojan TLS [不推荐] ==================================\n"
|
||||||
jq .inbounds[0].settings.clients ${configPath}04_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
|
jq .inbounds[0].settings.clients//.inbounds[0].users ${configPath}04_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
|
||||||
local email=
|
local email=
|
||||||
email=$(echo "${user}" | jq -r .email)
|
email=$(echo "${user}" | jq -r .email//.name)
|
||||||
echoContent skyBlue "\n ---> 账号:${email}"
|
echoContent skyBlue "\n ---> 账号:${email}"
|
||||||
|
|
||||||
defaultBase64Code trojan "${currentDefaultPort}" "${email}" "$(echo "${user}" | jq -r .password)"
|
defaultBase64Code trojan "${currentDefaultPort}${singBoxTrojanPort}" "${email}" "$(echo "${user}" | jq -r .password)"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -7146,6 +7187,7 @@ customSingBoxInstall() {
|
||||||
echoContent skyBlue "\n========================个性化安装============================"
|
echoContent skyBlue "\n========================个性化安装============================"
|
||||||
echoContent yellow "0.VLESS+Vision+TCP"
|
echoContent yellow "0.VLESS+Vision+TCP"
|
||||||
echoContent yellow "3.VMess+TLS+WS[仅CDN推荐]"
|
echoContent yellow "3.VMess+TLS+WS[仅CDN推荐]"
|
||||||
|
echoContent yellow "4.Trojan+TLS[不推荐]"
|
||||||
echoContent yellow "6.Hysteria2"
|
echoContent yellow "6.Hysteria2"
|
||||||
echoContent yellow "7.VLESS+Reality+Vision"
|
echoContent yellow "7.VLESS+Reality+Vision"
|
||||||
echoContent yellow "8.VLESS+Reality+gRPC"
|
echoContent yellow "8.VLESS+Reality+gRPC"
|
||||||
|
@ -7174,7 +7216,7 @@ customSingBoxInstall() {
|
||||||
totalProgress=9
|
totalProgress=9
|
||||||
installTools 1
|
installTools 1
|
||||||
# 申请tls
|
# 申请tls
|
||||||
if echo "${selectCustomInstallType}" | grep -q -E ",0,|,3,|,6,|,9,|,10,"; then
|
if echo "${selectCustomInstallType}" | grep -q -E ",0,|,3,|,4,|,6,|,9,|,10,"; then
|
||||||
initTLSNginxConfig 2
|
initTLSNginxConfig 2
|
||||||
installTLS 3
|
installTLS 3
|
||||||
handleNginx stop
|
handleNginx stop
|
||||||
|
@ -8635,7 +8677,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.16"
|
echoContent green "当前版本:v3.2.17"
|
||||||
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
|
||||||
|
@ -8674,7 +8716,6 @@ menu() {
|
||||||
echoContent yellow "17.更新脚本"
|
echoContent yellow "17.更新脚本"
|
||||||
echoContent yellow "18.安装BBR、DD脚本"
|
echoContent yellow "18.安装BBR、DD脚本"
|
||||||
echoContent skyBlue "-------------------------脚本管理-----------------------------"
|
echoContent skyBlue "-------------------------脚本管理-----------------------------"
|
||||||
# echoContent yellow "19.查看日志"
|
|
||||||
echoContent yellow "20.卸载脚本"
|
echoContent yellow "20.卸载脚本"
|
||||||
echoContent red "=============================================================="
|
echoContent red "=============================================================="
|
||||||
mkdirTools
|
mkdirTools
|
||||||
|
|
Loading…
Reference in New Issue