feat(脚本): 增加tcp+tls

pull/534/merge
mack-a 2020-08-27 16:57:42 +08:00
parent 0d9910fb2d
commit f17c3b90e4
1 changed files with 140 additions and 73 deletions

View File

@ -6,6 +6,7 @@ upgrade="yum -y update"
echoType='echo -e' echoType='echo -e'
domain= domain=
add= add=
globalType=
customPath=alone customPath=alone
centosVersion=0 centosVersion=0
installProgress=0 installProgress=0
@ -94,6 +95,11 @@ installTools(){
# yum-utils # yum-utils
yum install yum-utils -y > /dev/null 2>&1 yum install yum-utils -y > /dev/null 2>&1
fi fi
# 修复ubuntu个别系统问题
if [[ "${release}" = "ubuntu" ]]
then
dpkg --configure -a
fi
if [[ ! -z `ps -ef|grep -v grep|grep apt` ]] if [[ ! -z `ps -ef|grep -v grep|grep apt` ]]
then then
@ -289,7 +295,7 @@ installTLS(){
# 安装Nginx科学上网配置 # 安装Nginx科学上网配置
initNginxConfig(){ initNginxConfig(){
installType=$1 installType=$1
if [[ "${installType}" = "WSS" ]] if [[ "${installType}" = "wss" ]]
then then
cat << EOF > /etc/nginx/conf.d/alone.conf cat << EOF > /etc/nginx/conf.d/alone.conf
server { server {
@ -463,6 +469,9 @@ installV2Ray(){
checkGFWStatue(){ checkGFWStatue(){
# 验证整个服务是否可用 # 验证整个服务是否可用
progressTools "yellow" "验证服务是否可用--->" progressTools "yellow" "验证服务是否可用--->"
if [[ "${globalType}" = "wss" ]]
then
sleep 1 sleep 1
if [[ ! -z `curl -s -L https://${domain}/${customPath}|grep -v grep|grep "Bad Request"` ]] if [[ ! -z `curl -s -L https://${domain}/${customPath}|grep -v grep|grep "Bad Request"` ]]
then then
@ -472,6 +481,24 @@ checkGFWStatue(){
progressTools "red" " 错误日志:`curl -s -L https://${domain}/${customPath}`" progressTools "red" " 错误日志:`curl -s -L https://${domain}/${customPath}`"
exit 0 exit 0
fi fi
elif [[ "${globalType}" = "tcp" ]]
then
echo '' > /etc/v2ray/v2ray_access_ws_tls.log
curl --connect-time 3 --max-time 1 --url https://${domain} > /dev/null 2>&1
sleep 0.1
if [[ ! -z `cat /etc/v2ray/v2ray_access_ws_tls.log|grep -v grep|grep "Not Found"` ]]
then
progressTools "green" " 服务可用--->"
else
progressTools "red" " 服务不可用"
progressTools "red" " 1.请检查云朵是否关闭"
progressTools "red" " 2.请手动尝试使用账号并观察日志,日志路径[/etc/v2ray/v2ray_access_ws_tls.log]"
exit 0
fi
fi
} }
# 开机自启 # 开机自启
installV2RayService(){ installV2RayService(){
@ -691,7 +718,7 @@ initV2RayConfig(){
} }
} }
EOF EOF
elif [[ "$1" = "WSS" ]] elif [[ "$1" = "wss" ]]
then then
cat << EOF > /etc/v2ray/config.json cat << EOF > /etc/v2ray/config.json
{ {
@ -700,31 +727,6 @@ EOF
"error":"/etc/v2ray/v2ray_error_ws_tls.log", "error":"/etc/v2ray/v2ray_error_ws_tls.log",
"loglevel":"debug" "loglevel":"debug"
}, },
"stats":{
},
"api":{
"services":[
"StatsService"
],
"tag":"api"
},
"policy":{
"levels":{
"1":{
"handshake":4,
"connIdle":300,
"uplinkOnly":2,
"downlinkOnly":5,
"statsUserUplink":false,
"statsUserDownlink":false
}
},
"system":{
"statsInboundUplink":true,
"statsInboundDownlink":true
}
},
"allocate":{ "allocate":{
"strategy":"always", "strategy":"always",
"refresh":5, "refresh":5,
@ -738,7 +740,7 @@ EOF
"clients":[ "clients":[
{ {
"id":"${uuid}", "id":"${uuid}",
"alterId":64, "alterId":0,
"level":1, "level":1,
"email":"test@v2ray.com" "email":"test@v2ray.com"
} }
@ -758,7 +760,7 @@ EOF
"clients":[ "clients":[
{ {
"id":"${uuid}", "id":"${uuid}",
"alterId":64, "alterId":0,
"level":1, "level":1,
"email":"test_vless@v2ray.com" "email":"test_vless@v2ray.com"
} }
@ -784,20 +786,6 @@ EOF
} }
} }
], ],
"routing":{
"settings":{
"rules":[
{
"inboundTag":[
"api"
],
"outboundTag":"api",
"type":"field"
}
]
},
"strategy":"rules"
},
"dns":{ "dns":{
"servers":[ "servers":[
"8.8.8.8", "8.8.8.8",
@ -807,14 +795,58 @@ EOF
} }
} }
EOF EOF
elif [[ "$1" = "tls" ]]
then
cat << EOF > /etc/v2ray/config.json
{
"log":{
"access":"/etc/v2ray/v2ray_access_ws_tls.log",
"error":"/etc/v2ray/v2ray_error_ws_tls.log",
"loglevel":"debug"
},
"inbounds": [
{
"port": 443,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "${uuid}",
"alterId": 0
}
]
},
"streamSettings": {
"network": "tcp",
"security": "tls",
"tlsSettings": {
"certificates": [
{
"certificateFile": "/etc/nginx/v2ray-agent-https/${domain}.crt",
"keyFile": "/etc/nginx/v2ray-agent-https/${domain}.key"
}
]
}
}
}
],
"outbounds":[
{
"protocol": "freedom",
"settings": {}
}
],
"dns":{
"servers":[
"8.8.8.8",
"8.8.4.4"
],
"tag":"dns_inbound"
}
}
EOF
fi fi
# 自定义路径
# if [[ ! -z "${customPath}" ]]
# then
# sed -i "s/alone/${1}/g" `grep alone -rl /etc/v2ray/config.json`
# sed -i "s/vlesspath/${1}vld/g" `grep vlesspath -rl /etc/v2ray/config.json`
# fi
# sed -i "s/654765fe-5fb1-271f-7c3f-18ed82827f72/${uuid}/g" `grep 654765fe-5fb1-271f-7c3f-18ed82827f72 -rl /etc/v2ray/config.json`
} }
# 自定义CDN IP # 自定义CDN IP
customCDNIP(){ customCDNIP(){
@ -842,7 +874,7 @@ buildAccounts(){
path=`echo ${user}|jq .streamSettings.wsSettings.path` path=`echo ${user}|jq .streamSettings.wsSettings.path`
echoContent yellow "客户端链接--->\n" echoContent yellow "客户端链接--->\n"
defaultBase64Code "${ps}" "${id}" "${host}" "${path}" "${add}" defaultBase64Code "${ps}" "${id}" "${host}" "${path}" "${add}"
quanMultBase64Code "${ps}" "${id}" "${host}" "${path}" "${add}" # quanMultBase64Code "${ps}" "${id}" "${host}" "${path}" "${add}"
} }
# 通用 # 通用
defaultBase64Code(){ defaultBase64Code(){
@ -851,17 +883,32 @@ defaultBase64Code(){
local host=$3 local host=$3
local path=$4 local path=$4
local add=$5 local add=$5
if [[ ${globalType} = "tcp" ]]
qrCodeBase64Default=`echo -n '{"port":"443","ps":"'${ps}'","tls":"tls","id":'"${id}"',"aid":"64","v":"2","host":"'${host}'","type":"none","path":'${path}',"net":"ws","add":"'${add}'"}'|sed 's#/#\\\/#g'|base64` then
qrCodeBase64Default=`echo -n '{"port":"443","ps":"'${ps}'","tls":"tls","id":'"${id}"',"aid":"0","v":"2","host":"'${host}'","type":"none","net":"tcp","add":"'${host}'","allowInsecure":0,"method":"none","peer":""}'|sed 's#/#\\\/#g'|base64`
qrCodeBase64Default=`echo ${qrCodeBase64Default}|sed 's/ //g'` qrCodeBase64Default=`echo ${qrCodeBase64Default}|sed 's/ //g'`
echoContent red "通用json--->" "no"
echoContent green ' {"port":"443","ps":"'${ps}'","tls":"tls","id":'"${id}"',"aid":"0","v":"2","host":"'${host}'","type":"none","net":"tcp","add":"'${host}'","allowInsecure":0,"method":"none","peer":""}\n'
elif [[ ${globalType} = "wss" ]]
then
qrCodeBase64Default=`echo -n '{"port":"443","ps":"'${ps}'","tls":"tls","id":'"${id}"',"aid":"0","v":"2","host":"'${host}'","type":"none","path":'${path}',"net":"ws","add":"'${add}'","allowInsecure":0,"method":"none","peer":""}'|sed 's#/#\\\/#g'|base64`
qrCodeBase64Default=`echo ${qrCodeBase64Default}|sed 's/ //g'`
echoContent red "通用json--->" "no"
echoContent green ' {"port":"443","ps":"'${ps}'","tls":"tls","id":'"${id}"',"aid":"0","v":"2","host":"'${host}'","type":"none","path":'${path}',"net":"ws","add":"'${add}'","allowInsecure":0,"method":"none","peer":""}\n'
elif [[ "${globalType}" = "h2" ]]
then
qrCodeBase64Default=`echo -n '{"port":"443","ps":"'${ps}'","tls":"tls","id":'"${id}"',"aid":"0","v":"2","host":"'${host}'","type":"none","path":'${path}',"net":"h2","add":"'${add}'","allowInsecure":0,"method":"none","peer":""}'|sed 's#/#\\\/#g'|base64`
qrCodeBase64Default=`echo ${qrCodeBase64Default}|sed 's/ //g'`
echoContent red "通用json--->" "no"
echoContent green ' {"port":"443","ps":"'${ps}'","tls":"tls","id":'"${id}"',"aid":"0","v":"2","host":"'${host}'","type":"none","path":'${path}',"net":"h2","add":"'${add}'","allowInsecure":0,"method":"none","peer":""}\n'
fi
# 通用Vmess # 通用Vmess
echoContent red "通用vmess链接--->" "no" echoContent red "通用vmess链接--->" "no"
echoContent green " vmess://${qrCodeBase64Default}\n" echoContent green " vmess://${qrCodeBase64Default}\n"
echo "通用vmess链接: " > /etc/v2ray/usersv2ray.conf echo "通用vmess链接: " > /etc/v2ray/usersv2ray.conf
echo " vmess://${qrCodeBase64Default}" >> /etc/v2ray/usersv2ray.conf echo " vmess://${qrCodeBase64Default}" >> /etc/v2ray/usersv2ray.conf
echoContent red "通用json--->" "no" # echoContent green ' V2Ray v4.27.0 目前无通用订阅需要手动配置VLESS和上面大部分一样path则是"'/${2}vld'",其余内容不变'
echoContent green ' {"port":"443","ps":"'${ps}'","tls":"tls","id":'"${id}"',"aid":"64","v":"2","host":"'${host}'","type":"none","path":'${path}',"net":"ws","add":"'${add}'"}\n'
echoContent green ' V2Ray v4.27.0 目前无通用订阅需要手动配置VLESS和上面大部分一样path则是"'/${2}vld'",其余内容不变'
} }
# quanMult base64Code # quanMult base64Code
quanMultBase64Code(){ quanMultBase64Code(){
@ -958,11 +1005,11 @@ menu(){
mkdirTools mkdirTools
cd cd
echoContent red "==============================================================" echoContent red "=============================================================="
echoContent green "V2Ray+WSS+Nginx+Web/TLS+TCP+V2Ray/VLESS+TCP+V2Ray+Web一键脚本" echoContent green "V2Ray+wss+Nginx+Web/TLS+TCP+V2Ray/VLESS+TCP+V2Ray+Web一键脚本"
echoContent green "作者mack-a" echoContent green "作者mack-a" no
echoContent green "Versionv1.0.9" echoContent green "Versionv1.0.9" no
echoContent red "==============================================================" echoContent red "=============================================================="
echoContent yellow "1.V2Ray+WSS+Nginx+Web" "no" echoContent yellow "1.V2Ray+wss+Nginx+Web" "no"
echoContent yellow "2.TLS+TCP+V2Ray" "no" echoContent yellow "2.TLS+TCP+V2Ray" "no"
echoContent yellow "3.VLESS+TCP+V2Ray+Web" "no" echoContent yellow "3.VLESS+TCP+V2Ray+Web" "no"
echoContent yellow "4.状态展示" "no" echoContent yellow "4.状态展示" "no"
@ -970,7 +1017,8 @@ menu(){
echoContent yellow "6.卸载脚本" "no" echoContent yellow "6.卸载脚本" "no"
echoContent red "==============================================================" echoContent red "=============================================================="
read -p "请选择:" read -p "请选择:"
installV2RayWSSNginxWeb # installV2RaywssNginxWeb
installV2RayTCPTLS
exit 0; exit 0;
# =============== # ===============
# todo 这里判断每次安装的内容 # todo 这里判断每次安装的内容
@ -1032,18 +1080,19 @@ menu(){
exit 0; exit 0;
fi fi
} }
# 安装V2Ray+WSS+Nginx+Web # 安装V2Ray+wss+Nginx+Web
installV2RayWSSNginxWeb(){ installV2RaywssNginxWeb(){
globalType=wss
installTools installTools
initTLSNginxConfig initTLSNginxConfig
installTLS installTLS
handleNginx stop handleNginx stop
initNginxConfig WSS initNginxConfig wss
randomPathFunction randomPathFunction
installCronTLS installCronTLS
installV2Ray installV2Ray
installV2RayService installV2RayService
initV2RayConfig WSS initV2RayConfig wss
handleV2Ray start handleV2Ray start
handleNginx start handleNginx start
customCDNIP customCDNIP
@ -1051,6 +1100,24 @@ installV2RayWSSNginxWeb(){
checkGFWStatue checkGFWStatue
progressTools "yellow" "安装完毕[100%]--->" progressTools "yellow" "安装完毕[100%]--->"
} }
# 安装V2Ray+TLS
installV2RayTCPTLS(){
globalType=tcp
installTools
# 申请tls
initTLSNginxConfig
installTLS
handleNginx stop
# 安装V2Ray
installV2Ray
installV2RayService
initV2RayConfig tls
handleV2Ray start
# 生成账号
checkGFWStatue tcp
buildAccounts
progressTools "yellow" "安装完毕[100%]--->"
}
# 注意事项 # 注意事项
warningMessage(){ warningMessage(){
echoContent green "1.脚本会检查并安装工具包" echoContent green "1.脚本会检查并安装工具包"