feat(脚本): 添加hysteria、优化dns申请证书提示,并添加教程

pull/534/merge
mack-a 2022-11-08 15:04:46 +08:00
parent 127fadcd9b
commit b715e86283
3 changed files with 451 additions and 75 deletions

View File

@ -0,0 +1,3 @@
# dns添加TXT记录
## 1.cloudflare
<img src="https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/cloudflare/cloudflare_dns_txt.png" width=700>

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -83,12 +83,12 @@ checkCPUVendor() {
'amd64' | 'x86_64')
xrayCoreCPUVendor="Xray-linux-64"
v2rayCoreCPUVendor="v2ray-linux-64"
# hysteriaCoreCPUVendor="hysteria-linux-amd64"
hysteriaCoreCPUVendor="hysteria-linux-amd64"
;;
'armv8' | 'aarch64')
xrayCoreCPUVendor="Xray-linux-arm64-v8a"
v2rayCoreCPUVendor="v2ray-linux-arm64-v8a"
# hysteriaCoreCPUVendor="hysteria-linux-arm64"
hysteriaCoreCPUVendor="hysteria-linux-arm64"
;;
*)
echo " 不支持此CPU架构--->"
@ -113,7 +113,7 @@ initVar() {
# 核心支持的cpu版本
xrayCoreCPUVendor=""
v2rayCoreCPUVendor=""
# hysteriaCoreCPUVendor=""
hysteriaCoreCPUVendor=""
# 域名
domain=
@ -153,6 +153,9 @@ initVar() {
# v2ray-core、xray-core配置文件的路径
configPath=
# hysteria 配置文件的路径
hysteriaConfigPath=
# 配置文件的path
currentPath=
@ -214,6 +217,22 @@ initVar() {
# 自定义端口
customPort=
# hysteria端口
hysteriaPort=
# hysteria协议
hysteriaProtocol=
# hysteria延迟
hysteriaLag=
# hysteria下行速度
hysteriaClientDownloadSpeed=
# hysteria上行速度
hysteriaClientUploadSpeed=
}
# 读取tls证书详情
@ -239,6 +258,7 @@ readCustomPort() {
readInstallType() {
coreInstallType=
configPath=
hysteriaConfigPath=
# 1.检测安装目录
if [[ -d "/etc/v2ray-agent" ]]; then
@ -267,6 +287,14 @@ readInstallType() {
coreInstallType=1
fi
fi
if [[ -d "/etc/v2ray-agent/hysteria" && -f "/etc/v2ray-agent/hysteria/hysteria" ]]; then
# 这里检测 hysteria
if [[ -d "/etc/v2ray-agent/hysteria/conf" ]] && [[ -f "/etc/v2ray-agent/hysteria/conf/config.json" ]] && [[ -f "/etc/v2ray-agent/hysteria/conf/client_network.json" ]]; then
hysteriaConfigPath=/etc/v2ray-agent/hysteria/conf/
fi
fi
fi
}
@ -299,6 +327,10 @@ readInstallProtocolType() {
currentInstallProtocolType=${currentInstallProtocolType}'5'
fi
done < <(find ${configPath} -name "*inbounds.json" | awk -F "[.]" '{print $1}')
if [[ -n "${hysteriaConfigPath}" ]]; then
currentInstallProtocolType=${currentInstallProtocolType}'6'
fi
}
# 检查是否安装宝塔
@ -390,6 +422,17 @@ checkFirewalldAllowPort() {
exit 0
fi
}
# 读取hysteria网络环境
readHysteriaConfig() {
if [[ -n "${hysteriaConfigPath}" ]]; then
hysteriaLag=$(jq -r .hysteriaLag <"${hysteriaConfigPath}client_network.json")
hysteriaClientDownloadSpeed=$(jq -r .hysteriaClientDownloadSpeed <"${hysteriaConfigPath}client_network.json")
hysteriaClientUploadSpeed=$(jq -r .hysteriaClientUploadSpeed <"${hysteriaConfigPath}client_network.json")
hysteriaPort=$(jq -r .listen <"${hysteriaConfigPath}config.json" | awk -F "[:]" '{print $2}')
hysteriaProtocol=$(jq -r .protocol <"${hysteriaConfigPath}config.json")
fi
}
# 检查文件目录以及path路径
readConfigHostPathUUID() {
currentPath=
@ -563,7 +606,7 @@ mkdirTools() {
mkdir -p /etc/v2ray-agent/xray/conf
mkdir -p /etc/v2ray-agent/xray/tmp
mkdir -p /etc/v2ray-agent/trojan
# mkdir -p /etc/v2ray-agent/hysteria/conf
mkdir -p /etc/v2ray-agent/hysteria/conf
mkdir -p /etc/systemd/system/
mkdir -p /tmp/v2ray-agent-tls/
}
@ -1036,8 +1079,10 @@ checkIP() {
echoContent yellow " ---> 2.检查域名dns解析是否正确"
echoContent yellow " ---> 3.如解析正确请等待dns生效预计三分钟内生效"
echoContent yellow " ---> 4.如报Nginx启动问题请手动启动nginx查看错误如自己无法处理请提issues"
echoContent yellow " ---> 5.错误日志:${localIP}"
echo
echoContent skyBlue " ---> 如以上设置都正确,请重新安装纯净系统后再次尝试"
if [[ -n ${localIP} ]]; then
echoContent yellow " ---> 检测返回值异常建议手动卸载nginx后重新执行脚本"
fi
@ -1126,7 +1171,9 @@ switchSSLType() {
fi
}
acmeInstallSSL() {
# 选择acme安装证书方式
selectAcmeInstallSSL() {
local installSSLIPv6=
if echo "${localIP}" | grep -q ":"; then
installSSLIPv6="--listen-v6"
@ -1145,7 +1192,13 @@ acmeInstallSSL() {
dnsSSLStatus=true
fi
fi
acmeInstallSSL
readAcmeTLS
}
# 安装SSL证书
acmeInstallSSL() {
if [[ "${dnsSSLStatus}" == "true" ]]; then
sudo "$HOME/.acme.sh/acme.sh" --issue -d "*.${dnsTLSDomain}" --dns --yes-I-know-dns-manual-mode-enough-go-ahead-please --standalone -k ec-256 --server "${sslType}" ${installSSLIPv6} 2>&1 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
@ -1154,6 +1207,7 @@ acmeInstallSSL() {
txtValue=$(tail -n 10 /etc/v2ray-agent/tls/acme.log | grep "TXT value" | awk -F "'" '{print $2}')
if [[ -n "${txtValue}" ]]; then
echoContent green " ---> 请手动添加DNS TXT记录"
echoContent yellow " ---> 添加方法请参考此教程https://github.com/mack-a/v2ray-agent/blob/master/documents/dns_txt.md"
echoContent green " ---> name_acme-challenge"
echoContent green " ---> value${txtValue}"
echoContent yellow " ---> 添加完成后等请等待1-2分钟"
@ -1168,7 +1222,7 @@ acmeInstallSSL() {
sudo "$HOME/.acme.sh/acme.sh" --renew -d "*.${dnsTLSDomain}" --yes-I-know-dns-manual-mode-enough-go-ahead-please --ecc --server "${sslType}" ${installSSLIPv6} 2>&1 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
else
echoContent red " ---> 验证失败请等待1-2分钟后重新尝试"
exit 0
acmeInstallSSL
fi
else
echoContent red " ---> 放弃"
@ -1179,7 +1233,6 @@ acmeInstallSSL() {
echoContent green " ---> 生成证书中"
sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server "${sslType}" ${installSSLIPv6} 2>&1 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
fi
readAcmeTLS
}
# 自定义端口
customPortFunction() {
@ -1194,7 +1247,7 @@ customPortFunction() {
if [[ "${historyCustomPortStatus}" == "n" || -z "${customPort}" ]]; then
echo
echoContent yellow "请输入自定义端口[例: 2083]自定义端口后只允许使用DNS申请证书[回车]使用443"
echoContent yellow "请输入端口[默认: 443]如自定义端口只允许使用DNS申请证书[回车使用默认]"
read -r -p "端口:" customPort
if [[ -n "${customPort}" ]]; then
if ((customPort >= 1 && customPort <= 65535)); then
@ -1246,7 +1299,7 @@ installTLS() {
if [[ "${installDNSACMEStatus}" != "true" ]]; then
switchSSLType
customSSLEmail
acmeInstallSSL
selectAcmeInstallSSL
else
echoContent green " ---> 检测到已安装通配符证书,自动生成中"
fi
@ -1548,6 +1601,33 @@ installV2Ray() {
fi
}
# 安装 hysteria
installHysteria() {
readInstallType
echoContent skyBlue "\n进度 $1/${totalProgress} : 安装Hysteria"
if [[ -z "${hysteriaConfigPath}" ]]; then
version=$(curl -s https://api.github.com/repos/HyNetwork/hysteria/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
echoContent green " ---> Hysteria版本:${version}"
if wget --help | grep -q show-progress; then
wget -c -q --show-progress -P /etc/v2ray-agent/hysteria/ "https://github.com/HyNetwork/hysteria/releases/download/${version}/${hysteriaCoreCPUVendor}"
else
wget -c -P /etc/v2ray-agent/hysteria/ "https://github.com/HyNetwork/hysteria/releases/download/${version}/${hysteriaCoreCPUVendor}" >/dev/null 2>&1
fi
mv "/etc/v2ray-agent/hysteria/${hysteriaCoreCPUVendor}" /etc/v2ray-agent/hysteria/hysteria
chmod 655 /etc/v2ray-agent/hysteria/hysteria
else
echoContent green " ---> Hysteria版本:$(/etc/v2ray-agent/hysteria/hysteria --version | awk '{print $3}')"
read -r -p "是否更新、升级?[y/n]:" reInstallHysteriaStatus
if [[ "${reInstallHysteriaStatus}" == "y" ]]; then
rm -f /etc/v2ray-agent/hysteria/hysteria
installHysteria "$1"
fi
fi
}
# 安装xray
installXray() {
readInstallType
@ -1861,6 +1941,39 @@ EOF
fi
}
# 安装hysteria开机自启
installHysteriaService() {
echoContent skyBlue "\n进度 $1/${totalProgress} : 配置Hysteria开机自启"
if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
rm -rf /etc/systemd/system/hysteria.service
touch /etc/systemd/system/hysteria.service
execStart='/etc/v2ray-agent/hysteria/hysteria --log-level info -c /etc/v2ray-agent/hysteria/conf/config.json server'
cat <<EOF >/etc/systemd/system/hysteria.service
[Unit]
Description=Hysteria Service
Documentation=https://github.com/HyNetwork/hysteria/wiki
After=network.target nss-lookup.target
Wants=network-online.target
[Service]
Type=simple
User=root
CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW
NoNewPrivileges=yes
ExecStart=${execStart}
Restart=on-failure
RestartPreventExitStatus=23
LimitNPROC=10000
LimitNOFILE=1000000
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable hysteria.service
echoContent green " ---> 配置Hysteria开机自启成功"
fi
}
# Xray开机自启
installXrayService() {
echoContent skyBlue "\n进度 $1/${totalProgress} : 配置Xray开机自启"
@ -1925,6 +2038,37 @@ handleV2Ray() {
fi
fi
}
# 操作Hysteria
handleHysteria() {
# shellcheck disable=SC2010
if find /bin /usr/bin | grep -q systemctl && ls /etc/systemd/system/ | grep -q hysteria.service; then
if [[ -z $(pgrep -f "hysteria/hysteria") ]] && [[ "$1" == "start" ]]; then
systemctl start hysteria.service
elif [[ -n $(pgrep -f "hysteria/hysteria") ]] && [[ "$1" == "stop" ]]; then
systemctl stop hysteria.service
fi
fi
sleep 0.8
if [[ "$1" == "start" ]]; then
if [[ -n $(pgrep -f "hysteria/hysteria") ]]; then
echoContent green " ---> Hysteria启动成功"
else
echoContent red "Hysteria启动失败"
echoContent red "请手动执行【/etc/v2ray-agent/hysteria/hysteria --log-level debug -c /etc/v2ray-agent/hysteria/conf/config.json server】查看错误日志"
exit 0
fi
elif [[ "$1" == "stop" ]]; then
if [[ -z $(pgrep -f "hysteria/hysteria") ]]; then
echoContent green " ---> Hysteria关闭成功"
else
echoContent red "Hysteria关闭失败"
echoContent red "请手动执行【ps -ef|grep -v grep|grep hysteria|awk '{print \$2}'|xargs kill -9】"
exit 0
fi
fi
}
# 操作xray
handleXray() {
if [[ -n $(find /bin /usr/bin -name "systemctl") ]] && [[ -n $(find /etc/systemd/system/ -name "xray.service") ]]; then
@ -1983,10 +2127,121 @@ addClients() {
echo "${config}" | jq . >"${path}"
fi
}
# 添加hysteria配置
addClientsHysteria() {
local path=$1
local addClientsStatus=$2
if [[ ${addClientsStatus} == "true" && -n "${previousClients}" ]]; then
local uuids=
uuids=$(echo "${previousClients}" | jq -r [.[].id])
config=$(jq -r ".auth.config = ${uuids}" "${path}")
echo "${config}" | jq . >"${path}"
fi
}
# 初始化hysteria端口
initHysteriaPort() {
echoContent yellow "请输入Hysteria端口[例: 10000],不可与其他服务重复"
read -r -p "端口:" hysteriaPort
if [[ -z ${hysteriaPort} ]]; then
echoContent red "\n ---> 端口不可为空"
initHysteriaPort "$2"
elif ((customPort >= 1 && customPort <= 65535)); then
echoContent red "\n ---> 端口不合法"
initHysteriaPort "$2"
fi
allowPort "${hysteriaPort}"
}
# 初始化hysteria的协议
initHysteriaProtocol() {
echoContent skyBlue "\n请选择协议类型"
echoContent red "=============================================================="
echoContent yellow "1.udp(QUIC)(默认)"
echoContent yellow "2.faketcp"
echoContent yellow "3.wechat-video"
echoContent red "=============================================================="
read -r -p "请选择:" selectHysteriaProtocol
case ${selectHysteriaProtocol} in
1)
hysteriaProtocol="udp"
;;
2)
hysteriaProtocol="faketcp"
;;
3)
hysteriaProtocol="wechat-video"
;;
*)
hysteriaProtocol="udp"
;;
esac
}
# 初始化hysteria网络信息
initHysteriaNetwork() {
echoContent yellow "请输入本地到服务器的平均延迟请按照真实情况填写默认180单位ms"
read -r -p "延迟:" hysteriaLag
if [[ -z "${hysteriaLag}" ]]; then
hysteriaLag=180
fi
echoContent yellow "请输入本地带宽峰值的下行速度默认100单位Mbps"
read -r -p "延迟:" hysteriaClientDownloadSpeed
if [[ -z "${hysteriaClientDownloadSpeed}" ]]; then
hysteriaClientDownloadSpeed=100
fi
echoContent yellow "请输入本地带宽峰值的上行速度默认50单位Mbps"
read -r -p "延迟:" hysteriaClientUploadSpeed
if [[ -z "${hysteriaClientUploadSpeed}" ]]; then
hysteriaClientUploadSpeed=50
fi
cat <<EOF >/etc/v2ray-agent/hysteria/conf/client_network.json
{
"hysteriaLag":"${hysteriaLag}",
"hysteriaClientUploadSpeed":"${hysteriaClientUploadSpeed}",
"hysteriaClientDownloadSpeed":"${hysteriaClientDownloadSpeed}"
}
EOF
}
# 初始化Hysteria配置
initHysteriaConfig() {
echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化Hysteria配置"
echoContent skyBlue "\n进度 $1/${totalProgress} : 初始化Hysteria配置"
initHysteriaPort
initHysteriaProtocol
initHysteriaNetwork
getClients "${configPath}/02_VLESS_TCP_inbounds.json" true
cat <<EOF >/etc/v2ray-agent/hysteria/conf/config.json
{
"listen": ":${hysteriaPort}",
"protocol": "udp",
"disable_udp": false,
"cert": "/etc/v2ray-agent/tls/${currentHost}.crt",
"key": "/etc/v2ray-agent/tls/${currentHost}.key",
"auth": {
"mode": "passwords",
"config": []
},
"up_mbps":${hysteriaClientUploadSpeed},
"down_mbps":${hysteriaClientDownloadSpeed},
"alpn": "h3",
"recv_window_conn": 15728640,
"recv_window_client": 67108864,
"max_conn_client": 4096,
"disable_mtu_discovery": true,
"resolve_preference": "46",
"resolver": "https://8.8.8.8:443/dns-query"
}
EOF
addClientsHysteria "/etc/v2ray-agent/hysteria/conf/config.json" true
}
# 初始化V2Ray 配置文件
@ -2105,7 +2360,7 @@ EOF
"clients": [
{
"password": "${uuid}",
"email": "${domain}_trojan_tcp"
"email": "${domain}_${uuid}"
}
],
"fallbacks":[
@ -2142,7 +2397,7 @@ EOF
"clients": [
{
"id": "${uuid}",
"email": "${domain}_VLESS_WS"
"email": "${domain}_${uuid}"
}
],
"decryption": "none"
@ -2180,7 +2435,7 @@ EOF
"clients": [
{
"password": "${uuid}",
"email": "${domain}_trojan_gRPC"
"email": "${domain}_${uuid}"
}
],
"fallbacks": [
@ -2222,7 +2477,7 @@ EOF
"id": "${uuid}",
"alterId": 0,
"add": "${add}",
"email": "${domain}_vmess_ws"
"email": "${domain}_${uuid}"
}
]
},
@ -2256,7 +2511,7 @@ EOF
{
"id": "${uuid}",
"add": "${add}",
"email": "${domain}_VLESS_gRPC"
"email": "${domain}_${uuid}"
}
],
"decryption": "none"
@ -2518,7 +2773,7 @@ EOF
"clients": [
{
"password": "${uuid}",
"email": "${domain}_trojan_tcp"
"email": "${domain}_${uuid}"
}
],
"fallbacks":[
@ -2555,7 +2810,7 @@ EOF
"clients": [
{
"id": "${uuid}",
"email": "${domain}_VLESS_WS"
"email": "${domain}_${uuid}"
}
],
"decryption": "none"
@ -2593,7 +2848,7 @@ EOF
"clients": [
{
"password": "${uuid}",
"email": "${domain}_trojan_gRPC"
"email": "${domain}_${uuid}"
}
],
"fallbacks": [
@ -2633,7 +2888,7 @@ EOF
"id": "${uuid}",
"alterId": 0,
"add": "${add}",
"email": "${domain}_vmess_ws"
"email": "${domain}_${uuid}"
}
]
},
@ -2667,7 +2922,7 @@ EOF
{
"id": "${uuid}",
"add": "${add}",
"email": "${domain}_VLESS_gRPC"
"email": "${domain}_${uuid}"
}
],
"decryption": "none"
@ -2705,7 +2960,7 @@ EOF
"id": "${uuid}",
"add":"${add}",
"flow":"xtls-rprx-direct",
"email": "${domain}_VLESS_XTLS/TLS-direct_TCP"
"email": "${domain}_${uuid}"
}
],
"decryption": "none",
@ -2963,6 +3218,15 @@ trojan://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&peer=${curren
EOF
echoContent yellow " ---> 二维码 Trojan gRPC(TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${currentAdd}%3a${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dtls%26peer%3d${currentHost}%26type%3Dgrpc%26sni%3d${currentHost}%26path%3D${currentPath}trojangrpc%26alpn%3Dh2%26serviceName%3D${currentPath}trojangrpc%23${email}\n"
elif [[ "${type}" == "hysteria" ]]; then
echoContent yellow " ---> Hysteria(TLS)"
echoContent green " hysteria://${currentHost}:${hysteriaPort}?protocol=${hysteriaProtocol}&auth=${id}&peer=${currentHost}&insecure=0&alpn=h3&upmbps=${hysteriaClientUploadSpeed}&downmbps=${hysteriaClientDownloadSpeed}#${email}\n"
cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
hysteria://${currentHost}:${hysteriaPort}?protocol=${hysteriaProtocol}&auth=${id}&peer=${currentHost}&insecure=0&alpn=h3&upmbps=${hysteriaClientUploadSpeed}&downmbps=${hysteriaClientDownloadSpeed}#${email}
EOF
echoContent yellow " ---> 二维码 Hysteria(TLS)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=hysteria%3A%2F%2F${currentHost}%3A${hysteriaPort}%3Fprotocol%3D${hysteriaProtocol}%26auth%3D${id}%26peer%3D${currentHost}%26insecure%3D0%26alpn%3Dh3%26upmbps%3D${hysteriaClientUploadSpeed}%26downmbps%3D${hysteriaClientDownloadSpeed}%23${email}\n"
fi
}
@ -2972,6 +3236,7 @@ showAccounts() {
readInstallType
readInstallProtocolType
readConfigHostPathUUID
readHysteriaConfig
echoContent skyBlue "\n进度 $1/${totalProgress} : 账号"
local show
# VLESS TCP
@ -2980,16 +3245,21 @@ showAccounts() {
if echo "${currentInstallProtocolType}" | grep -q trojan; then
echoContent skyBlue "===================== Trojan TCP TLS/XTLS-direct/XTLS-splice ======================\n"
jq .inbounds[0].settings.clients ${configPath}02_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .email)"
defaultBase64Code trojanTCPXTLS "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .password)"
local email=
email=$(echo "${user}" | jq -r .email)
echoContent skyBlue "\n ---> 账号:${email}"
defaultBase64Code trojanTCPXTLS "${email}" "$(echo "${user}" | jq -r .password)"
done
else
echoContent skyBlue "===================== VLESS TCP TLS/XTLS-direct/XTLS-splice ======================\n"
jq .inbounds[0].settings.clients ${configPath}02_VLESS_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .email)"
local email=
email=$(echo "${user}" | jq -r .email)
echoContent skyBlue "\n ---> 账号:${email}"
echo
defaultBase64Code vlesstcp "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
defaultBase64Code vlesstcp "${email}" "$(echo "${user}" | jq -r .id)"
done
fi
@ -2998,14 +3268,17 @@ showAccounts() {
echoContent skyBlue "\n================================ VLESS WS TLS CDN ================================\n"
jq .inbounds[0].settings.clients ${configPath}03_VLESS_WS_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .email)"
local email=
email=$(echo "${user}" | jq -r .email)
echoContent skyBlue "\n ---> 账号:${email}"
echo
local path="${currentPath}ws"
# if [[ ${coreInstallType} == "1" ]]; then
# echoContent yellow "Xray的0-RTT path后面会有不兼容以v2ray为核心的客户端请手动删除后使用\n"
# path="${currentPath}ws"
# fi
defaultBase64Code vlessws "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
defaultBase64Code vlessws "${email}" "$(echo "${user}" | jq -r .id)"
done
fi
@ -3017,9 +3290,12 @@ showAccounts() {
path="${currentPath}vws"
fi
jq .inbounds[0].settings.clients ${configPath}05_VMess_WS_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .email)"
local email=
email=$(echo "${user}" | jq -r .email)
echoContent skyBlue "\n ---> 账号:${email}"
echo
defaultBase64Code vmessws "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
defaultBase64Code vmessws "${email}" "$(echo "${user}" | jq -r .id)"
done
fi
@ -3030,9 +3306,13 @@ showAccounts() {
# local serviceName
# serviceName=$(jq -r .inbounds[0].streamSettings.grpcSettings.serviceName ${configPath}06_VLESS_gRPC_inbounds.json)
jq .inbounds[0].settings.clients ${configPath}06_VLESS_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .email)"
local email=
email=$(echo "${user}" | jq -r .email)
echoContent skyBlue "\n ---> 账号:${email}"
echo
defaultBase64Code vlessgrpc "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
defaultBase64Code vlessgrpc "${email}" "$(echo "${user}" | jq -r .id)"
done
fi
fi
@ -3041,23 +3321,44 @@ showAccounts() {
if echo ${currentInstallProtocolType} | grep -q 4; then
echoContent skyBlue "\n================================== Trojan TLS ==================================\n"
jq .inbounds[0].settings.clients ${configPath}04_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .email)"
local email=
email=$(echo "${user}" | jq -r .email)
echoContent skyBlue "\n ---> 账号:${email}"
defaultBase64Code trojan "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .password)"
defaultBase64Code trojan "${email}" "$(echo "${user}" | jq -r .password)"
done
fi
if echo ${currentInstallProtocolType} | grep -q 2; then
echoContent skyBlue "\n================================ Trojan gRPC TLS ================================\n"
echoContent red "\n --->gRPC处于测试阶段可能对你使用的客户端不兼容如不能使用请忽略"
# local serviceName=
# serviceName=$(jq -r .inbounds[0].streamSettings.grpcSettings.serviceName ${configPath}04_trojan_gRPC_inbounds.json)
jq .inbounds[0].settings.clients ${configPath}04_trojan_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .email)"
local email=
email=$(echo "${user}" | jq -r .email)
echoContent skyBlue "\n ---> 账号:${email}"
echo
defaultBase64Code trojangrpc "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .password)"
defaultBase64Code trojangrpc "${email}" "$(echo "${user}" | jq -r .password)"
done
fi
if echo ${currentInstallProtocolType} | grep -q 6; then
echoContent skyBlue "\n================================ Hysteria TLS ================================\n"
echoContent red "\n --->Hysteria速度依赖与本地的网络环境如果被QoS使用体验会非常差。IDC也有可能认为是攻击请谨慎使用"
jq .auth.config ${hysteriaConfigPath}config.json | jq -r '.[]' | while read -r user; do
local vlessUser=
vlessUser=$(jq '.inbounds[0].settings.clients[]|select(.id=="'"${user}"'")' ${configPath}02_VLESS_TCP_inbounds.json)
local email=
email=$(echo "${vlessUser}" | jq -r .email)
if [[ -n ${vlessUser} ]]; then
echoContent skyBlue "\n ---> 账号:${email}"
echo
defaultBase64Code hysteria "${email}" "${user}"
fi
done
fi
if [[ -z ${show} ]]; then
echoContent red " ---> 未安装"
@ -3065,9 +3366,6 @@ showAccounts() {
}
# 移除nginx302配置
removeNginx302() {
# 查找到302那行并删除
# local line302Result=
# line302Result=$(grep -n "return 302" </etc/nginx/conf.d/alone.conf | tail -n 1)
local count=0
grep -n "return 302" <"/etc/nginx/conf.d/alone.conf" | while read -r line; do
@ -3202,8 +3500,8 @@ addCorePort() {
echoContent red "\n=============================================================="
echoContent yellow "# 注意事项\n"
echoContent yellow "支持批量添加"
echoContent yellow "不影响443端口的使用"
echoContent yellow "查看账号时,只会展示默认端口443的账号"
echoContent yellow "不影响默认端口的使用"
echoContent yellow "查看账号时,只会展示默认端口的账号"
echoContent yellow "不允许有特殊字符,注意逗号的格式"
echoContent yellow "录入示例:2053,2083,2087\n"
@ -3305,6 +3603,12 @@ unInstall() {
fi
if [[ -z "${hysteriaConfigPath}" ]]; then
handleHysteria stop
rm -rf /etc/systemd/system/hysteria.service
echoContent green " ---> 删除Hysteria开机自启完成"
fi
if [[ -f "/root/.acme.sh/acme.sh.env" ]] && grep -q 'acme.sh.env' </root/.bashrc; then
sed -i 's/. "\/root\/.acme.sh\/acme.sh.env"//g' "$(grep '. "/root/.acme.sh/acme.sh.env"' -rl /root/.bashrc)"
fi
@ -3333,6 +3637,8 @@ unInstall() {
echoContent green " ---> 卸载v2ray-agent脚本完成"
}
#updateGeoSite
# 修改V2Ray CDN节点
updateV2RayCDN() {
@ -3548,6 +3854,12 @@ addUser() {
trojanTCPResult=$(jq -r ".inbounds[0].settings.clients += [${trojanUsers}]" ${configPath}04_trojan_TCP_inbounds.json)
echo "${trojanTCPResult}" | jq . >${configPath}04_trojan_TCP_inbounds.json
fi
if echo ${currentInstallProtocolType} | grep -q 6; then
local hysteriaResult
hysteriaResult=$(jq -r ".auth.config += [\"${uuid}\"]" ${hysteriaConfigPath}config.json)
echo "${hysteriaResult}" | jq . >${hysteriaConfigPath}config.json
fi
done
reloadCore
@ -3601,6 +3913,12 @@ removeUser() {
echo "${trojanTCPResult}" | jq . >${configPath}04_trojan_TCP_inbounds.json
fi
if echo ${currentInstallProtocolType} | grep -q 6; then
local hysteriaResult
hysteriaResult=$(jq -r 'del(.auth.config['${delUserIndex}'])' ${hysteriaConfigPath}config.json)
echo "${hysteriaResult}" | jq . >${hysteriaConfigPath}config.json
fi
reloadCore
fi
manageAccount 1
@ -4539,6 +4857,11 @@ reloadCore() {
handleV2Ray stop
handleV2Ray start
fi
if [[ -n "${hysteriaConfigPath}" ]]; then
handleHysteria stop
handleHysteria start
fi
}
# dns解锁Netflix
@ -4869,6 +5192,32 @@ xrayCoreInstall() {
checkGFWStatue 12
showAccounts 13
}
# Hysteria安装
hysteriaCoreInstall() {
if [[ -z "${coreInstallType}" ]]; then
echoContent red "\n ---> 由于环境依赖如安装hysteria请先安装Xray/V2ray"
menu
exit 0
fi
totalProgress=5
installHysteria 1
initHysteriaConfig 2
installHysteriaService 3
handleHysteria start
showAccounts 5
}
# 卸载 hysteria
unInstallHysteriaCore() {
if [[ -z "${hysteriaConfigPath}" ]]; then
echoContent red "\n ---> 未安装"
exit 0
fi
handleHysteria stop
rm -rf /etc/v2ray-agent/hysteria/*
rm -rf /etc/systemd/system/hysteria.service
echoContent green " ---> 卸载完成"
}
# 核心管理
coreVersionManageMenu() {
@ -4900,7 +5249,8 @@ cronRenewTLS() {
manageAccount() {
echoContent skyBlue "\n功能 1/${totalProgress} : 账号管理"
echoContent red "\n=============================================================="
echoContent yellow "# 每次删除、添加账号后,需要重新查看订阅生成订阅\n"
echoContent yellow "# 每次删除、添加账号后,需要重新查看订阅生成订阅"
echoContent yellow "# 如安装了Hysteria账号会同时添加到Hysteria\n"
echoContent yellow "1.查看账号"
echoContent yellow "2.查看订阅"
echoContent yellow "3.添加用户"
@ -4999,12 +5349,31 @@ switchAlpn() {
fi
reloadCore
}
# hysteria管理
manageHysteria() {
echoContent skyBlue "\n进度 1/1 : Hysteria管理"
echoContent red "\n=============================================================="
echoContent yellow "1.安装"
echoContent yellow "2.卸载"
echoContent yellow "3.更新core"
echoContent red "=============================================================="
read -r -p "请选择:" installHysteriaStatus
if [[ "${installHysteriaStatus}" == "1" ]]; then
hysteriaCoreInstall
elif [[ "${installHysteriaStatus}" == "2" ]]; then
unInstallHysteriaCore
elif [[ "${installHysteriaStatus}" == "3" ]]; then
installHysteria 1
handleHysteria start
fi
}
# 主菜单
menu() {
cd "$HOME" || exit
echoContent red "\n=============================================================="
echoContent green "作者:mack-a"
echoContent green "当前版本:v2.6.5"
echoContent green "当前版本:v2.6.6"
echoContent green "Github:https://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c"
showInstallStatus
@ -5027,25 +5396,26 @@ menu() {
echoContent yellow "3.切换Trojan[XTLS]"
fi
echoContent yellow "4.Hysteria管理"
echoContent skyBlue "-------------------------工具管理-----------------------------"
echoContent yellow "4.账号管理"
echoContent yellow "5.更换伪装站"
echoContent yellow "6.更新证书"
echoContent yellow "7.更换CDN节点"
echoContent yellow "8.IPv6分流"
echoContent yellow "9.WARP分流"
echoContent yellow "10.流媒体工具"
echoContent yellow "11.添加新端口"
echoContent yellow "12.BT下载管理"
echoContent yellow "13.切换alpn"
echoContent yellow "14.域名黑名单"
echoContent yellow "5.账号管理"
echoContent yellow "6.更换伪装站"
echoContent yellow "7.更新证书"
echoContent yellow "8.更换CDN节点"
echoContent yellow "9.IPv6分流"
echoContent yellow "10.WARP分流"
echoContent yellow "11.流媒体工具"
echoContent yellow "12.添加新端口"
echoContent yellow "13.BT下载管理"
echoContent yellow "14.切换alpn"
echoContent yellow "15.域名黑名单"
echoContent skyBlue "-------------------------版本管理-----------------------------"
echoContent yellow "15.core管理"
echoContent yellow "16.更新脚本"
echoContent yellow "17.安装BBR、DD脚本"
echoContent yellow "16.core管理"
echoContent yellow "17.更新脚本"
echoContent yellow "18.安装BBR、DD脚本"
echoContent skyBlue "-------------------------脚本管理-----------------------------"
echoContent yellow "18.查看日志"
echoContent yellow "19.卸载脚本"
echoContent yellow "19.查看日志"
echoContent yellow "20.卸载脚本"
echoContent red "=============================================================="
mkdirTools
aliasInstall
@ -5061,51 +5431,54 @@ menu() {
initXrayFrontingConfig 1
;;
4)
manageAccount 1
manageHysteria
;;
5)
updateNginxBlog 1
manageAccount 1
;;
6)
renewalTLS 1
updateNginxBlog 1
;;
7)
updateV2RayCDN 1
renewalTLS 1
;;
8)
ipv6Routing 1
updateV2RayCDN 1
;;
9)
warpRouting 1
ipv6Routing 1
;;
10)
streamingToolbox 1
warpRouting 1
;;
11)
addCorePort 1
streamingToolbox 1
;;
12)
btTools 1
addCorePort 1
;;
13)
switchAlpn 1
btTools 1
;;
14)
blacklist 1
switchAlpn 1
;;
15)
coreVersionManageMenu 1
blacklist 1
;;
16)
updateV2RayAgent 1
coreVersionManageMenu 1
;;
17)
bbrInstall
updateV2RayAgent 1
;;
18)
checkLog 1
bbrInstall
;;
19)
checkLog 1
;;
20)
unInstall 1
;;
esac