Merge branch 'dev_remove_trojan-go'

pull/534/merge
mack-a 2021-06-28 15:20:02 +08:00
commit fab97bcdd3
2 changed files with 386 additions and 270 deletions

View File

@ -109,6 +109,14 @@
[支持通过虚拟币向我捐赠](https://github.com/mack-a/v2ray-agent/blob/master/documents/donation.md) [支持通过虚拟币向我捐赠](https://github.com/mack-a/v2ray-agent/blob/master/documents/donation.md)
## 客户端推荐
- Android
- [AnXray](https://github.com/XTLS/AnXray/releases)
- iOS
- Shadowrocket
- windows/Mac/Linux
- [Qv2ray](https://github.com/Qv2ray/Qv2ray/actions)[推荐action版本]
## 安装脚本 ## 安装脚本
- 支持快捷方式启动安装完毕后shell输入【**vasma**】即可打开脚本,脚本执行路径[**/etc/v2ray-agent/install.sh**] - 支持快捷方式启动安装完毕后shell输入【**vasma**】即可打开脚本,脚本执行路径[**/etc/v2ray-agent/install.sh**]

View File

@ -229,15 +229,18 @@ readInstallProtocolType() {
if echo ${row} | grep -q VMess_WS_inbounds; then if echo ${row} | grep -q VMess_WS_inbounds; then
currentInstallProtocolType=${currentInstallProtocolType}'3' currentInstallProtocolType=${currentInstallProtocolType}'3'
fi fi
if echo ${row} | grep -q trojan_TCP_inbounds; then
currentInstallProtocolType=${currentInstallProtocolType}'4'
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'
fi fi
done < <(ls ${configPath} | grep inbounds.json | awk -F "[.]" '{print $1}') done < <(ls ${configPath} | grep inbounds.json | awk -F "[.]" '{print $1}')
if [[ -f "/etc/v2ray-agent/trojan/trojan-go" ]] && [[ -f "/etc/v2ray-agent/trojan/config_full.json" ]]; then # if [[ -f "/etc/v2ray-agent/trojan/trojan-go" ]] && [[ -f "/etc/v2ray-agent/trojan/config_full.json" ]]; then
currentInstallProtocolType=${currentInstallProtocolType}'4' # currentInstallProtocolType=${currentInstallProtocolType}'4'
fi # fi
} }
# 检查文件目录以及path路径 # 检查文件目录以及path路径
@ -331,7 +334,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
@ -741,7 +744,7 @@ checkIP() {
exit 0 exit 0
fi fi
else else
read -r -p "IP查询失败是否重试[y/n]" retryStatus read -r -p "IP查询失败请检查域名解析是否正确,是否重试[y/n]" retryStatus
if [[ "${retryStatus}" == "y" ]]; then if [[ "${retryStatus}" == "y" ]]; then
checkIP checkIP
else else
@ -1285,50 +1288,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 +1643,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
@ -1660,7 +1698,7 @@ EOF
"clients": [ "clients": [
{ {
"id": "${uuid}", "id": "${uuid}",
"email": "${domain}_vless_ws" "email": "${domain}_VLESS_WS"
} }
], ],
"decryption": "none" "decryption": "none"
@ -1680,45 +1718,45 @@ EOF
fi fi
# VMess_TCP # VMess_TCP
if echo "${selectCustomInstallType}" | grep -q 2 || [[ "$1" == "all" ]]; then # if echo "${selectCustomInstallType}" | grep -q 2 || [[ "$1" == "all" ]]; then
fallbacksList=${fallbacksList}',{"path":"/'${customPath}'tcp","dest":31298,"xver":1}' # fallbacksList=${fallbacksList}',{"path":"/'${customPath}'tcp","dest":31298,"xver":1}'
cat <<EOF >/etc/v2ray-agent/v2ray/conf/04_VMess_TCP_inbounds.json # cat <<EOF >/etc/v2ray-agent/v2ray/conf/04_VMess_TCP_inbounds.json
{ #{
"inbounds":[ #"inbounds":[
{ #{
"port": 31298, # "port": 31298,
"listen": "127.0.0.1", # "listen": "127.0.0.1",
"protocol": "vmess", # "protocol": "vmess",
"tag":"VMessTCP", # "tag":"VMessTCP",
"settings": { # "settings": {
"clients": [ # "clients": [
{ # {
"id": "${uuid}", # "id": "${uuid}",
"alterId": 0, # "alterId": 0,
"email": "${domain}_vmess_tcp" # "email": "${domain}_vmess_tcp"
} # }
] # ]
}, # },
"streamSettings": { # "streamSettings": {
"network": "tcp", # "network": "tcp",
"security": "none", # "security": "none",
"tcpSettings": { # "tcpSettings": {
"acceptProxyProtocol": true, # "acceptProxyProtocol": true,
"header": { # "header": {
"type": "http", # "type": "http",
"request": { # "request": {
"path": [ # "path": [
"/${customPath}tcp" # "/${customPath}tcp"
] # ]
} # }
} # }
} # }
} # }
} #}
] #]
} #}
EOF #EOF
fi # fi
# VMess_WS # VMess_WS
if echo "${selectCustomInstallType}" | grep -q 3 || [[ "$1" == "all" ]]; then if echo "${selectCustomInstallType}" | grep -q 3 || [[ "$1" == "all" ]]; then
@ -1769,7 +1807,7 @@ EOF
{ {
"id": "${uuid}", "id": "${uuid}",
"add": "${add}", "add": "${add}",
"email": "${domain}_vless_grpc" "email": "${domain}_VLESS_gRPC"
} }
], ],
"decryption": "none" "decryption": "none"
@ -1813,8 +1851,8 @@ EOF
"security": "tls", "security": "tls",
"tlsSettings": { "tlsSettings": {
"alpn": [ "alpn": [
"h2", "http/1.1",
"http/1.1" "h2"
], ],
"certificates": [ "certificates": [
{ {
@ -1964,19 +2002,6 @@ EOF
EOF EOF
fi fi
# 取消BT
# cat <<EOF >/etc/v2ray-agent/xray/conf/10_bt_outbounds.json
#{
# "outbounds": [
# {
# "protocol": "blackhole",
# "settings": {},
# "tag": "blocked"
# }
# ]
#}
#EOF
# dns # dns
cat <<EOF >/etc/v2ray-agent/xray/conf/11_dns.json cat <<EOF >/etc/v2ray-agent/xray/conf/11_dns.json
{ {
@ -1987,15 +2012,52 @@ EOF
} }
} }
EOF EOF
# VLESS_TCP_TLS/XTLS # VLESS_TCP_TLS/XTLS
# 回落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 # trojan
# 回落trojan-go if [[ -n $(echo "${selectCustomInstallType}" | grep 4) || "$1" == "all" ]]; then
fallbacksList='{"dest":31296,"xver":0},{"alpn":"h2","dest":31302,"xver":0}' # 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/xray/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
# if echo "${selectCustomInstallType}" | grep -q 4 || [[ "$1" == "all" ]]; then
# # 回落trojan-go
# fallbacksList='{"dest":31296,"xver":0},{"alpn":"h2","dest":31302,"xver":0}'
# fi
# VLESS_WS_TLS # VLESS_WS_TLS
if echo "${selectCustomInstallType}" | grep -q 1 || [[ "$1" == "all" ]]; then if echo "${selectCustomInstallType}" | grep -q 1 || [[ "$1" == "all" ]]; then
fallbacksList=${fallbacksList}',{"path":"/'${customPath}'ws","dest":31297,"xver":1}' fallbacksList=${fallbacksList}',{"path":"/'${customPath}'ws","dest":31297,"xver":1}'
@ -2011,7 +2073,7 @@ EOF
"clients": [ "clients": [
{ {
"id": "${uuid}", "id": "${uuid}",
"email": "${domain}_vless_ws" "email": "${domain}_VLESS_WS"
} }
], ],
"decryption": "none" "decryption": "none"
@ -2030,46 +2092,47 @@ EOF
EOF EOF
fi fi
# VMess_TCP # # VMess_TCP
if [[ -n $(echo ${selectCustomInstallType} | grep 2) || "$1" == "all" ]]; then # if [[ -n $(echo ${selectCustomInstallType} | grep 2) || "$1" == "all" ]]; then
fallbacksList=${fallbacksList}',{"path":"/'${customPath}'tcp","dest":31298,"xver":1}' # fallbacksList=${fallbacksList}',{"path":"/'${customPath}'tcp","dest":31298,"xver":1}'
cat <<EOF >/etc/v2ray-agent/xray/conf/04_VMess_TCP_inbounds.json # cat <<EOF >/etc/v2ray-agent/xray/conf/04_VMess_TCP_inbounds.json
{ #{
"inbounds":[ #"inbounds":[
{ #{
"port": 31298, # "port": 31298,
"listen": "127.0.0.1", # "listen": "127.0.0.1",
"protocol": "vmess", # "protocol": "vmess",
"tag":"VMessTCP", # "tag":"VMessTCP",
"settings": { # "settings": {
"clients": [ # "clients": [
{ # {
"id": "${uuid}", # "id": "${uuid}",
"alterId": 0, # "alterId": 0,
"email": "${domain}_vmess_tcp" # "email": "${domain}_vmess_tcp"
} # }
] # ]
}, # },
"streamSettings": { # "streamSettings": {
"network": "tcp", # "network": "tcp",
"security": "none", # "security": "none",
"tcpSettings": { # "tcpSettings": {
"acceptProxyProtocol": true, # "acceptProxyProtocol": true,
"header": { # "header": {
"type": "http", # "type": "http",
"request": { # "request": {
"path": [ # "path": [
"/${customPath}tcp" # "/${customPath}tcp"
] # ]
} # }
} # }
} # }
} # }
} #}
] #]
} #}
EOF #EOF
fi # fi
# VMess_WS # VMess_WS
if echo "${selectCustomInstallType}" | grep -q 3 || [[ "$1" == "all" ]]; then if echo "${selectCustomInstallType}" | grep -q 3 || [[ "$1" == "all" ]]; then
@ -2120,7 +2183,7 @@ EOF
{ {
"id": "${uuid}", "id": "${uuid}",
"add": "${add}", "add": "${add}",
"email": "${domain}_vless_grpc" "email": "${domain}_VLESS_gRPC"
} }
], ],
"decryption": "none" "decryption": "none"
@ -2165,8 +2228,8 @@ EOF
"xtlsSettings": { "xtlsSettings": {
"minVersion": "1.2", "minVersion": "1.2",
"alpn": [ "alpn": [
"h2", "http/1.1",
"http/1.1" "h2"
], ],
"certificates": [ "certificates": [
{ {
@ -2327,7 +2390,21 @@ EOF
elif [[ "${type}" == "vmesstcp" ]]; then elif [[ "${type}" == "vmesstcp" ]]; then
qrCodeBase64Default=$(echo -n '{"port":"'${port}'","ps":'${ps}',"tls":"tls","id":'"${id}"',"aid":"0","v":"2","host":"'${host}'","type":"http","path":"/'${path}'","net":"http","add":"'${add}'","allowInsecure":0,"method":"post","peer":"'${host}'","obfs":"http","obfsParam":"'${host}'"}' | sed 's#/#\\\/#g' | base64) # echoContent yellow " ---> 通用格式[新版,推荐]"
#
# echoContent green " vmess://tcp+tls:2e6257c5-1402-41a6-a96d-1e0bdad78159-0@vu3.s83h.xyz:443/?type=http&tlsServerName=vu3.s83h.xyz#vu3.s83h.xyz_vmess_tcp"
# echoContent green " vmess://tcp+tls:${id//\"/}-0@${add}:${port}/?type=http&path=/${path}&tlsServerName=${host}&alpn=http1.1#${ps//\"/}\n"
#
# echoContent yellow " ---> 格式化明文(vmess+http+tls)"
# echoContent green "协议类型vmess地址${host},端口:${port}用户ID${id}安全tls传输方式http账户名:${ps}\n"
# cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
#vmess://http+tls:${id}-0@${add}:${port}/?path=/${path}&tlsServerName=${host}&alpn=http1.1#${ps}
#EOF
# echoContent yellow " ---> 二维码 vmess(http+tls)"
# echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vmess%3A%2F%2Fhttp%2Btls%3A${id}-0%40add%3A${port}%2F%3Fpath%3D%2F${path}%26tlsServerName%3D${host}%26alpn%3Dhttp1.1%23%24%7B${ps}%7D\n"
echoContent red path:${path}
qrCodeBase64Default=$(echo -n '{"add":"'${add}'","aid":"0","host":"'${host}'","id":'"${id}"',"net":"tcp","path":"/'${path}'","port":"'${port}'","ps":'${ps}',"scy":"none","sni":"'${host}'","tls":"tls","v":"2","type":"http","allowInsecure":0,"peer":"'${host}'","obfs":"http","obfsParam":"'${host}'"}' | base64)
qrCodeBase64Default=$(echo ${qrCodeBase64Default} | sed 's/ //g') qrCodeBase64Default=$(echo ${qrCodeBase64Default} | sed 's/ //g')
echoContent yellow " ---> 通用json(VMess+TCP+TLS)" echoContent yellow " ---> 通用json(VMess+TCP+TLS)"
@ -2370,24 +2447,24 @@ EOF
echoContent green " vless://${VLESSID}@${add}:${port}?encryption=none&security=tls&type=grpc&host=${host}&serviceName=${path}&alpn=h2#${VLESSEmail}\n" echoContent green " vless://${VLESSID}@${add}:${port}?encryption=none&security=tls&type=grpc&host=${host}&serviceName=${path}&alpn=h2#${VLESSEmail}\n"
echoContent yellow " ---> 格式化明文(VLESS+gRPC+TLS)" echoContent yellow " ---> 格式化明文(VLESS+gRPC+TLS)"
echoContent green " 协议类型VLESS地址${add},伪装域名/SNI${host},端口:${port}用户ID${VLESSID}安全tls传输方式gRPCserviceName:${path},账户名:${VLESSEmail}\n" echoContent green " 协议类型VLESS地址${add},伪装域名/SNI${host},端口:${port}用户ID${VLESSID}安全tls传输方式gRPCalpnh2serviceName:${path},账户名:${VLESSEmail}\n"
cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}" cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
vless://${VLESSID}@${add}:${port}?encryption=none&security=tls&type=grpc&host=${host}&path=${path}&serviceName=${path}&alpn=h2#${VLESSEmail} vless://${VLESSID}@${add}:${port}?encryption=none&security=tls&type=grpc&host=${host}&path=${path}&serviceName=${path}&alpn=h2#${VLESSEmail}
EOF EOF
echoContent yellow " ---> 二维码 VLESS(VLESS+gRPC+TLS)" echoContent yellow " ---> 二维码 VLESS(VLESS+gRPC+TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${VLESSID}%40${add}%3A${port}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dgrpc%26host%3D${host}%26path%3D${path}%23${VLESSEmail}" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${VLESSID}%40${add}%3A${port}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dgrpc%26host%3D${host}%26serviceName%3D${path}%26path%3D${path}%26alpn%3Dh2%23${VLESSEmail}"
elif [[ "${type}" == "trojan" ]]; then elif [[ "${type}" == "trojan" ]]; then
# URLEncode # URLEncode
echoContent yellow " ---> Trojan(TLS)" echoContent yellow " ---> Trojan(TLS)"
echoContent green " trojan://${id}@${host}:${port}?peer=${host}&sni=${host}#${host}_trojan\n" echoContent green " trojan://${id}@${host}:${port}?peer=${host}&sni=${host}&alpn=http1.1#${host}_trojan\n"
cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}" cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
trojan://${id}@${host}:${port}?peer=${host}&sni=${host}#${host}_trojan trojan://${id}@${host}:${port}?peer=${host}&sni=${host}&alpn=http1.1#${host}_trojan
EOF EOF
echoContent yellow " ---> 二维码 Trojan(TLS)" echoContent yellow " ---> 二维码 Trojan(TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${host}%3a${port}%3fpeer%3d${host}%26sni%3d${host}%23${host}_trojan\n" echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${host}%3a${port}%3fpeer%3d${host}%26sni%3d${host}%26alpn%3Dhttp1.1%23${host}_trojan\n"
elif [[ "${type}" == "trojangows" ]]; then elif [[ "${type}" == "trojangows" ]]; then
# URLEncode # URLEncode
@ -2486,40 +2563,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} echo
if [[ -n "${trojanUUID}" ]]; then defaultBase64Code trojan trojan $(echo "${user}" | jq -r .password) ${currentHost}
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 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
@ -2631,7 +2720,7 @@ unInstall() {
fi fi
handleV2Ray stop handleV2Ray stop
handleTrojanGo stop # handleTrojanGo stop
rm -rf /root/.acme.sh rm -rf /root/.acme.sh
echoContent green " ---> 删除acme.sh完成" echoContent green " ---> 删除acme.sh完成"
rm -rf /etc/systemd/system/v2ray.service rm -rf /etc/systemd/system/v2ray.service
@ -2696,25 +2785,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 用户管理
@ -2874,21 +2962,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
@ -2935,12 +3035,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
} }
@ -3362,7 +3467,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不可为空"
@ -3488,7 +3593,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不可为空"
@ -3641,7 +3746,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 "--------------------------------------------------------------"
@ -3671,18 +3777,18 @@ customV2RayInstall() {
installV2RayService 9 installV2RayService 9
initV2RayConfig custom 10 initV2RayConfig custom 10
cleanUp xrayDel cleanUp xrayDel
if echo ${selectCustomInstallType} | grep -q 4; then # if echo ${selectCustomInstallType} | grep -q 4; then
installTrojanGo 11 # installTrojanGo 11
installTrojanService 12 # installTrojanService 12
initTrojanGoConfig 13 # initTrojanGoConfig 13
handleTrojanGo stop # handleTrojanGo stop
handleTrojanGo start # handleTrojanGo start
else # else
# 这里需要删除trojan的服务 # # 这里需要删除trojan的服务
handleTrojanGo stop # handleTrojanGo stop
rm -rf /etc/v2ray-agent/trojan/* # rm -rf /etc/v2ray-agent/trojan/*
rm -rf /etc/systemd/system/trojan-go.service # rm -rf /etc/systemd/system/trojan-go.service
fi # fi
installCronTLS 14 installCronTLS 14
handleV2Ray stop handleV2Ray stop
handleV2Ray start handleV2Ray start
@ -3701,9 +3807,10 @@ customXrayInstall() {
echoContent yellow "VLESS前置默认安装0如果只需要安装0则只选择0即可" echoContent yellow "VLESS前置默认安装0如果只需要安装0则只选择0即可"
echoContent yellow "0.VLESS+TLS/XTLS+TCP" echoContent yellow "0.VLESS+TLS/XTLS+TCP"
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 "--------------------------------------------------------------"
@ -3734,17 +3841,20 @@ customXrayInstall() {
initXrayConfig custom 10 initXrayConfig custom 10
cleanUp v2rayDel cleanUp v2rayDel
if echo "${selectCustomInstallType}" | grep -q 4; then if echo "${selectCustomInstallType}" | grep -q 4; then
installTrojanGo 11 # installTrojanGo 11
installTrojanService 12 # installTrojanService 12
initTrojanGoConfig 13 # initTrojanGoConfig 13
handleTrojanGo stop # handleTrojanGo stop
handleTrojanGo start # handleTrojanGo start
echo
else else
# 这里需要删除trojan的服务 # 这里需要删除trojan的服务
handleTrojanGo stop # handleTrojanGo stop
rm -rf /etc/v2ray-agent/trojan/* # rm -rf /etc/v2ray-agent/trojan/*
rm -rf /etc/systemd/system/trojan-go.service # rm -rf /etc/systemd/system/trojan-go.service
echo
fi fi
installCronTLS 14 installCronTLS 14
handleXray stop handleXray stop
handleXray start handleXray start
@ -3812,12 +3922,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
@ -3825,9 +3935,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
@ -3849,12 +3959,12 @@ xrayCoreInstall() {
handleV2Ray stop handleV2Ray stop
installXray 7 installXray 7
installXrayService 8 installXrayService 8
installTrojanGo 9 # installTrojanGo 9
installTrojanService 10 # installTrojanService 10
customCDNIP 11 customCDNIP 11
initXrayConfig all 12 initXrayConfig all 12
cleanUp v2rayDel cleanUp v2rayDel
initTrojanGoConfig 13 # initTrojanGoConfig 13
installCronTLS 14 installCronTLS 14
nginxBlog 15 nginxBlog 15
updateRedirectNginxConf updateRedirectNginxConf
@ -3863,9 +3973,9 @@ xrayCoreInstall() {
handleXray start handleXray 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
@ -3954,13 +4064,11 @@ 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.9" echoContent green "当前版本v2.5.10"
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
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent red "VMess+TLS+TCP(http+tls),将在未来几个版本脚本中移除"
echoContent red "=============================================================="
if [[ -n "${coreInstallType}" ]]; then if [[ -n "${coreInstallType}" ]]; then
echoContent yellow "1.重新安装" echoContent yellow "1.重新安装"
else else
@ -3979,12 +4087,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
@ -4023,19 +4131,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