From c5050d82678ee7532b271fc3379d529c57cc3255 Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Thu, 10 Nov 2022 15:46:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E5=85=BC=E5=AE=B9t?= =?UTF-8?q?rojan=E5=89=8D=E7=BD=AE=E7=9A=84Hysteria=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E3=80=81=E4=BC=98=E5=8C=96=E7=AB=AF=E5=8F=A3=E5=8F=B7=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E3=80=81=E7=A7=BB=E9=99=A4=E6=9C=8D=E5=8A=A1=E7=AB=AF?= =?UTF-8?q?hysteria=E4=B8=8A=E4=BC=A0=E4=B8=8B=E8=BD=BD=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 55 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 21 deletions(-) diff --git a/install.sh b/install.sh index 790572b..71b250d 100644 --- a/install.sh +++ b/install.sh @@ -248,7 +248,7 @@ readAcmeTLS() { readCustomPort() { if [[ -n "${configPath}" ]]; then local port= - port=$(jq -r .inbounds[0].port "${configPath}02_VLESS_TCP_inbounds.json") + port=$(jq -r .inbounds[0].port "${configPath}${frontingType}.json") if [[ "${port}" != "443" ]]; then customPort=${port} fi @@ -439,7 +439,7 @@ readConfigHostPathUUID() { currentDefaultPort= currentUUID= currentHost= - # currentPort= + currentPort= currentAdd= # 读取path if [[ -n "${configPath}" ]]; then @@ -476,7 +476,7 @@ readConfigHostPathUUID() { if [[ -n "${defaultPortFile}" ]]; then currentDefaultPort=$(echo "${defaultPortFile}" | awk -F [_] '{print $4}') else - currentDefaultPort=$(jq -r .inbounds[0].port ${configPath}02_VLESS_TCP_inbounds.json) + currentDefaultPort=$(jq -r .inbounds[0].port ${configPath}${frontingType}.json) fi fi @@ -487,7 +487,7 @@ readConfigHostPathUUID() { if [[ "${currentAdd}" == "null" ]]; then currentAdd=${currentHost} fi - # currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json) + currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json) elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then if [[ "${coreInstallType}" == "3" ]]; then @@ -502,7 +502,7 @@ readConfigHostPathUUID() { currentAdd=${currentHost} fi currentUUID=$(jq -r .inbounds[0].settings.clients[0].id ${configPath}${frontingType}.json) - # currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json) + currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json) fi } @@ -588,12 +588,11 @@ initVar "$1" checkSystem checkCPUVendor readInstallType -readCustomPort readInstallProtocolType readConfigHostPathUUID readInstallAlpn +readCustomPort checkBTPanel - # ------------------------------------------------------------- # 初始化安装目录 @@ -1253,15 +1252,20 @@ acmeInstallSSL() { # 自定义端口 customPortFunction() { local historyCustomPortStatus= - if [[ -n "${customPort}" ]]; then + local showPort= + if [[ -n "${customPort}" || -n "${currentPort}" ]]; then echo read -r -p "读取到上次安装时的端口,是否使用上次安装时的端口 ?[y/n]:" historyCustomPortStatus if [[ "${historyCustomPortStatus}" == "y" ]]; then - echoContent yellow "\n ---> 端口: ${customPort}" + showPort="${currentPort}" + if [[ -n "${customPort}" ]]; then + showPort="${customPort}" + fi + echoContent yellow "\n ---> 端口: ${showPort}" fi fi - if [[ "${historyCustomPortStatus}" == "n" || -z "${customPort}" ]]; then + if [[ "${historyCustomPortStatus}" == "n" ]] && [[ -z "${customPort}" && -z "${currentPort}" ]]; then echo echoContent yellow "请输入端口[默认: 443],如自定义端口,只允许使用DNS申请证书[回车使用默认]" read -r -p "端口:" customPort @@ -1276,8 +1280,6 @@ customPortFunction() { else echoContent yellow "\n ---> 端口: 443" fi - else - echoContent yellow "\n ---> 端口: ${currentPort}" fi } @@ -2154,6 +2156,11 @@ addClientsHysteria() { if [[ ${addClientsStatus} == "true" && -n "${previousClients}" ]]; then local uuids= uuids=$(echo "${previousClients}" | jq -r [.[].id]) + + + if [[ "${frontingType}" == "02_trojan_TCP_inbounds" ]]; then + uuids=$(echo "${previousClients}" | jq -r [.[].password]) + fi config=$(jq -r ".auth.config = ${uuids}" "${path}") echo "${config}" | jq . >"${path}" fi @@ -2252,7 +2259,7 @@ initHysteriaConfig() { initHysteriaProtocol initHysteriaNetwork - getClients "${configPath}/02_VLESS_TCP_inbounds.json" true + getClients "${configPath}${frontingType}.json" true cat </etc/v2ray-agent/hysteria/conf/config.json { "listen": ":${hysteriaPort}", @@ -2264,8 +2271,6 @@ initHysteriaConfig() { "mode": "passwords", "config": [] }, - "up_mbps":${hysteriaClientUploadSpeed}, - "down_mbps":${hysteriaClientDownloadSpeed}, "alpn": "h3", "recv_window_conn": 15728640, "recv_window_client": 67108864, @@ -3379,13 +3384,21 @@ showAccounts() { 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 + jq .auth.config ${hysteriaConfigPath}config.json | jq -r '.[]' | while read -r user; do + local defaultUser= + local uuidType= + uuidType=".id" + + if [[ "${frontingType}" == "02_trojan_TCP_inbounds" ]]; then + uuidType=".password" + fi + + defaultUser=$(jq '.inbounds[0].settings.clients[]|select('${uuidType}'=="'"${user}"'")' ${configPath}${frontingType}.json) + local email= + email=$(echo "${defaultUser}" | jq -r .email) + + if [[ -n ${defaultUser} ]]; then echoContent skyBlue "\n ---> 账号:${email}" echo defaultBase64Code hysteria "${email}" "${user}"