From ab468ca0d6383ccdbab69e5a90a3b44b0e4327e7 Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:59:34 +0800 Subject: [PATCH 01/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0sing-box=E5=85=A8=E9=83=A8=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 1598 +++++++++++++++++++++++----------------------------- 1 file changed, 691 insertions(+), 907 deletions(-) diff --git a/install.sh b/install.sh index b23a927..013d79f 100644 --- a/install.sh +++ b/install.sh @@ -92,8 +92,8 @@ checkCPUVendor() { 'amd64' | 'x86_64') xrayCoreCPUVendor="Xray-linux-64" v2rayCoreCPUVendor="v2ray-linux-64" - hysteriaCoreCPUVendor="hysteria-linux-amd64" - tuicCoreCPUVendor="-x86_64-unknown-linux-musl" + # hysteriaCoreCPUVendor="hysteria-linux-amd64" + # tuicCoreCPUVendor="-x86_64-unknown-linux-musl" warpRegCoreCPUVendor="main-linux-amd64" singBoxCoreCPUVendor="-linux-amd64" ;; @@ -101,8 +101,8 @@ checkCPUVendor() { cpuVendor="arm" xrayCoreCPUVendor="Xray-linux-arm64-v8a" v2rayCoreCPUVendor="v2ray-linux-arm64-v8a" - hysteriaCoreCPUVendor="hysteria-linux-arm64" - tuicCoreCPUVendor="-aarch64-unknown-linux-musl" + # hysteriaCoreCPUVendor="hysteria-linux-arm64" + # tuicCoreCPUVendor="-aarch64-unknown-linux-musl" warpRegCoreCPUVendor="main-linux-arm64" singBoxCoreCPUVendor="-linux-arm64" ;; @@ -129,7 +129,7 @@ initVar() { # 核心支持的cpu版本 xrayCoreCPUVendor="" v2rayCoreCPUVendor="" - hysteriaCoreCPUVendor="" + # hysteriaCoreCPUVendor="" warpRegCoreCPUVendor="" cpuVendor="" @@ -174,11 +174,22 @@ initVar() { # xray-core reality状态 realityStatus= - # hysteria 配置文件的路径 - hysteriaConfigPath= - # sing-box配置文件路径 singBoxConfigPath= + + # sing-box端口 + + singBoxVLESSVisionPort= + singBoxVLESSRealityVisionPort= + singBoxVLESSRealityGRPCPort= + singBoxHysteria2Port= + singBoxTuicPort= + + # sing-box reality serverName publicKey + singBoxVLESSRealityGRPCServerName= + singBoxVLESSRealityVisionServerName= + singBoxVLESSRealityPublicKey= + # interfaceName= # 端口跳跃 portHoppingStart= @@ -312,7 +323,7 @@ readAcmeTLS() { # 读取默认自定义端口 readCustomPort() { - if [[ -n "${configPath}" && -z "${realityStatus}" ]]; then + if [[ -n "${configPath}" && -z "${realityStatus}" && "${coreInstallType}" == "1" ]]; then local port= port=$(jq -r .inbounds[0].port "${configPath}${frontingType}.json") if [[ "${port}" != "443" ]]; then @@ -328,19 +339,8 @@ readInstallType() { # 1.检测安装目录 if [[ -d "/etc/v2ray-agent" ]]; then - # 检测安装方式 v2ray-core - # if [[ -d "/etc/v2ray-agent/v2ray" && -f "/etc/v2ray-agent/v2ray/v2ray" && -f "/etc/v2ray-agent/v2ray/v2ctl" ]]; then - # if [[ -d "/etc/v2ray-agent/v2ray/conf" && -f "/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json" ]]; then - # configPath=/etc/v2ray-agent/v2ray/conf/ - # if grep sing-box 卸载完成" fi } + # 读取xray reality配置 readXrayCoreRealityConfig() { currentRealityServerNames= @@ -661,21 +667,22 @@ readConfigHostPathUUID() { if [[ -n "${realityStatus}" && -z "${currentClients}" ]]; then currentUUID=$(jq -r .inbounds[0].settings.clients[0].id ${configPath}07_VLESS_vision_reality_inbounds.json) currentClients=$(jq -r .inbounds[0].settings.clients ${configPath}07_VLESS_vision_reality_inbounds.json) - fi elif [[ "${coreInstallType}" == "2" ]]; then - currentHost=$(jq -r .inbounds[0].streamSettings.tlsSettings.certificates[0].certificateFile ${configPath}${frontingType}.json | awk -F '[t][l][s][/]' '{print $2}' | awk -F '[.][c][r][t]' '{print $1}') - currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json) + currentHost=$(jq -r .inbounds[0].tls.server_name ${configPath}${frontingType}.json) + + # currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json) if [[ "${currentAdd}" == "null" ]]; then currentAdd=${currentHost} fi - currentUUID=$(jq -r .inbounds[0].settings.clients[0].id ${configPath}${frontingType}.json) - currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json) + currentUUID=$(jq -r .inbounds[0].users[0].uuid ${configPath}${frontingType}.json) + # currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json) + currentClients=$(jq -r .inbounds[0].users ${configPath}${frontingType}.json) fi # 读取path - if [[ -n "${configPath}" && -n "${frontingType}" ]]; then + if [[ -n "${configPath}" && -n "${frontingType}" && "${coreInstallType}" == "1" ]]; then local fallback fallback=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.path)' ${configPath}${frontingType}.json | head -1) @@ -715,10 +722,10 @@ showInstallStatus() { fi elif [[ "${coreInstallType}" == 2 ]]; then - if [[ -n $(pgrep -f "v2ray/v2ray") ]]; then - echoContent yellow "\n核心: v2ray-core[运行中]" + if [[ -n $(pgrep -f "sing-box/sing-box") ]]; then + echoContent yellow "\n核心: sing-box[运行中]" else - echoContent yellow "\n核心: v2ray-core[未运行]" + echoContent yellow "\n核心: sing-box[未运行]" fi fi # 读取协议类型 @@ -728,17 +735,7 @@ showInstallStatus() { echoContent yellow "已安装协议: \c" fi if echo ${currentInstallProtocolType} | grep -q 0; then - if [[ "${coreInstallType}" == 2 ]]; then - echoContent yellow "VLESS+TCP[TLS] \c" - else - echoContent yellow "VLESS+TCP[TLS_Vision] \c" - fi - fi - - if echo ${currentInstallProtocolType} | grep -q trojan; then - if [[ "${coreInstallType}" == 1 ]]; then - echoContent yellow "Trojan+TCP[TLS_Vision] \c" - fi + echoContent yellow "VLESS+TCP[TLS_Vision] \c" fi if echo ${currentInstallProtocolType} | grep -q 1; then @@ -777,21 +774,13 @@ showInstallStatus() { # 清理旧残留 cleanUp() { - # if [[ "$1" == "v2rayClean" ]]; then - # rm -rf "$(find /etc/v2ray-agent/v2ray/* | grep -E '(config_full.json|conf)')" - # handleV2Ray stop >/dev/null - # rm -f /etc/systemd/system/v2ray.service - # el - if [[ "$1" == "xrayClean" ]]; then - rm -rf "$(find /etc/v2ray-agent/xray/* | grep -E '(config_full.json|conf)')" - handleXray stop >/dev/null - rm -f /etc/systemd/system/xray.service - - elif [[ "$1" == "v2rayDel" ]]; then - rm -rf /etc/v2ray-agent/v2ray/* - - elif [[ "$1" == "xrayDel" ]]; then + if [[ "$1" == "xrayDel" ]]; then + handleXray stop rm -rf /etc/v2ray-agent/xray/* + elif [[ "$1" == "singBoxDel" ]]; then + handleSingBox stop + rm -rf /etc/v2ray-agent/sing-box/conf/config.json >/dev/null 2>&1 + rm -rf /etc/v2ray-agent/sing-box/conf/config/* >/dev/null 2>&1 fi } initVar "$1" @@ -800,7 +789,7 @@ checkCPUVendor readInstallType readInstallProtocolType readConfigHostPathUUID -readInstallAlpn +#readInstallAlpn readCustomPort readXrayCoreRealityConfig # ------------------------------------------------------------- @@ -823,14 +812,11 @@ mkdirTools() { mkdir -p /etc/v2ray-agent/xray/conf mkdir -p /etc/v2ray-agent/xray/reality_scan mkdir -p /etc/v2ray-agent/xray/tmp - mkdir -p /etc/v2ray-agent/hysteria/conf mkdir -p /etc/systemd/system/ mkdir -p /tmp/v2ray-agent-tls/ mkdir -p /etc/v2ray-agent/warp - mkdir -p /etc/v2ray-agent/tuic/conf - mkdir -p /etc/v2ray-agent/sing-box/conf/config } @@ -1207,7 +1193,9 @@ initTLSNginxConfig() { initTLSNginxConfig 3 else dnsTLSDomain=$(echo "${domain}" | awk -F "." '{$1="";print $0}' | sed 's/^[[:space:]]*//' | sed 's/ /./g') - customPortFunction + if [[ "${coreInstallType}" == "1" || "${selectCoreType}" == "1" ]]; then + customPortFunction + fi # 修改配置 handleNginx stop fi @@ -1231,7 +1219,7 @@ updateRedirectNginxConf() { nginxH2Conf="listen 127.0.0.1:31302 http2 so_keepalive=on;" nginxVersion=$(nginx -v 2>&1) - if echo "${nginxVersion}" | grep -q "1.25"; then + if echo "${nginxVersion}" | grep -q "1.25" && [[ $(echo "${nginxVersion}" | awk -F "[.]" '{print $3}') -gt 0 ]]; then nginxH2Conf="listen 127.0.0.1:31302 so_keepalive=on;http2 on;" fi @@ -1539,8 +1527,6 @@ customPortFunction() { if [[ "${port}" == "${currentRealityPort}" ]]; then handleXray stop fi - - # todo dns api fi if [[ -n "${port}" ]]; then @@ -1919,30 +1905,6 @@ installV2Ray() { fi } -# 安装 hysteria -installHysteria() { - readInstallType - echoContent skyBlue "\n进度 $1/${totalProgress} : 安装Hysteria" - - if [[ -z "${hysteriaConfigPath}" ]]; then - - version=$(curl -s "https://api.github.com/repos/apernet/hysteria/releases?per_page=10" | jq -r ".[]|select (.prerelease==${prereleaseStatus})|.tag_name" | grep "app/" | head -1) - - echoContent green " ---> Hysteria版本:${version}" - wget -c -q "${wgetShowProgressStatus}" -P /etc/v2ray-agent/hysteria/ "https://github.com/apernet/hysteria/releases/download/${version}/${hysteriaCoreCPUVendor}" - 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 | grep "Version:" | awk '{print $2}')" - read -r -p "是否更新、升级?[y/n]:" reInstallHysteriaStatus - if [[ "${reInstallHysteriaStatus}" == "y" ]]; then - rm -f /etc/v2ray-agent/hysteria/hysteria - installHysteria "$1" - fi - fi - -} - # 安装 sing-box installSingBox() { readInstallType @@ -1973,30 +1935,6 @@ installSingBox() { } -# 安装 tuic -installTuic() { - readInstallType - echoContent skyBlue "\n进度 $1/${totalProgress} : 安装Tuic" - - if [[ -z "${tuicConfigPath}" ]]; then - - version=$(curl -s "https://api.github.com/repos/EAimTY/tuic/releases?per_page=1" | jq -r '.[]|select (.prerelease==false)|.tag_name') - - echoContent green " ---> Tuic版本:${version}" - wget -c -q "${wgetShowProgressStatus}" -P /etc/v2ray-agent/tuic/ "https://github.com/EAimTY/tuic/releases/download/${version}/${version}${tuicCoreCPUVendor}" - mv "/etc/v2ray-agent/tuic/${version}${tuicCoreCPUVendor}" /etc/v2ray-agent/tuic/tuic - chmod 655 /etc/v2ray-agent/tuic/tuic - else - echoContent green " ---> Tuic版本:$(/etc/v2ray-agent/tuic/tuic -v)" - read -r -p "是否更新、升级?[y/n]:" reInstallTuicStatus - if [[ "${reInstallTuicStatus}" == "y" ]]; then - rm -f /etc/v2ray-agent/tuic/tuic - tuicConfigPath= - installTuic "$1" - fi - fi - -} # 检查wget showProgress checkWgetShowProgress() { if find /usr/bin /usr/sbin | grep -q -w wget && wget --help | grep -q show-progress; then @@ -2308,13 +2246,12 @@ checkGFWStatue() { echoContent skyBlue "\n进度 $1/${totalProgress} : 验证服务启动状态" if [[ "${coreInstallType}" == "1" ]] && [[ -n $(pgrep -f "xray/xray") ]]; then echoContent green " ---> 服务启动成功" - elif [[ "${coreInstallType}" == "2" ]] && [[ -n $(pgrep -f "v2ray/v2ray") ]]; then + elif [[ "${coreInstallType}" == "2" ]] && [[ -n $(pgrep -f "sing-box/sing-box") ]]; then echoContent green " ---> 服务启动成功" else echoContent red " ---> 服务启动失败,请检查终端是否有日志打印" exit 0 fi - } # V2Ray开机自启 @@ -2382,35 +2319,7 @@ EOF fi } -# 安装Tuic开机自启动 -#installTuicService() { -# echoContent skyBlue "\n进度 $1/${totalProgress} : 配置Tuic开机自启" -# if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then -# rm -rf /etc/systemd/system/tuic.service -# touch /etc/systemd/system/tuic.service -# execStart='/etc/v2ray-agent/tuic/tuic -c /etc/v2ray-agent/tuic/conf/config.json' -# cat </etc/systemd/system/tuic.service -#[Unit] -#Description=Tuic Service -#Documentation=https://github.com/EAimTY -#After=network.target nss-lookup.target -#[Service] -#User=root -#ExecStart=${execStart} -#Restart=on-failure -#RestartPreventExitStatus=23 -#LimitNPROC=10000 -#LimitNOFILE=1000000 -#[Install] -#WantedBy=multi-user.target -#EOF -# systemctl daemon-reload -# systemctl enable tuic.service -# echoContent green " ---> 配置Tuic开机自启成功" -# fi -#} - -# sing-box 自启动 +# sing-box开机自启 installSingBoxService() { echoContent skyBlue "\n进度 $1/${totalProgress} : 配置sing-box开机自启" if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then @@ -2627,7 +2536,7 @@ handleXray() { fi } -# 读取用户数据并初始化 +# 读取Xray用户数据并初始化 initXrayClients() { local type=$1 local newUUID=$2 @@ -2709,35 +2618,57 @@ initXrayClients() { done < <(echo "${currentClients}" | jq -c '.[]') echo "${users}" } -getClients() { - local path=$1 - - local addClientsStatus=$2 - previousClients= - - if [[ ${addClientsStatus} == "true" ]]; then - if [[ ! -f "${path}" ]]; then - echo - local protocol - protocol=$(echo "${path}" | awk -F "[_]" '{print $2 $3}') - echoContent yellow "没有读取到此协议[${protocol}]上一次安装的配置文件,采用配置文件的第一个uuid" - else - previousClients=$(jq -r ".inbounds[0].settings.clients" "${path}") +# 读取singbox用户数据并初始化 +initSingBoxClients() { + local type=$1 + local newUUID=$2 + local newName=$3 + if [[ -n "${newUUID}" ]]; then + local newUser= + newUser="{\"uuid\":\"${uuid}\",\"flow\":\"xtls-rprx-vision\",\"name\":\"${newName}-VLESS_TCP/TLS_Vision\"}" + currentClients=$(echo "${currentClients}" | jq -r ". +=[${newUser}]") + fi + local users= + users=[] + while read -r user; do + uuid=$(echo "${user}" | jq -r .uuid) + name=$(echo "${user}" | jq -r .name | awk -F "[-]" '{print $1}') + currentUser= + # VLESS Vision + if echo "${type}" | grep -q "0"; then + currentUser="{\"uuid\":\"${uuid}\",\"flow\":\"xtls-rprx-vision\",\"name\":\"${name}-VLESS_TCP/TLS_Vision\"}" + users=$(echo "${users}" | jq -r ". +=[${currentUser}]") fi - fi + # VLESS Reality Vision + if echo "${type}" | grep -q "7"; then + currentUser="{\"uuid\":\"${uuid}\",\"flow\":\"xtls-rprx-vision\",\"name\":\"${name}-VLESS_Reality_Vision\"}" + users=$(echo "${users}" | jq -r ". +=[${currentUser}]") + fi + # VLESS Reality gRPC + if echo "${type}" | grep -q "8"; then + currentUser="{\"uuid\":\"${uuid}\",\"name\":\"${name}-VLESS_Reality_gPRC\"}" + users=$(echo "${users}" | jq -r ". +=[${currentUser}]") + fi + + # hysteria2 + if echo "${type}" | grep -q "6"; then + currentUser="{\"password\":\"${uuid}\",\"name\":\"${name}-singbox_hysteria2\"}" + + users=$(echo "${users}" | jq -r ". +=[${currentUser}]") + fi + + # tuic + if echo "${type}" | grep -q "9"; then + currentUser="{\"uuid\":\"${uuid}\",\"password\":\"${uuid}\",\"name\":\"${name}-singbox_tuic\"}" + + users=$(echo "${users}" | jq -r ". +=[${currentUser}]") + fi + + done < <(echo "${currentClients}" | jq -c '.[]') + echo "${users}" } -# 添加client配置 -addClients() { - - local path=$1 - local addClientsStatus=$2 - if [[ ${addClientsStatus} == "true" && -n "${previousClients}" ]]; then - config=$(jq -r ".inbounds[0].settings.clients = ${previousClients}" "${path}") - echo "${config}" | jq . >"${path}" - fi -} # 添加hysteria配置 addClientsHysteria() { local path=$1 @@ -2942,7 +2873,6 @@ initHysteriaConfig() { # initHysteriaNetwork local uuid= uuid=$(${ctlPath} uuid) - # getClients "${configPath}${frontingType}.json" true cat </etc/v2ray-agent/hysteria/conf/config.json { "listen":":${hysteriaPort}", @@ -3084,7 +3014,7 @@ initSingBoxTuicConfig() { initTuicPort initTuicProtocol - cat </etc/v2ray-agent/sing-box/conf/config/tuic.json + cat </etc/v2ray-agent/sing-box/conf/config/06_hysteria2_inbounds.json { "inbounds": [ { @@ -3370,12 +3300,16 @@ EOF # sing-box Tuic安装 singBoxTuicInstall() { + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请全部安装或者个性化安装Hysteria2" + exit 0 + fi if ! echo "${currentInstallProtocolType}" | grep -q "0" || [[ -z "${coreInstallType}" ]]; then echoContent red "\n ---> 由于证书环境依赖,如安装Tuic,请先安装Xray-core的VLESS_TCP_TLS_Vision" exit 0 fi + totalProgress=5 - # installTuic 1 installSingBox 1 initSingBoxTuicConfig 2 installSingBoxService 3 @@ -3385,10 +3319,15 @@ singBoxTuicInstall() { # sing-box hy2安装 singBoxHysteria2Install() { + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请全部安装或者个性化安装Hysteria2" + exit 0 + fi if ! echo "${currentInstallProtocolType}" | grep -q "0" || [[ -z "${coreInstallType}" ]]; then echoContent red "\n ---> 由于证书环境依赖,如安装Hysteria2,请先安装Xray-core的VLESS_TCP_TLS_Vision" exit 0 fi + totalProgress=5 installSingBox 1 initSingBoxHysteria2Config 2 @@ -3403,345 +3342,6 @@ singBoxMergeConfig() { /etc/v2ray-agent/sing-box/sing-box merge config.json -C /etc/v2ray-agent/sing-box/conf/config/ -D /etc/v2ray-agent/sing-box/conf/ >/dev/null 2>&1 } -# 初始化V2Ray 配置文件 -initV2RayConfig() { - echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化V2Ray配置" - echo - - read -r -p "是否自定义UUID ?[y/n]:" customUUIDStatus - echo - if [[ "${customUUIDStatus}" == "y" ]]; then - read -r -p "请输入合法的UUID:" currentCustomUUID - if [[ -n "${currentCustomUUID}" ]]; then - uuid=${currentCustomUUID} - fi - fi - local addClientsStatus= - if [[ -n "${currentUUID}" && -z "${uuid}" ]]; then - read -r -p "读取到上次安装记录,是否使用上次安装时的UUID ?[y/n]:" historyUUIDStatus - if [[ "${historyUUIDStatus}" == "y" ]]; then - uuid=${currentUUID} - addClientsStatus=true - else - uuid=$(/etc/v2ray-agent/v2ray/v2ctl uuid) - fi - elif [[ -z "${uuid}" ]]; then - uuid=$(/etc/v2ray-agent/v2ray/v2ctl uuid) - fi - - if [[ -z "${uuid}" ]]; then - addClientsStatus= - echoContent red "\n ---> uuid读取错误,重新生成" - uuid=$(/etc/v2ray-agent/v2ray/v2ctl uuid) - fi - - movePreviousConfig - # log - cat </etc/v2ray-agent/v2ray/conf/00_log.json -{ - "log": { - "error": "/etc/v2ray-agent/v2ray/error.log", - "loglevel": "warning" - } -} -EOF - # outbounds - if [[ -n "${pingIPv6}" ]]; then - cat </etc/v2ray-agent/v2ray/conf/10_ipv6_outbounds.json -{ - "outbounds": [ - { - "protocol": "freedom", - "settings": {}, - "tag": "direct" - } - ] -} -EOF - - else - cat </etc/v2ray-agent/v2ray/conf/10_ipv4_outbounds.json -{ - "outbounds":[ - { - "protocol":"freedom", - "settings":{ - "domainStrategy":"UseIPv4" - }, - "tag":"IPv4_out" - }, - { - "protocol":"freedom", - "settings":{ - "domainStrategy":"UseIPv6" - }, - "tag":"IPv6_out" - }, - { - "protocol":"blackhole", - "tag":"blackhole_out" - } - ] -} -EOF - fi - - # dns - cat </etc/v2ray-agent/v2ray/conf/11_dns.json -{ - "dns": { - "servers": [ - "localhost" - ] - } -} -EOF - - # VLESS_TCP_TLS - # 回落nginx - local fallbacksList='{"dest":31300,"xver":0},{"alpn":"h2","dest":31302,"xver":0}' - - # trojan - if echo "${selectCustomInstallType}" | grep -q 4 || [[ "$1" == "all" ]]; then - - fallbacksList='{"dest":31296,"xver":1},{"alpn":"h2","dest":31302,"xver":0}' - - getClients "${configPath}../tmp/04_trojan_TCP_inbounds.json" "${addClientsStatus}" - cat </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": "default_Trojan_TCP" - } - ], - "fallbacks":[ - {"dest":"31300"} - ] - }, - "streamSettings": { - "network": "tcp", - "security": "none", - "tcpSettings": { - "acceptProxyProtocol": true - } - } - } - ] -} -EOF - addClients "/etc/v2ray-agent/v2ray/conf/04_trojan_TCP_inbounds.json" "${addClientsStatus}" - fi - - # VLESS_WS_TLS - if echo "${selectCustomInstallType}" | grep -q 1 || [[ "$1" == "all" ]]; then - fallbacksList=${fallbacksList}',{"path":"/'${customPath}'ws","dest":31297,"xver":1}' - getClients "${configPath}../tmp/03_VLESS_WS_inbounds.json" "${addClientsStatus}" - cat </etc/v2ray-agent/v2ray/conf/03_VLESS_WS_inbounds.json -{ -"inbounds":[ - { - "port": 31297, - "listen": "127.0.0.1", - "protocol": "vless", - "tag":"VLESSWS", - "settings": { - "clients": [ - { - "id": "${uuid}", - "email": "default_VLESS_WS" - } - ], - "decryption": "none" - }, - "streamSettings": { - "network": "ws", - "security": "none", - "wsSettings": { - "acceptProxyProtocol": true, - "path": "/${customPath}ws" - } - } - } -] -} -EOF - addClients "/etc/v2ray-agent/v2ray/conf/03_VLESS_WS_inbounds.json" "${addClientsStatus}" - fi - - # trojan_grpc - if echo "${selectCustomInstallType}" | grep -q 2 || [[ "$1" == "all" ]]; then - if ! echo "${selectCustomInstallType}" | grep -q 5 && [[ -n ${selectCustomInstallType} ]]; then - fallbacksList=${fallbacksList//31302/31304} - fi - getClients "${configPath}../tmp/04_trojan_gRPC_inbounds.json" "${addClientsStatus}" - cat </etc/v2ray-agent/v2ray/conf/04_trojan_gRPC_inbounds.json -{ - "inbounds": [ - { - "port": 31304, - "listen": "127.0.0.1", - "protocol": "trojan", - "tag": "trojangRPCTCP", - "settings": { - "clients": [ - { - "password": "${uuid}", - "email": "default_Trojan_gRPC" - } - ], - "fallbacks": [ - { - "dest": "31300" - } - ] - }, - "streamSettings": { - "network": "grpc", - "grpcSettings": { - "serviceName": "${customPath}trojangrpc" - } - } - } - ] -} -EOF - addClients "/etc/v2ray-agent/v2ray/conf/04_trojan_gRPC_inbounds.json" "${addClientsStatus}" - fi - - # VMess_WS - if echo "${selectCustomInstallType}" | grep -q 3 || [[ "$1" == "all" ]]; then - fallbacksList=${fallbacksList}',{"path":"/'${customPath}'vws","dest":31299,"xver":1}' - - getClients "${configPath}../tmp/05_VMess_WS_inbounds.json" "${addClientsStatus}" - - cat </etc/v2ray-agent/v2ray/conf/05_VMess_WS_inbounds.json -{ -"inbounds":[ -{ - "listen": "127.0.0.1", - "port": 31299, - "protocol": "vmess", - "tag":"VMessWS", - "settings": { - "clients": [ - { - "id": "${uuid}", - "alterId": 0, - "add": "${add}", - "email": "default_VMess_WS" - } - ] - }, - "streamSettings": { - "network": "ws", - "security": "none", - "wsSettings": { - "acceptProxyProtocol": true, - "path": "/${customPath}vws" - } - } -} -] -} -EOF - addClients "/etc/v2ray-agent/v2ray/conf/05_VMess_WS_inbounds.json" "${addClientsStatus}" - fi - - if echo "${selectCustomInstallType}" | grep -q 5 || [[ "$1" == "all" ]]; then - getClients "${configPath}../tmp/06_VLESS_gRPC_inbounds.json" "${addClientsStatus}" - cat </etc/v2ray-agent/v2ray/conf/06_VLESS_gRPC_inbounds.json -{ - "inbounds":[ - { - "port": 31301, - "listen": "127.0.0.1", - "protocol": "vless", - "tag":"VLESSGRPC", - "settings": { - "clients": [ - { - "id": "${uuid}", - "add": "${add}", - "email": "default_VLESS_gRPC" - } - ], - "decryption": "none" - }, - "streamSettings": { - "network": "grpc", - "grpcSettings": { - "serviceName": "${customPath}grpc" - } - } - } -] -} -EOF - addClients "/etc/v2ray-agent/v2ray/conf/06_VLESS_gRPC_inbounds.json" "${addClientsStatus}" - fi - - # VLESS_TCP - getClients "${configPath}../tmp/02_VLESS_TCP_inbounds.json" "${addClientsStatus}" - local defaultPort=443 - if [[ -n "${customPort}" ]]; then - defaultPort=${customPort} - fi - - cat </etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json -{ -"inbounds":[ -{ - "port": ${defaultPort}, - "protocol": "vless", - "tag":"VLESSTCP", - "settings": { - "clients": [ - { - "id": "${uuid}", - "add":"${add}", - "email": "default_VLESS_TCP" - } - ], - "decryption": "none", - "fallbacks": [ - ${fallbacksList} - ] - }, - "streamSettings": { - "network": "tcp", - "security": "tls", - "tlsSettings": { - "minVersion": "1.2", - "alpn": [ - "http/1.1", - "h2" - ], - "certificates": [ - { - "certificateFile": "/etc/v2ray-agent/tls/${domain}.crt", - "keyFile": "/etc/v2ray-agent/tls/${domain}.key", - "ocspStapling": 3600, - "usage":"encipherment" - } - ] - } - } -} -] -} -EOF - addClients "/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json" "${addClientsStatus}" - -} - # 初始化Xray Trojan XTLS 配置文件 initXrayFrontingConfig() { echoContent red " ---> Trojan暂不支持 xtls-rprx-vision" @@ -3805,19 +3405,30 @@ initXrayFrontingConfig() { exit 0 } -# 移动上次配置文件至临时文件 -movePreviousConfig() { - - if [[ -n "${configPath}" ]]; then - if [[ -z "${realityStatus}" ]]; then - rm -rf "${configPath}../tmp/*" 2>/dev/null - mv ${configPath}[0][2-6]* ${configPath}../tmp/ 2>/dev/null +# 初始化sing-box端口 +initSingBoxPort() { + local port=$1 + if [[ -n "${port}" ]]; then + read -r -p "读取到上次使用的端口,是否使用 ?[y/n]:" historyPort + if [[ "${historyPort}" != "y" ]]; then + port= else - rm -rf "${configPath}../tmp/*" - mv ${configPath}[0][7-8]* ${configPath}../tmp/ 2>/dev/null - mv ${configPath}[0][2]* ${configPath}../tmp/ 2>/dev/null + echo "${port}" + fi + fi + if [[ -z "${port}" ]]; then + read -r -p '请输入自定义端口[需合法],端口不可重复,[回车]随机端口:' port + if [[ -z "${port}" ]]; then + port=$((RANDOM % 50001 + 10000)) + fi + if ((port >= 1 && port <= 65535)); then + allowPort "${port}" + allowPort "${port}" "udp" + echo "${port}" + else + echoContent red " ---> 端口输入错误" + exit 0 fi - fi } @@ -4219,7 +3830,7 @@ EOF } EOF - cat </etc/v2ray-agent/xray/conf/08_VLESS_reality_fallback_grpc_inbounds.json + cat </etc/v2ray-agent/xray/conf/08_VLESS_vision_gRPC_inbounds.json { "inbounds": [ { @@ -4248,10 +3859,255 @@ EOF else rm /etc/v2ray-agent/xray/conf/07_VLESS_vision_reality_inbounds.json >/dev/null 2>&1 - rm /etc/v2ray-agent/xray/conf/08_VLESS_reality_fallback_grpc_inbounds.json >/dev/null 2>&1 + rm /etc/v2ray-agent/xray/conf/08_VLESS_vision_gRPC_inbounds.json >/dev/null 2>&1 fi installSniffing } + +# 初始化TCP Brutal +initTCPBrutal() { + echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化TCP_Brutal配置" + read -r -p "是否使用TCP_Brutal?[y/n]:" tcpBrutalStatus + if [[ "${tcpBrutalStatus}" == "y" ]]; then + read -r -p "请输入本地带宽峰值的下行速度(默认:100,单位:Mbps):" tcpBrutalClientDownloadSpeed + if [[ -z "${tcpBrutalClientDownloadSpeed}" ]]; then + tcpBrutalClientDownloadSpeed=100 + fi + + read -r -p "请输入本地带宽峰值的上行速度(默认:50,单位:Mbps):" tcpBrutalClientUploadSpeed + if [[ -z "${tcpBrutalClientUploadSpeed}" ]]; then + tcpBrutalClientUploadSpeed=50 + fi + fi +} +# 初始化sing-box配置文件 +initSingBoxConfig() { + echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化sing-box配置" + echo + local uuid= + local addClientsStatus= + if [[ -n "${currentUUID}" ]]; then + read -r -p "读取到上次用户配置,是否使用上次安装的配置 ?[y/n]:" historyUUIDStatus + if [[ "${historyUUIDStatus}" == "y" ]]; then + addClientsStatus=true + echoContent green "\n ---> 使用成功" + fi + fi + + if [[ -z "${addClientsStatus}" ]]; then + echoContent yellow "请输入自定义UUID[需合法],[回车]随机UUID" + read -r -p 'UUID:' customUUID + + if [[ -n ${customUUID} ]]; then + uuid=${customUUID} + else + uuid=$(/etc/v2ray-agent/sing-box/sing-box generate uuid) + fi + + echoContent yellow "\n请输入自定义用户名[需合法],[回车]随机用户名" + read -r -p '用户名:' customEmail + if [[ -z ${customEmail} ]]; then + customEmail="$(echo "${uuid}" | cut -d "-" -f 1)-VLESS_TCP/TLS_Vision" + fi + fi + + if [[ -z "${addClientsStatus}" && -z "${uuid}" ]]; then + addClientsStatus= + echoContent red "\n ---> uuid读取错误,随机生成" + uuid=$(/etc/v2ray-agent/sing-box/sing-box generate uuid) + fi + + if [[ -n "${uuid}" ]]; then + currentClients='[{"uuid":"'${uuid}'","flow":"xtls-rprx-vision","name":"'${customEmail}'"}]' + echoContent yellow "\n ${customEmail}:${uuid}" + fi + + # VLESS Vision + if echo "${selectCustomInstallType}" | grep -q 0 || [[ "$1" == "all" ]]; then + echoContent red "\n===================== 配置VLESS+Vision =====================\n" + echo + mapfile -t result < <(initSingBoxPort "${singBoxVLESSVisionPort}") + echoContent green "\n ---> VLESS_Vision端口:${result[-1]}" + + checkDNSIP "${domain}" + removeNginxDefaultConf + handleSingBox stop + checkPortOpen "${result[-1]}" "${domain}" + cat </etc/v2ray-agent/sing-box/conf/config/02_VLESS_TCP_inbounds.json +{ + "inbounds":[ + { + "type": "vless", + "listen":"::", + "listen_port":${result[-1]}, + "tag":"VLESSTCP", + "users":$(initSingBoxClients 0), + "tls":{ + "server_name": "${domain}", + "enabled": true, + "certificate_path": "/etc/v2ray-agent/tls/${domain}.crt", + "key_path": "/etc/v2ray-agent/tls/${domain}.key" + } + } + ] +} +EOF + else + rm /etc/v2ray-agent/sing-box/conf/config/01_VLESS_TCP_inbounds.json >/dev/null 2>&1 + fi + + # VLESS_Reality_Vision + if echo "${selectCustomInstallType}" | grep -q 7 || [[ "$1" == "all" ]]; then + echoContent red "\n================= 配置VLESS+Reality+Vision =================\n" + initRealityClientServersName + initRealityKey + echo + mapfile -t result < <(initSingBoxPort "${singBoxVLESSRealityVisionPort}") + echoContent green "\n ---> VLESS_Reality_Vision端口:${result[-1]}" + cat </etc/v2ray-agent/sing-box/conf/config/07_VLESS_vision_reality_inbounds.json +{ + "inbounds": [ + { + "type": "vless", + "listen":"::", + "listen_port":${result[-1]}, + "tag": "VLESSReality", + "users":$(initSingBoxClients 7), + "tls": { + "enabled": true, + "server_name": ${realityServerNames}, + "reality": { + "enabled": true, + "handshake":{ + "server":${realityServerNames}, + "server_port":443 + }, + "private_key": "${realityPrivateKey}", + "short_id": [ + "", + "6ba85179e30d4fc2" + ] + } + } + } + ] +} +EOF + else + rm /etc/v2ray-agent/sing-box/conf/config/02_VLESS_vision_reality_inbounds.json >/dev/null 2>&1 + fi + + if echo "${selectCustomInstallType}" | grep -q 8 || [[ "$1" == "all" ]]; then + echoContent red "\n================== 配置VLESS+Reality+gRPC ==================\n" + initRealityClientServersName + initRealityKey + echo + mapfile -t result < <(initSingBoxPort "${singBoxVLESSRealityGRPCPort}") + echoContent green "\n ---> VLESS_Reality_gPRC端口:${result[-1]}" + cat </etc/v2ray-agent/sing-box/conf/config/08_VLESS_vision_gRPC_inbounds.json +{ + "inbounds": [ + { + "type": "vless", + "listen":"::", + "listen_port":${result[-1]}, + "users":$(initSingBoxClients 8), + "tag": "VLESSRealityGRPC", + "tls": { + "enabled": true, + "server_name": ${realityServerNames}, + "reality": { + "enabled": true, + "handshake":{ + "server":${realityServerNames}, + "server_port":443 + }, + "private_key": "${realityPrivateKey}", + "short_id": [ + "", + "6ba85179e30d4fc2" + ] + } + }, + "transport": { + "type": "grpc", + "service_name": "grpc" + } + } + ] +} +EOF + else + rm /etc/v2ray-agent/sing-box/conf/03_VLESS_vision_gRPC_inbounds.json >/dev/null 2>&1 + fi + + if echo "${selectCustomInstallType}" | grep -q 6 || [[ "$1" == "all" ]]; then + echoContent red "\n================== 配置 Hysteria2 ==================\n" + echo + mapfile -t result < <(initSingBoxPort "${singBoxHysteria2Port}") + echoContent green "\n ---> Hysteria2端口:${result[-1]}" + initHysteria2Network + + cat </etc/v2ray-agent/sing-box/conf/config/06_hysteria2_inbounds.json +{ + "inbounds": [ + { + "type": "hysteria2", + "listen": "::", + "listen_port": ${result[-1]}, + "users": $(initSingBoxClients 6), + "up_mbps":${hysteria2ClientDownloadSpeed}, + "down_mbps":${hysteria2ClientUploadSpeed}, + "tls": { + "enabled": true, + "server_name":"${domain}", + "alpn": [ + "h3" + ], + "certificate_path": "/etc/v2ray-agent/tls/${domain}.crt", + "key_path": "/etc/v2ray-agent/tls/${domain}.key" + } + } + ] +} +EOF + else + rm /etc/v2ray-agent/sing-box/conf/06_hysteria2_inbounds.json >/dev/null 2>&1 + fi + + if echo "${selectCustomInstallType}" | grep -q 9 || [[ "$1" == "all" ]]; then + echoContent red "\n================== 配置 Tuic ==================\n" + echo + mapfile -t result < <(initSingBoxPort "${singBoxTuicPort}") + echoContent green "\n ---> Tuic端口:${result[-1]}" + initTuicProtocol + cat </etc/v2ray-agent/sing-box/conf/config/09_tuic_inbounds.json +{ + "inbounds": [ + { + "type": "tuic", + "listen": "::", + "tag": "singbox-tuic-in", + "listen_port": ${result[-1]}, + "users": $(initSingBoxClients 9), + "congestion_control": "${tuicAlgorithm}", + "tls": { + "enabled": true, + "server_name":"${domain}", + "alpn": [ + "h3" + ], + "certificate_path": "/etc/v2ray-agent/tls/${domain}.crt", + "key_path": "/etc/v2ray-agent/tls/${domain}.key" + } + } + ] +} +EOF + else + rm /etc/v2ray-agent/sing-box/conf/09_tuic_inbounds.json >/dev/null 2>&1 + fi +} # 初始化Xray Reality配置 # 自定义CDN IP customCDNIP() { @@ -4286,29 +4142,28 @@ customCDNIP() { # 通用 defaultBase64Code() { local type=$1 - local email=$2 - local id=$3 - local add=$4 + local port=$2 + local email=$3 + local id=$4 + local add=$5 local user= user=$(echo "${email}" | awk -F "[-]" '{print $1}') - port=${currentDefaultPort} if [[ "${type}" == "vlesstcp" ]]; then - if [[ "${coreInstallType}" == "1" ]] && echo "${currentInstallProtocolType}" | grep -q 0; then - echoContent yellow " ---> 通用格式(VLESS+TCP+TLS_Vision)" - echoContent green " vless://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=tls&fp=chrome&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-vision#${email}\n" + echoContent yellow " ---> 通用格式(VLESS+TCP+TLS_Vision)" + echoContent green " vless://${id}@${currentHost}:${port}?encryption=none&security=tls&fp=chrome&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-vision#${email}\n" - echoContent yellow " ---> 格式化明文(VLESS+TCP+TLS_Vision)" - echoContent green "协议类型:VLESS,地址:${currentHost},端口:${currentDefaultPort},用户ID:${id},安全:tls,client-fingerprint: chrome,传输方式:tcp,flow:xtls-rprx-vision,账户名:${email}\n" - cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" -vless://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=tls&type=tcp&host=${currentHost}&fp=chrome&headerType=none&sni=${currentHost}&flow=xtls-rprx-vision#${email} + echoContent yellow " ---> 格式化明文(VLESS+TCP+TLS_Vision)" + echoContent green "协议类型:VLESS,地址:${currentHost},端口:${port},用户ID:${id},安全:tls,client-fingerprint: chrome,传输方式:tcp,flow:xtls-rprx-vision,账户名:${email}\n" + cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" +vless://${id}@${currentHost}:${port}?encryption=none&security=tls&type=tcp&host=${currentHost}&fp=chrome&headerType=none&sni=${currentHost}&flow=xtls-rprx-vision#${email} EOF - cat <>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}" + cat <>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}" - name: "${email}" type: vless server: ${currentHost} - port: ${currentDefaultPort} + port: ${port} uuid: ${id} network: tcp tls: true @@ -4316,40 +4171,15 @@ EOF flow: xtls-rprx-vision client-fingerprint: chrome EOF - echoContent yellow " ---> 二维码 VLESS(VLESS+TCP+TLS_Vision)" - echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${currentHost}%3A${currentDefaultPort}%3Fencryption%3Dnone%26fp%3Dchrome%26security%3Dtls%26type%3Dtcp%26${currentHost}%3D${currentHost}%26headerType%3Dnone%26sni%3D${currentHost}%26flow%3Dxtls-rprx-vision%23${email}\n" - elif [[ "${coreInstallType}" == 2 ]]; then - echoContent yellow " ---> 通用格式(VLESS+TCP+TLS)" - echoContent green " vless://${id}@${currentHost}:${currentDefaultPort}?security=tls&encryption=none&host=${currentHost}&fp=chrome&headerType=none&type=tcp#${email}\n" - - echoContent yellow " ---> 格式化明文(VLESS+TCP+TLS)" - echoContent green " 协议类型:VLESS,地址:${currentHost},端口:${currentDefaultPort},用户ID:${id},安全:tls,client-fingerprint: chrome,传输方式:tcp,账户名:${email}\n" - - cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" -vless://${id}@${currentHost}:${currentDefaultPort}?security=tls&encryption=none&host=${currentHost}&fp=chrome&headerType=none&type=tcp#${email} -EOF - echoContent yellow " ---> 二维码 VLESS(VLESS+TCP+TLS)" - echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3a%2f%2f${id}%40${currentHost}%3a${currentDefaultPort}%3fsecurity%3dtls%26encryption%3dnone%26fp%3Dchrome%26host%3d${currentHost}%26headerType%3dnone%26type%3dtcp%23${email}\n" - fi - - elif [[ "${type}" == "trojanTCPXTLS" ]]; then - echoContent yellow " ---> 通用格式(Trojan+TCP+TLS_Vision)" - echoContent green " trojan://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-vision#${email}\n" - - echoContent yellow " ---> 格式化明文(Trojan+TCP+TLS_Vision)" - echoContent green "协议类型:Trojan,地址:${currentHost},端口:${currentDefaultPort},用户ID:${id},安全:xtls,传输方式:tcp,flow:xtls-rprx-vision,账户名:${email}\n" - cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" -trojan://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-vision#${email} -EOF - echoContent yellow " ---> 二维码 Trojan(Trojan+TCP+TLS_Vision)" - echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3A%2F%2F${id}%40${currentHost}%3A${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dxtls%26type%3Dtcp%26${currentHost}%3D${currentHost}%26headerType%3Dnone%26sni%3D${currentHost}%26flow%3Dxtls-rprx-vision%23${email}\n" + echoContent yellow " ---> 二维码 VLESS(VLESS+TCP+TLS_Vision)" + echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${currentHost}%3A${port}%3Fencryption%3Dnone%26fp%3Dchrome%26security%3Dtls%26type%3Dtcp%26${currentHost}%3D${currentHost}%26headerType%3Dnone%26sni%3D${currentHost}%26flow%3Dxtls-rprx-vision%23${email}\n" elif [[ "${type}" == "vmessws" ]]; then - qrCodeBase64Default=$(echo -n "{\"port\":${currentDefaultPort},\"ps\":\"${email}\",\"tls\":\"tls\",\"id\":\"${id}\",\"aid\":0,\"v\":2,\"host\":\"${currentHost}\",\"type\":\"none\",\"path\":\"/${currentPath}vws\",\"net\":\"ws\",\"add\":\"${add}\",\"allowInsecure\":0,\"method\":\"none\",\"peer\":\"${currentHost}\",\"sni\":\"${currentHost}\"}" | base64 -w 0) + qrCodeBase64Default=$(echo -n "{\"port\":${port},\"ps\":\"${email}\",\"tls\":\"tls\",\"id\":\"${id}\",\"aid\":0,\"v\":2,\"host\":\"${currentHost}\",\"type\":\"none\",\"path\":\"/${currentPath}vws\",\"net\":\"ws\",\"add\":\"${add}\",\"allowInsecure\":0,\"method\":\"none\",\"peer\":\"${currentHost}\",\"sni\":\"${currentHost}\"}" | base64 -w 0) qrCodeBase64Default="${qrCodeBase64Default// /}" echoContent yellow " ---> 通用json(VMess+WS+TLS)" - echoContent green " {\"port\":${currentDefaultPort},\"ps\":\"${email}\",\"tls\":\"tls\",\"id\":\"${id}\",\"aid\":0,\"v\":2,\"host\":\"${currentHost}\",\"type\":\"none\",\"path\":\"/${currentPath}vws\",\"net\":\"ws\",\"add\":\"${add}\",\"allowInsecure\":0,\"method\":\"none\",\"peer\":\"${currentHost}\",\"sni\":\"${currentHost}\"}\n" + echoContent green " {\"port\":${port},\"ps\":\"${email}\",\"tls\":\"tls\",\"id\":\"${id}\",\"aid\":0,\"v\":2,\"host\":\"${currentHost}\",\"type\":\"none\",\"path\":\"/${currentPath}vws\",\"net\":\"ws\",\"add\":\"${add}\",\"allowInsecure\":0,\"method\":\"none\",\"peer\":\"${currentHost}\",\"sni\":\"${currentHost}\"}\n" echoContent yellow " ---> 通用vmess(VMess+WS+TLS)链接" echoContent green " vmess://${qrCodeBase64Default}\n" echoContent yellow " ---> 二维码 vmess(VMess+WS+TLS)" @@ -4361,7 +4191,7 @@ EOF - name: "${email}" type: vmess server: ${add} - port: ${currentDefaultPort} + port: ${port} uuid: ${id} alterId: 0 cipher: none @@ -4380,19 +4210,19 @@ EOF elif [[ "${type}" == "vlessws" ]]; then echoContent yellow " ---> 通用格式(VLESS+WS+TLS)" - echoContent green " vless://${id}@${add}:${currentDefaultPort}?encryption=none&security=tls&type=ws&host=${currentHost}&sni=${currentHost}&fp=chrome&path=/${currentPath}ws#${email}\n" + echoContent green " vless://${id}@${add}:${port}?encryption=none&security=tls&type=ws&host=${currentHost}&sni=${currentHost}&fp=chrome&path=/${currentPath}ws#${email}\n" echoContent yellow " ---> 格式化明文(VLESS+WS+TLS)" - echoContent green " 协议类型:VLESS,地址:${add},伪装域名/SNI:${currentHost},端口:${currentDefaultPort},client-fingerprint: chrome,用户ID:${id},安全:tls,传输方式:ws,路径:/${currentPath}ws,账户名:${email}\n" + echoContent green " 协议类型:VLESS,地址:${add},伪装域名/SNI:${currentHost},端口:${port},client-fingerprint: chrome,用户ID:${id},安全:tls,传输方式:ws,路径:/${currentPath}ws,账户名:${email}\n" cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" -vless://${id}@${add}:${currentDefaultPort}?encryption=none&security=tls&type=ws&host=${currentHost}&sni=${currentHost}&fp=chrome&path=/${currentPath}ws#${email} +vless://${id}@${add}:${port}?encryption=none&security=tls&type=ws&host=${currentHost}&sni=${currentHost}&fp=chrome&path=/${currentPath}ws#${email} EOF cat <>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}" - name: "${email}" type: vless server: ${add} - port: ${currentDefaultPort} + port: ${port} uuid: ${id} udp: true tls: true @@ -4406,24 +4236,24 @@ EOF EOF echoContent yellow " ---> 二维码 VLESS(VLESS+WS+TLS)" - echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${add}%3A${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dws%26host%3D${currentHost}%26fp%3Dchrome%26sni%3D${currentHost}%26path%3D%252f${currentPath}ws%23${email}" + echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${add}%3A${port}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dws%26host%3D${currentHost}%26fp%3Dchrome%26sni%3D${currentHost}%26path%3D%252f${currentPath}ws%23${email}" elif [[ "${type}" == "vlessgrpc" ]]; then echoContent yellow " ---> 通用格式(VLESS+gRPC+TLS)" - echoContent green " vless://${id}@${add}:${currentDefaultPort}?encryption=none&security=tls&type=grpc&host=${currentHost}&path=${currentPath}grpc&fp=chrome&serviceName=${currentPath}grpc&alpn=h2&sni=${currentHost}#${email}\n" + echoContent green " vless://${id}@${add}:${port}?encryption=none&security=tls&type=grpc&host=${currentHost}&path=${currentPath}grpc&fp=chrome&serviceName=${currentPath}grpc&alpn=h2&sni=${currentHost}#${email}\n" echoContent yellow " ---> 格式化明文(VLESS+gRPC+TLS)" - echoContent green " 协议类型:VLESS,地址:${add},伪装域名/SNI:${currentHost},端口:${currentDefaultPort},用户ID:${id},安全:tls,传输方式:gRPC,alpn:h2,client-fingerprint: chrome,serviceName:${currentPath}grpc,账户名:${email}\n" + echoContent green " 协议类型:VLESS,地址:${add},伪装域名/SNI:${currentHost},端口:${port},用户ID:${id},安全:tls,传输方式:gRPC,alpn:h2,client-fingerprint: chrome,serviceName:${currentPath}grpc,账户名:${email}\n" cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" -vless://${id}@${add}:${currentDefaultPort}?encryption=none&security=tls&type=grpc&host=${currentHost}&path=${currentPath}grpc&serviceName=${currentPath}grpc&fp=chrome&alpn=h2&sni=${currentHost}#${email} +vless://${id}@${add}:${port}?encryption=none&security=tls&type=grpc&host=${currentHost}&path=${currentPath}grpc&serviceName=${currentPath}grpc&fp=chrome&alpn=h2&sni=${currentHost}#${email} EOF cat <>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}" - name: "${email}" type: vless server: ${add} - port: ${currentDefaultPort} + port: ${port} uuid: ${id} udp: true tls: true @@ -4434,22 +4264,22 @@ EOF grpc-service-name: ${currentPath}grpc EOF echoContent yellow " ---> 二维码 VLESS(VLESS+gRPC+TLS)" - echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${add}%3A${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dgrpc%26host%3D${currentHost}%26serviceName%3D${currentPath}grpc%26fp%3Dchrome%26path%3D${currentPath}grpc%26sni%3D${currentHost}%26alpn%3Dh2%23${email}" + echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${add}%3A${port}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dgrpc%26host%3D${currentHost}%26serviceName%3D${currentPath}grpc%26fp%3Dchrome%26path%3D${currentPath}grpc%26sni%3D${currentHost}%26alpn%3Dh2%23${email}" elif [[ "${type}" == "trojan" ]]; then # URLEncode echoContent yellow " ---> Trojan(TLS)" - echoContent green " trojan://${id}@${currentHost}:${currentDefaultPort}?peer=${currentHost}&fp=chrome&sni=${currentHost}&alpn=http/1.1#${currentHost}_Trojan\n" + echoContent green " trojan://${id}@${currentHost}:${port}?peer=${currentHost}&fp=chrome&sni=${currentHost}&alpn=http/1.1#${currentHost}_Trojan\n" cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" -trojan://${id}@${currentHost}:${currentDefaultPort}?peer=${currentHost}&fp=chrome&sni=${currentHost}&alpn=http/1.1#${email}_Trojan +trojan://${id}@${currentHost}:${port}?peer=${currentHost}&fp=chrome&sni=${currentHost}&alpn=http/1.1#${email}_Trojan EOF cat <>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}" - name: "${email}" type: trojan server: ${currentHost} - port: ${currentDefaultPort} + port: ${port} password: ${id} client-fingerprint: chrome udp: true @@ -4462,14 +4292,14 @@ EOF # URLEncode echoContent yellow " ---> Trojan gRPC(TLS)" - echoContent green " trojan://${id}@${add}:${currentDefaultPort}?encryption=none&peer=${currentHost}&fp=chrome&security=tls&type=grpc&sni=${currentHost}&alpn=h2&path=${currentPath}trojangrpc&serviceName=${currentPath}trojangrpc#${email}\n" + echoContent green " trojan://${id}@${add}:${port}?encryption=none&peer=${currentHost}&fp=chrome&security=tls&type=grpc&sni=${currentHost}&alpn=h2&path=${currentPath}trojangrpc&serviceName=${currentPath}trojangrpc#${email}\n" cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" -trojan://${id}@${add}:${currentDefaultPort}?encryption=none&peer=${currentHost}&security=tls&type=grpc&fp=chrome&sni=${currentHost}&alpn=h2&path=${currentPath}trojangrpc&serviceName=${currentPath}trojangrpc#${email} +trojan://${id}@${add}:${port}?encryption=none&peer=${currentHost}&security=tls&type=grpc&fp=chrome&sni=${currentHost}&alpn=h2&path=${currentPath}trojangrpc&serviceName=${currentPath}trojangrpc#${email} EOF cat <>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}" - name: "${email}" server: ${add} - port: ${currentDefaultPort} + port: ${port} type: trojan password: ${id} network: grpc @@ -4479,23 +4309,23 @@ EOF grpc-service-name: ${currentPath}trojangrpc 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${add}%3a${currentDefaultPort}%3Fencryption%3Dnone%26fp%3Dchrome%26security%3Dtls%26peer%3d${currentHost}%26type%3Dgrpc%26sni%3d${currentHost}%26path%3D${currentPath}trojangrpc%26alpn%3Dh2%26serviceName%3D${currentPath}trojangrpc%23${email}\n" + echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${add}%3a${port}%3Fencryption%3Dnone%26fp%3Dchrome%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 " hysteria2://${id}@${currentHost}:${hysteriaPort}?peer=${currentHost}&insecure=0&sni=${currentHost}&alpn=h3#${email}\n" + echoContent green " hysteria2://${id}@${currentHost}:${port}?peer=${currentHost}&insecure=0&sni=${currentHost}&alpn=h3#${email}\n" cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" -hysteria2://${id}@${currentHost}:${hysteriaPort}?peer=${currentHost}&insecure=0&sni=${currentHost}&alpn=h3#${email} +hysteria2://${id}@${currentHost}:${port}?peer=${currentHost}&insecure=0&sni=${currentHost}&alpn=h3#${email} EOF echoContent yellow " ---> v2rayN(hysteria+TLS)" - echo "{\"server\": \"$(getPublicIP 4):${hysteriaPort}\",\"socks5\": { \"listen\": \"127.0.0.1:7798\", \"timeout\": 300},\"auth\":\"${id}\",\"tls\":{\"sni\":\"${currentHost}\"}}" | jq + echo "{\"server\": \"$(getPublicIP 4):${port}\",\"socks5\": { \"listen\": \"127.0.0.1:7798\", \"timeout\": 300},\"auth\":\"${id}\",\"tls\":{\"sni\":\"${currentHost}\"}}" | jq cat <>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}" - name: "${email}" type: hysteria2 server: ${currentHost} - port: ${hysteriaPort} + port: ${port} password: ${id} alpn: - h3 @@ -4504,64 +4334,77 @@ EOF down: "${hysteria2ClientDownloadSpeed} Mbps" EOF echoContent yellow " ---> 二维码 Hysteria2(TLS)" - echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=hysteria2%3A%2F%2F${id}%40${currentHost}%3A${hysteriaPort}%3Fpeer%3D${currentHost}%26insecure%3D0%26sni%3D${currentHost}%26alpn%3Dh3%23${email}\n" + echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=hysteria2%3A%2F%2F${id}%40${currentHost}%3A${port}%3Fpeer%3D${currentHost}%26insecure%3D0%26sni%3D${currentHost}%26alpn%3Dh3%23${email}\n" elif [[ "${type}" == "vlessReality" ]]; then + local realityServerName=${currentRealityServerNames} + local publicKey=${currentRealityPublicKey} + if [[ "${coreInstallType}" == "2" ]]; then + realityServerName=${singBoxVLESSRealityVisionServerName} + publicKey=${singBoxVLESSRealityPublicKey} + fi echoContent yellow " ---> 通用格式(VLESS+reality+uTLS+Vision)" - echoContent green " vless://${id}@$(getPublicIP):${currentRealityPort}?encryption=none&security=reality&type=tcp&sni=${currentRealityServerNames}&fp=chrome&pbk=${currentRealityPublicKey}&sid=6ba85179e30d4fc2&flow=xtls-rprx-vision#${email}\n" + echoContent green " vless://${id}@$(getPublicIP):${port}?encryption=none&security=reality&type=tcp&sni=${realityServerName}&fp=chrome&pbk=${publicKey}&sid=6ba85179e30d4fc2&flow=xtls-rprx-vision#${email}\n" echoContent yellow " ---> 格式化明文(VLESS+reality+uTLS+Vision)" - echoContent green "协议类型:VLESS reality,地址:$(getPublicIP),publicKey:${currentRealityPublicKey},shortId: 6ba85179e30d4fc2,serverNames:${currentRealityServerNames},端口:${currentRealityPort},用户ID:${id},传输方式:tcp,账户名:${email}\n" + echoContent green "协议类型:VLESS reality,地址:$(getPublicIP),publicKey:${publicKey},shortId: 6ba85179e30d4fc2,serverNames:${realityServerName},端口:${port},用户ID:${id},传输方式:tcp,账户名:${email}\n" cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" -vless://${id}@$(getPublicIP):${currentRealityPort}?encryption=none&security=reality&type=tcp&sni=${currentRealityServerNames}&fp=chrome&pbk=${currentRealityPublicKey}&sid=6ba85179e30d4fc2&flow=xtls-rprx-vision#${email} +vless://${id}@$(getPublicIP):${port}?encryption=none&security=reality&type=tcp&sni=${realityServerName}&fp=chrome&pbk=${publicKey}&sid=6ba85179e30d4fc2&flow=xtls-rprx-vision#${email} EOF cat <>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}" - name: "${email}" type: vless server: $(getPublicIP) - port: ${currentRealityPort} + port: ${port} uuid: ${id} network: tcp tls: true udp: true flow: xtls-rprx-vision - servername: ${currentRealityServerNames} + servername: ${realityServerName} reality-opts: - public-key: ${currentRealityPublicKey} + public-key: ${publicKey} short-id: 6ba85179e30d4fc2 client-fingerprint: chrome EOF echoContent yellow " ---> 二维码 VLESS(VLESS+reality+uTLS+Vision)" - echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40$(getPublicIP)%3A${currentRealityPort}%3Fencryption%3Dnone%26security%3Dreality%26type%3Dtcp%26sni%3D${currentRealityServerNames}%26fp%3Dchrome%26pbk%3D${currentRealityPublicKey}%26sid%3D6ba85179e30d4fc2%26flow%3Dxtls-rprx-vision%23${email}\n" + echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40$(getPublicIP)%3A${port}%3Fencryption%3Dnone%26security%3Dreality%26type%3Dtcp%26sni%3D${realityServerName}%26fp%3Dchrome%26pbk%3D${publicKey}%26sid%3D6ba85179e30d4fc2%26flow%3Dxtls-rprx-vision%23${email}\n" elif [[ "${type}" == "vlessRealityGRPC" ]]; then + local realityServerName=${currentRealityServerNames} + local publicKey=${currentRealityPublicKey} + if [[ "${coreInstallType}" == "2" ]]; then + realityServerName=${singBoxVLESSRealityGRPCServerName} + publicKey=${singBoxVLESSRealityPublicKey} + fi + echoContent yellow " ---> 通用格式(VLESS+reality+uTLS+gRPC)" - echoContent green " vless://${id}@$(getPublicIP):${currentRealityPort}?encryption=none&security=reality&type=grpc&sni=${currentRealityServerNames}&fp=chrome&pbk=${currentRealityPublicKey}&sid=6ba85179e30d4fc2&path=grpc&serviceName=grpc#${email}\n" + echoContent green " vless://${id}@$(getPublicIP):${port}?encryption=none&security=reality&type=grpc&sni=${realityServerName}&fp=chrome&pbk=${publicKey}&sid=6ba85179e30d4fc2&path=grpc&serviceName=grpc#${email}\n" echoContent yellow " ---> 格式化明文(VLESS+reality+uTLS+gRPC)" - echoContent green "协议类型:VLESS reality,serviceName:grpc,地址:$(getPublicIP),publicKey:${currentRealityPublicKey},shortId: 6ba85179e30d4fc2,serverNames:${currentRealityServerNames},端口:${currentRealityPort},用户ID:${id},传输方式:gRPC,client-fingerprint:chrome,账户名:${email}\n" + echoContent green "协议类型:VLESS reality,serviceName:grpc,地址:$(getPublicIP),publicKey:${publicKey},shortId: 6ba85179e30d4fc2,serverNames:${realityServerName},端口:${port},用户ID:${id},传输方式:gRPC,client-fingerprint:chrome,账户名:${email}\n" cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" -vless://${id}@$(getPublicIP):${currentRealityPort}?encryption=none&security=reality&type=grpc&sni=${currentRealityServerNames}&fp=chrome&pbk=${currentRealityPublicKey}&sid=6ba85179e30d4fc2&path=grpc&serviceName=grpc#${email} +vless://${id}@$(getPublicIP):${port}?encryption=none&security=reality&type=grpc&sni=${realityServerName}&fp=chrome&pbk=${publicKey}&sid=6ba85179e30d4fc2&path=grpc&serviceName=grpc#${email} EOF cat <>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}" - name: "${email}" type: vless server: $(getPublicIP) - port: ${currentRealityPort} + port: ${port} uuid: ${id} network: grpc tls: true udp: true - servername: ${currentRealityServerNames} + servername: ${realityServerName} reality-opts: - public-key: ${currentRealityPublicKey} + public-key: ${publicKey} short-id: 6ba85179e30d4fc2 grpc-opts: grpc-service-name: "grpc" client-fingerprint: chrome EOF echoContent yellow " ---> 二维码 VLESS(VLESS+reality+uTLS+gRPC)" - echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40$(getPublicIP)%3A${currentRealityPort}%3Fencryption%3Dnone%26security%3Dreality%26type%3Dgrpc%26sni%3D${currentRealityServerNames}%26fp%3Dchrome%26pbk%3D${currentRealityPublicKey}%26pbk%3D6ba85179e30d4fc2%26path%3Dgrpc%26serviceName%3Dgrpc%23${email}\n" + echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40$(getPublicIP)%3A${port}%3Fencryption%3Dnone%26security%3Dreality%26type%3Dgrpc%26sni%3D${realityServerName}%26fp%3Dchrome%26pbk%3D${publicKey}%26sid%3D6ba85179e30d4fc2%26path%3Dgrpc%26serviceName%3Dgrpc%23${email}\n" elif [[ "${type}" == "tuic" ]]; then local tuicUUID= tuicUUID=$(echo "${id}" | awk -F "[_]" '{print $1}') @@ -4575,19 +4418,19 @@ EOF fi echoContent yellow " ---> 格式化明文(Tuic+TLS)" - echoContent green " 协议类型:Tuic,地址:${currentHost},端口:${tuicPort},uuid:${tuicUUID},password:${tuicPassword},congestion-controller:${tuicAlgorithm},alpn: h3,账户名:${email}\n" + echoContent green " 协议类型:Tuic,地址:${currentHost},端口:${port},uuid:${tuicUUID},password:${tuicPassword},congestion-controller:${tuicAlgorithm},alpn: h3,账户名:${email}\n" cat <>"/etc/v2ray-agent/subscribe_local/default/${user}" -tuic://${tuicUUID}:${tuicPassword}@${currentHost}:${tuicPort}?congestion_control=${tuicAlgorithm}&alpn=h3&sni=${currentHost}&udp_relay_mode=quic&allow_insecure=0#${email} +tuic://${tuicUUID}:${tuicPassword}@${currentHost}:${port}?congestion_control=${tuicAlgorithm}&alpn=h3&sni=${currentHost}&udp_relay_mode=quic&allow_insecure=0#${email} EOF echoContent yellow " ---> v2rayN(Tuic+TLS)" - echo "{\"relay\": {\"server\": \"${currentHost}:${tuicPort}\",\"uuid\": \"${tuicUUID}\",\"password\": \"${tuicPassword}\",\"ip\": \"$(getPublicIP 4)\",\"congestion_control\": \"${tuicAlgorithm}\",\"alpn\": [\"h3\"]},\"local\": {\"server\": \"127.0.0.1:7798\"},\"log_level\": \"warn\"}" | jq + echo "{\"relay\": {\"server\": \"${currentHost}:${port}\",\"uuid\": \"${tuicUUID}\",\"password\": \"${tuicPassword}\",\"ip\": \"$(getPublicIP 4)\",\"congestion_control\": \"${tuicAlgorithm}\",\"alpn\": [\"h3\"]},\"local\": {\"server\": \"127.0.0.1:7798\"},\"log_level\": \"warn\"}" | jq cat <>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}" - name: "${email}" server: ${currentHost} type: tuic - port: ${tuicPort} + port: ${port} uuid: ${tuicUUID} password: ${tuicPassword} alpn: @@ -4608,40 +4451,31 @@ showAccounts() { readInstallType readInstallProtocolType readConfigHostPathUUID - # readHysteriaConfig readSingBoxConfig readXrayCoreRealityConfig - # readHysteriaPortHopping echo echoContent skyBlue "\n进度 $1/${totalProgress} : 账号" local show - # VLESS TCP - if echo "${currentInstallProtocolType}" | grep -q trojan; then - echoContent skyBlue "===================== Trojan TCP TLS_Vision[不推荐] ======================\n" - jq .inbounds[0].settings.clients ${configPath}02_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do - local email= - email=$(echo "${user}" | jq -r .email) - echoContent skyBlue "\n ---> 账号:${email}" - defaultBase64Code trojanTCPXTLS "${email}" "$(echo "${user}" | jq -r .password)" - done - elif echo ${currentInstallProtocolType} | grep -q 0; then + # VLESS TCP + if echo ${currentInstallProtocolType} | grep -q 0; then show=1 - echoContent skyBlue "============================= VLESS TCP TLS_Vision ==============================\n" - jq .inbounds[0].settings.clients ${configPath}02_VLESS_TCP_inbounds.json | jq -c '.[]' | while read -r user; do + + echoContent skyBlue "============================= VLESS TCP TLS_Vision [推荐] ==============================\n" + jq .inbounds[0].settings.clients//.inbounds[0].users ${configPath}02_VLESS_TCP_inbounds.json | jq -c '.[]' | while read -r user; do local email= - email=$(echo "${user}" | jq -r .email) + email=$(echo "${user}" | jq -r .email//.name) echoContent skyBlue "\n ---> 账号:${email}" echo - defaultBase64Code vlesstcp "${email}" "$(echo "${user}" | jq -r .id)" + defaultBase64Code vlesstcp "${currentDefaultPort}${singBoxVLESSVisionPort}" "${email}" "$(echo "${user}" | jq -r .id//.uuid)" done fi # VLESS WS if echo ${currentInstallProtocolType} | grep -q 1; then - echoContent skyBlue "\n================================ VLESS WS TLS [仅CDN不推荐] ================================\n" + 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 local email= @@ -4653,7 +4487,7 @@ showAccounts() { local count= while read -r line; do if [[ -n "${line}" ]]; then - defaultBase64Code vlessws "${email}${count}" "$(echo "${user}" | jq -r .id)" "${line}" + defaultBase64Code vlessws "${currentDefaultPort}" "${email}${count}" "$(echo "${user}" | jq -r .id)" "${line}" count=$((count + 1)) fi done < <(echo "${currentAdd}" | tr ',' '\n') @@ -4663,7 +4497,7 @@ showAccounts() { # VLESS grpc if echo ${currentInstallProtocolType} | grep -q 5; then - echoContent skyBlue "\n=============================== VLESS gRPC TLS [仅CDN不推荐] ===============================\n" + echoContent skyBlue "\n=============================== VLESS gRPC TLS [仅CDN推荐] ===============================\n" jq .inbounds[0].settings.clients ${configPath}06_VLESS_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do local email= @@ -4674,7 +4508,7 @@ showAccounts() { local count= while read -r line; do if [[ -n "${line}" ]]; then - defaultBase64Code vlessgrpc "${email}${count}" "$(echo "${user}" | jq -r .id)" "${line}" + defaultBase64Code vlessgrpc "${currentDefaultPort}" "${email}${count}" "$(echo "${user}" | jq -r .id)" "${line}" count=$((count + 1)) fi done < <(echo "${currentAdd}" | tr ',' '\n') @@ -4684,7 +4518,7 @@ showAccounts() { # VMess WS if echo ${currentInstallProtocolType} | grep -q 3; then - echoContent skyBlue "\n================================ VMess WS TLS [仅CDN不推荐] ================================\n" + echoContent skyBlue "\n================================ VMess WS TLS [仅CDN推荐] ================================\n" local path="${currentPath}vws" if [[ ${coreInstallType} == "1" ]]; then path="${currentPath}vws" @@ -4698,7 +4532,7 @@ showAccounts() { local count= while read -r line; do if [[ -n "${line}" ]]; then - defaultBase64Code vmessws "${email}${count}" "$(echo "${user}" | jq -r .id)" "${line}" + defaultBase64Code vmessws "${currentDefaultPort}" "${email}${count}" "$(echo "${user}" | jq -r .id)" "${line}" count=$((count + 1)) fi done < <(echo "${currentAdd}" | tr ',' '\n') @@ -4713,12 +4547,13 @@ showAccounts() { email=$(echo "${user}" | jq -r .email) echoContent skyBlue "\n ---> 账号:${email}" - defaultBase64Code trojan "${email}" "$(echo "${user}" | jq -r .password)" + defaultBase64Code trojan "${currentDefaultPort}" "${email}" "$(echo "${user}" | jq -r .password)" done fi + # trojan grpc if echo ${currentInstallProtocolType} | grep -q 2; then - echoContent skyBlue "\n================================ Trojan gRPC TLS [仅CDN不推荐] ================================\n" + echoContent skyBlue "\n================================ Trojan gRPC TLS [仅CDN推荐] ================================\n" jq .inbounds[0].settings.clients ${configPath}04_trojan_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do local email= email=$(echo "${user}" | jq -r .email) @@ -4728,19 +4563,20 @@ showAccounts() { local count= while read -r line; do if [[ -n "${line}" ]]; then - defaultBase64Code trojangrpc "${email}${count}" "$(echo "${user}" | jq -r .password)" "${line}" + defaultBase64Code trojangrpc "${currentDefaultPort}" "${email}${count}" "$(echo "${user}" | jq -r .password)" "${line}" count=$((count + 1)) fi done < <(echo "${currentAdd}" | tr ',' '\n') done fi + # hysteria2 if echo ${currentInstallProtocolType} | grep -q 6; then echoContent skyBlue "\n================================ Hysteria2 TLS [推荐] ================================\n" - jq -r -c '.inbounds[]|select(.type=="hysteria2")|.users[]' "${singBoxConfigPath}config.json" | while read -r user; do + jq -r -c '.inbounds[]|.users[]' "${configPath}06_hysteria2_inbounds.json" | while read -r user; do echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .name)" echo - defaultBase64Code hysteria "$(echo "${user}" | jq -r .name)" "$(echo "${user}" | jq -r .password)" + defaultBase64Code hysteria "${currentDefaultPort}${singBoxHysteria2Port}" "$(echo "${user}" | jq -r .name)" "$(echo "${user}" | jq -r .password)" done fi @@ -4749,36 +4585,35 @@ showAccounts() { if echo ${currentInstallProtocolType} | grep -q 7; then show=1 echoContent skyBlue "============================= VLESS reality_vision [推荐] ==============================\n" - jq .inbounds[0].settings.clients ${configPath}07_VLESS_vision_reality_inbounds.json | jq -c '.[]' | while read -r user; do + jq .inbounds[0].settings.clients//.inbounds[0].users ${configPath}07_VLESS_vision_reality_inbounds.json | jq -c '.[]' | while read -r user; do local email= - email=$(echo "${user}" | jq -r .email) + email=$(echo "${user}" | jq -r .email//.name) echoContent skyBlue "\n ---> 账号:${email}" echo - defaultBase64Code vlessReality "${email}" "$(echo "${user}" | jq -r .id)" + defaultBase64Code vlessReality "${currentDefaultPort}${singBoxVLESSRealityVisionPort}" "${email}" "$(echo "${user}" | jq -r .id//.uuid)" done fi - - # VLESS reality + # VLESS reality gRPC if echo ${currentInstallProtocolType} | grep -q 8; then show=1 echoContent skyBlue "============================== VLESS reality_gRPC [推荐] ===============================\n" - jq .inbounds[0].settings.clients ${configPath}08_VLESS_reality_fallback_grpc_inbounds.json | jq -c '.[]' | while read -r user; do + jq .inbounds[0].settings.clients//.inbounds[0].users ${configPath}08_VLESS_vision_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do local email= - email=$(echo "${user}" | jq -r .email) + email=$(echo "${user}" | jq -r .email//.name) echoContent skyBlue "\n ---> 账号:${email}" echo - defaultBase64Code vlessRealityGRPC "${email}" "$(echo "${user}" | jq -r .id)" + defaultBase64Code vlessRealityGRPC "${currentDefaultPort}${singBoxVLESSRealityGRPCPort}" "${email}" "$(echo "${user}" | jq -r .id//.uuid)" done fi # tuic if echo ${currentInstallProtocolType} | grep -q 9; then echoContent skyBlue "\n================================ Tuic TLS [推荐] ================================\n" - jq -r -c '.inbounds[]|select(.type=="tuic")|.users[]' "${singBoxConfigPath}config.json" | while read -r user; do + jq -r -c '.inbounds[].users[]' "${configPath}09_tuic_inbounds.json" | while read -r user; do echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .name)" echo - defaultBase64Code tuic "$(echo "${user}" | jq -r .name)" "$(echo "${user}" | jq -r .uuid)_$(echo "${user}" | jq -r .password)" + defaultBase64Code tuic "${currentDefaultPort}${singBoxTuicPort}" "$(echo "${user}" | jq -r .name)" "$(echo "${user}" | jq -r .uuid)_$(echo "${user}" | jq -r .password)" done fi @@ -4853,6 +4688,11 @@ addNginx302() { # 更新伪装站 updateNginxBlog() { + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核" + exit 0 + fi + echoContent skyBlue "\n进度 $1/${totalProgress} : 更换伪装站点" if ! echo "${currentInstallProtocolType}" | grep -q "0" || [[ -z "${coreInstallType}" ]]; then @@ -4920,7 +4760,12 @@ updateNginxBlog() { # 添加新端口 addCorePort() { - readHysteriaConfig + + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核" + exit 0 + fi + echoContent skyBlue "\n功能 1/${totalProgress} : 添加新端口" echoContent red "\n==============================================================" echoContent yellow "# 注意事项\n" @@ -5058,38 +4903,12 @@ unInstall() { rm -rf /etc/systemd/system/xray.service echoContent green " ---> 删除Xray开机自启完成" fi - - if [[ -n "${hysteriaConfigPath}" ]]; then - handleHysteria stop - rm -rf /etc/systemd/system/hysteria.service - echoContent green " ---> 删除Hysteria开机自启完成" - fi - - if [[ -n "${tuicConfigPath}" ]]; then - handleTuic stop - rm -rf /etc/systemd/system/tuic.service - echoContent green " ---> 删除Tuic开机自启完成" - fi - - if [[ -n "${singBoxConfigPath}" ]]; then + if [[ "${coreInstallType}" == "2" || -n "${singBoxConfigPath}" ]]; then handleSingBox stop rm -rf /etc/systemd/system/sing-box.service echoContent green " ---> 删除sing-box开机自启完成" fi - # if [[ -f "/root/.acme.sh/acme.sh.env" ]] && grep -q 'acme.sh.env' 备份证书成功,请注意留存。[/tmp/v2ray-agent-tls]" - # fi - # fi - rm -rf /etc/v2ray-agent rm -rf ${nginxConfigPath}alone.conf rm -rf ${nginxConfigPath}checkPortOpen.conf >/dev/null 2>&1 @@ -5107,7 +4926,10 @@ unInstall() { # 修改V2Ray CDN节点 updateV2RayCDN() { - + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核" + exit 0 + fi echoContent skyBlue "\n进度 $1/${totalProgress} : 修改CDN节点" if [[ -n "${currentAdd}" ]]; then @@ -5224,11 +5046,6 @@ addUserXray() { echoContent red " ---> 输入有误,请重新输入" exit 0 fi - # 生成用户 - # if [[ "${userNum}" == "1" ]]; then - # customUUID - # customUserEmail - # fi while [[ ${userNum} -gt 0 ]]; do readConfigHostPathUUID @@ -5300,8 +5117,8 @@ addUserXray() { if echo "${currentInstallProtocolType}" | grep -q 8; then local clients= clients=$(initXrayClients 8 "${uuid}" "${email}") - clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}08_VLESS_reality_fallback_grpc_inbounds.json) - echo "${clients}" | jq . >${configPath}08_VLESS_reality_fallback_grpc_inbounds.json + clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}08_VLESS_vision_gRPC_inbounds.json) + echo "${clients}" | jq . >${configPath}08_VLESS_vision_gRPC_inbounds.json fi # hysteria2 @@ -5432,6 +5249,7 @@ addUser() { echo "${trojanTCPResult}" | jq . >${configPath}04_trojan_TCP_inbounds.json fi # hysteria2 + # todo 修改为sing-box if echo ${currentInstallProtocolType} | grep -q 6; then local hysteriaResult users="{\"password\":\"${uuid}\",\"name\":\"${email}_singbox_hysteria2\"}" @@ -5520,8 +5338,8 @@ removeUser() { fi if echo ${currentInstallProtocolType} | grep -q 8; then local vlessRealityGRPCResult - vlessRealityGRPCResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}08_VLESS_reality_fallback_grpc_inbounds.json) - echo "${vlessRealityGRPCResult}" | jq . >${configPath}08_VLESS_reality_fallback_grpc_inbounds.json + vlessRealityGRPCResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}08_VLESS_vision_gRPC_inbounds.json) + echo "${vlessRealityGRPCResult}" | jq . >${configPath}08_VLESS_vision_gRPC_inbounds.json fi if echo ${currentInstallProtocolType} | grep -q 6; then @@ -5594,6 +5412,10 @@ bbrInstall() { # 查看、检查日志 checkLog() { + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核" + exit 0 + fi if [[ -z "${configPath}" && -z "${realityStatus}" ]]; then echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容" exit 0 @@ -6087,12 +5909,14 @@ unInstallSniffing() { # 安装嗅探 installSniffing() { readInstallType - find ${configPath} -name "*inbounds.json*" | awk -F "[c][o][n][f][/]" '{print $2}' | while read -r inbound; do - if ! grep -q "destOverride" <"${configPath}${inbound}"; then - sniffing=$(jq -r '.inbounds[0].sniffing = {"enabled":true,"destOverride":["http","tls","quic"]}' "${configPath}${inbound}") - echo "${sniffing}" | jq . >"${configPath}${inbound}" - fi - done + if [[ "${coreInstallType}" == "1" ]]; then + find ${configPath} -name "*inbounds.json*" | awk -F "[c][o][n][f][/]" '{print $2}' | while read -r inbound; do + if ! grep -q "destOverride" <"${configPath}${inbound}"; then + sniffing=$(jq -r '.inbounds[0].sniffing = {"enabled":true,"destOverride":["http","tls","quic"]}' "${configPath}${inbound}") + echo "${sniffing}" | jq . >"${configPath}${inbound}" + fi + done + fi } # warp分流 @@ -6290,7 +6114,7 @@ unInstallWireGuard() { if [[ -n "${singBoxConfigPath}" ]]; then if [[ ! -f "${singBoxConfigPath}config/wireguard_out_IPv6_route.json" && ! -f "${singBoxConfigPath}config/wireguard_out_IPv4_route.json" ]]; then - rm ${singBoxConfigPath}config/wireguard_outbound.json >/dev/null 2>&1 + rm "${singBoxConfigPath}config/wireguard_outbound.json" >/dev/null 2>&1 rm -rf /etc/v2ray-agent/warp/config >/dev/null 2>&1 fi fi @@ -6798,22 +6622,7 @@ reloadCore() { if [[ "${coreInstallType}" == "1" ]]; then handleXray stop handleXray start - # elif [[ "${coreInstallType}" == "2" ]]; then - # handleV2Ray stop - # handleV2Ray start - fi - - # if [[ -n "${hysteriaConfigPath}" ]]; then - # handleHysteria stop - # handleHysteria start - # fi - - # if [[ -n "${tuicConfigPath}" ]]; then - # handleTuic stop - # handleTuic start - # fi - - if [[ -n "${singBoxConfigPath}" ]]; then + elif [[ "${coreInstallType}" == "2" ]]; then handleSingBox stop handleSingBox start fi @@ -7013,23 +6822,18 @@ EOF exit 0 } -# v2ray-core个性化安装 -customV2RayInstall() { +# sing-box 个性化安装 +customSingBoxInstall() { echoContent skyBlue "\n========================个性化安装============================" - echoContent yellow "VLESS前置,默认安装0,如果只需要安装0,则只选择0即可" - echoContent yellow "0.VLESS+TLS_Vision+TCP" - echoContent yellow "1.VLESS+TLS+WS[CDN]" - echoContent yellow "2.Trojan+TLS+gRPC[CDN]" - echoContent yellow "3.VMess+TLS+WS[CDN]" - echoContent yellow "4.Trojan+TLS" - echoContent yellow "5.VLESS+TLS+gRPC[CDN]" + echoContent yellow "0.VLESS+Vision+TCP" + echoContent yellow "7.VLESS+Reality+Vision" + echoContent yellow "8.VLESS+Reality+gRPC" + # echoContent yellow "4.Hysteria2" + # echoContent yellow "5.Tuic" read -r -p "请选择[多选],[例如:123]:" selectCustomInstallType echoContent skyBlue "--------------------------------------------------------------" - if [[ -z ${selectCustomInstallType} ]]; then - selectCustomInstallType=0 - fi - if [[ "${selectCustomInstallType}" =~ ^[0-5]+$ ]]; then - cleanUp xrayClean + + if [[ "${selectCustomInstallType}" =~ ^[0-8]+$ ]]; then checkBTPanel totalProgress=17 installTools 1 @@ -7038,28 +6842,30 @@ customV2RayInstall() { installTLS 3 handleNginx stop # 随机path - if echo ${selectCustomInstallType} | grep -q 1 || echo ${selectCustomInstallType} | grep -q 3 || echo ${selectCustomInstallType} | grep -q 4; then - randomPathFunction 5 - customCDNIP 6 - fi - nginxBlog 7 - updateRedirectNginxConf - handleNginx start + # if echo "${selectCustomInstallType}" | grep -q 1 || echo "${selectCustomInstallType}" | grep -q 3 || echo "${selectCustomInstallType}" | grep -q 4; then + # randomPathFunction 5 + # customCDNIP 6 + # fi + # nginxBlog 7 + # updateRedirectNginxConf + # handleNginx start # 安装V2Ray - installV2Ray 8 - installV2RayService 9 - initV2RayConfig custom 10 + # installV2Ray 8 + installSingBox + # installV2RayService 9 + installSingBoxService + initSingBoxConfig custom 10 cleanUp xrayDel installCronTLS 14 - handleV2Ray stop - handleV2Ray start + handleSingBox stop + handleSingBox start # 生成账号 - checkGFWStatue 15 - showAccounts 16 + # checkGFWStatue 15 + # showAccounts 16 else echoContent red " ---> 输入不合法" - customV2RayInstall + customSingBoxInstall fi } @@ -7085,7 +6891,7 @@ customXrayInstall() { if ! echo "${selectCustomInstallType}" | grep -q "0"; then selectCustomInstallType="0${selectCustomInstallType}" fi - cleanUp v2rayClean + checkBTPanel totalProgress=12 installTools 1 @@ -7126,7 +6932,7 @@ customXrayInstall() { installXray 7 false installXrayService 8 initXrayConfig custom 9 - cleanUp v2rayDel + cleanUp singBoxDel installCronTLS 10 handleXray stop @@ -7145,7 +6951,7 @@ selectCoreInstall() { echoContent skyBlue "\n功能 1/${totalProgress} : 选择核心安装" echoContent red "\n==============================================================" echoContent yellow "1.Xray-core" - # echoContent yellow "2.sing-box" + echoContent yellow "2.sing-box" echoContent red "==============================================================" read -r -p "请选择:" selectCoreType case ${selectCoreType} in @@ -7157,21 +6963,12 @@ selectCoreInstall() { fi ;; 2) - v2rayCoreVersion= - echoContent red " ---> 由于v2ray不支持很多新的特性,为了降低开发成本现停止维护,建议使用Xray-core、hysteria、Tuic" - exit 0 if [[ "${selectInstallType}" == "2" ]]; then - customV2RayInstall + echoContent red "\n ---> 暂不支持,请等待后续更新" + exit 0 + customSingBoxInstall else - v2rayCoreInstall - fi - ;; - 3) - v2rayCoreVersion=v4.32.1 - if [[ "${selectInstallType}" == "2" ]]; then - customV2RayInstall - else - v2rayCoreInstall + singBoxInstall fi ;; *) @@ -7181,43 +6978,9 @@ selectCoreInstall() { esac } -# v2ray-core 安装 -v2rayCoreInstall() { - cleanUp xrayClean - checkBTPanel - selectCustomInstallType= - totalProgress=13 - installTools 2 - # 申请tls - initTLSNginxConfig 3 - - handleV2Ray stop - handleNginx start - - installTLS 4 - handleNginx stop - randomPathFunction 5 - # 安装V2Ray - installV2Ray 6 - installV2RayService 7 - customCDNIP 8 - initV2RayConfig all 9 - cleanUp xrayDel - installCronTLS 10 - nginxBlog 11 - updateRedirectNginxConf - handleV2Ray stop - sleep 2 - handleV2Ray start - handleNginx start - # 生成账号 - checkGFWStatue 12 - showAccounts 13 -} - # xray-core 安装 xrayCoreInstall() { - cleanUp v2rayClean + checkBTPanel selectCustomInstallType= totalProgress=13 @@ -7242,7 +7005,7 @@ xrayCoreInstall() { installXrayService 7 customCDNIP 8 initXrayConfig all 9 - cleanUp v2rayDel + cleanUp singBoxDel installCronTLS 10 if [[ -n "${btDomain}" ]]; then echoContent skyBlue "\n进度 11/${totalProgress} : 检测到宝塔面板,跳过伪装网站" @@ -7267,6 +7030,49 @@ xrayCoreInstall() { showAccounts 13 } +# sing-box 全部安装 +singBoxInstall() { + # checkBTPanel + selectCustomInstallType= + totalProgress=8 + installTools 2 + # if [[ -n "${btDomain}" ]]; then + # echoContent skyBlue "\n进度 3/${totalProgress} : 检测到宝塔面板,跳过申请TLS步骤" + # handleXray stop + # customPortFunction + # else + # 申请tls + initTLSNginxConfig 3 + handleXray stop + # handleNginx start + installTLS 4 + # fi + + handleNginx stop + # randomPathFunction 5 + # 安装sing-box + installSingBox 5 + installSingBoxService 6 + # installXray 6 false + # installXrayService 7 + # customCDNIP 8 + initSingBoxConfig all 7 + cleanUp xrayDel + installCronTLS 8 + + # updateRedirectNginxConf + + handleSingBox stop + handleNginx stop + sleep 2 + handleSingBox start + + # handleNginx start + # 生成账号 + # checkGFWStatue 12 + showAccounts 9 +} + # Hysteria安装 hysteriaCoreInstall() { if ! echo "${currentInstallProtocolType}" | grep -q "0" || [[ -z "${coreInstallType}" ]]; then @@ -7319,7 +7125,7 @@ unInstallXrayCoreReality() { echoContent yellow "# 如果需要卸载其他内容,请卸载脚本功能" handleXray stop rm /etc/v2ray-agent/xray/conf/07_VLESS_vision_reality_inbounds.json - rm /etc/v2ray-agent/xray/conf/08_VLESS_reality_fallback_grpc_inbounds.json + rm /etc/v2ray-agent/xray/conf/08_VLESS_vision_gRPC_inbounds.json echoContent green " ---> 卸载完成" } @@ -7334,16 +7140,13 @@ coreVersionManageMenu() { echoContent skyBlue "\n功能 1/1 : 请选择核心" echoContent red "\n==============================================================" echoContent yellow "1.Xray-core" - echoContent yellow "2.v2ray-core" - echoContent yellow "3.sing-box" + echoContent yellow "2.sing-box" echoContent red "==============================================================" read -r -p "请输入:" selectCore if [[ "${selectCore}" == "1" ]]; then xrayVersionManageMenu 1 elif [[ "${coreInstallType}" == "2" ]]; then - echoContent red " ---> 暂停维护" - elif [[ "${selectCore}" == "3" ]]; then singBoxVersionManageMenu 1 fi } @@ -7379,12 +7182,28 @@ manageAccount() { if [[ "${manageAccountStatus}" == "1" ]]; then showAccounts 1 elif [[ "${manageAccountStatus}" == "2" ]]; then + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" + exit 0 + fi subscribe elif [[ "${manageAccountStatus}" == "3" ]]; then + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" + exit 0 + fi addSubscribeMenu 1 elif [[ "${manageAccountStatus}" == "4" ]]; then + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" + exit 0 + fi addUserXray elif [[ "${manageAccountStatus}" == "5" ]]; then + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" + exit 0 + fi removeUser else echoContent red " ---> 选择错误" @@ -8021,7 +7840,7 @@ switchAlpn() { # 初始化realityKey initRealityKey() { - echoContent skyBlue "\n========================== 生成key ==========================\n" + echoContent skyBlue "\n========================= 生成key ==========================\n" if [[ -n "${currentRealityPublicKey}" ]]; then read -r -p "读取到上次安装记录,是否使用上次安装时的PublicKey/PrivateKey ?[y/n]:" historyKeyStatus if [[ "${historyKeyStatus}" == "y" ]]; then @@ -8030,9 +7849,16 @@ initRealityKey() { fi fi if [[ -z "${realityPrivateKey}" ]]; then - realityX25519Key=$(/etc/v2ray-agent/xray/xray x25519) - realityPrivateKey=$(echo "${realityX25519Key}" | head -1 | awk '{print $3}') - realityPublicKey=$(echo "${realityX25519Key}" | tail -n 1 | awk '{print $3}') + if [[ "${selectCoreType}" == "2" || "${coreInstallType}" == "2" ]]; then + realityX25519Key=$(/etc/v2ray-agent/sing-box/sing-box generate reality-keypair) + realityPrivateKey=$(echo "${realityX25519Key}" | head -1 | awk '{print $2}') + realityPublicKey=$(echo "${realityX25519Key}" | tail -n 1 | awk '{print $2}') + echo "publicKey:${realityPublicKey}" >/etc/v2ray-agent/sing-box/conf/config/reality_key + else + realityX25519Key=$(/etc/v2ray-agent/xray/xray x25519) + realityPrivateKey=$(echo "${realityX25519Key}" | head -1 | awk '{print $3}') + realityPublicKey=$(echo "${realityX25519Key}" | tail -n 1 | awk '{print $3}') + fi fi echoContent green "\n privateKey:${realityPrivateKey}" echoContent green "\n publicKey:${realityPublicKey}" @@ -8078,14 +7904,14 @@ initRealityDest() { } # 初始化客户端可用的ServersName initRealityClientServersName() { - if [[ -n "${domain}" ]]; then + if [[ -n "${domain}" && "${coreInstallType}" == "1" ]]; then realityServerNames=\"${domain}\" elif [[ -n "${realityDestDomain}" ]]; then realityServerNames=$(echo "${realityDestDomain}" | cut -d ":" -f 1) realityServerNames=\"${realityServerNames//,/\",\"}\" else - echoContent skyBlue "\n================ 配置客户端可用的serverNames ================\n" + echoContent skyBlue "\n================ 配置客户端可用的serverNames ===============\n" echoContent yellow "#注意事项" echoContent green "客户端可用的serverNames 列表:https://www.v2ray-agent.com/archives/1680104902581#heading-8\n" echoContent yellow "录入示例:addons.mozilla.org\n" @@ -8107,7 +7933,7 @@ initRealityPort() { realityPort=${currentRealityPort} fi fi - # todo 读取到VLESS_TLS_Vision端口,提示是否使用使用。这里可能有歧义 + if [[ -z "${realityPort}" ]]; then if [[ -n "${port}" ]]; then read -r -p "是否使用TLS+Vision端口 ?[y/n]:" realityPortTLSVisionStatus @@ -8126,11 +7952,6 @@ initRealityPort() { handleXray stop else checkPort "${realityPort}" - # if [[ -n "${port}" && "${port}" == "${realityPort}" ]]; then - # echoContent red " 端口不可与Vision重复--->" - # echo - # realityPort= - # fi fi fi if [[ -z "${realityPort}" ]]; then @@ -8176,7 +7997,7 @@ xrayCoreRealityInstall() { # 初始化配置 initXrayConfig custom 7 handleXray stop - cleanUp v2rayClean + sleep 2 # 启动 handleXray start @@ -8186,7 +8007,10 @@ xrayCoreRealityInstall() { # reality管理 manageReality() { - + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请全部安装或者个性化安装Hysteria2" + exit 0 + fi echoContent skyBlue "\n进度 1/1 : reality管理" echoContent red "\n==============================================================" @@ -8283,8 +8107,6 @@ manageHysteria() { singBoxHysteria2Install elif [[ "${installHysteria2Status}" == "2" && "${hysteria2Status}" == "true" ]]; then unInstallSingBox hysteria2 - # elif [[ "${installHysteria2Status}" == "3" && "${hysteria2Status}" == "true" ]]; then - # singBoxVersionManageMenu 1 fi } @@ -8297,7 +8119,6 @@ manageTuic() { echoContent yellow " 依赖第三方sing-box\n" echoContent yellow "1.重新安装" echoContent yellow "2.卸载" - # echoContent yellow "3.sing-box core管理" tuicStatus=true else echoContent yellow "1.安装" @@ -8310,21 +8131,19 @@ manageTuic() { singBoxTuicInstall elif [[ "${installTuicStatus}" == "2" && "${tuicStatus}" == "true" ]]; then unInstallSingBox tuic - # elif [[ "${installTuicStatus}" == "3" && "${tuicStatus}" == "true" ]]; then - # singBoxVersionManageMenu 1 fi } # sing-box log日志 singBoxLog() { cat </etc/v2ray-agent/sing-box/conf/config/log.json - { - "log": { - "disabled": $1, - "level": "debug", - "output": "/etc/v2ray-agent/sing-box/box.log", - "timestamp": true - } - } +{ + "log": { + "disabled": $1, + "level": "debug", + "output": "/etc/v2ray-agent/sing-box/box.log", + "timestamp": true + } +} EOF handleSingBox stop @@ -8374,7 +8193,7 @@ singBoxVersionManageMenu() { echoContent yellow "4.重启 sing-box" echoContent yellow "==============================================================" local logStatus= - if [[ -n "${singBoxConfigPath}" && -f "${singBoxConfigPath}config/log.json" && "$(jq -r .log.disabled ${singBoxConfigPath}config/log.json)" == "false" ]]; then + if [[ -n "${singBoxConfigPath}" && -f "${singBoxConfigPath}log.json" && "$(jq -r .log.disabled "${singBoxConfigPath}log.json")" == "false" ]]; then echoContent yellow "5.关闭日志" logStatus=true else @@ -8385,61 +8204,33 @@ singBoxVersionManageMenu() { echoContent yellow "6.查看日志" echoContent red "==============================================================" - read -r -p "请选择:" selectTuicType - if [[ "${selectTuicType}" == "1" ]]; then + read -r -p "请选择:" selectSingBoxType + if [[ "${selectSingBoxType}" == "1" ]]; then installSingBox 1 handleSingBox start - elif [[ "${selectTuicType}" == "2" ]]; then + elif [[ "${selectSingBoxType}" == "2" ]]; then handleSingBox stop - elif [[ "${selectTuicType}" == "3" ]]; then + elif [[ "${selectSingBoxType}" == "3" ]]; then handleSingBox start - elif [[ "${selectTuicType}" == "4" ]]; then + elif [[ "${selectSingBoxType}" == "4" ]]; then handleSingBox stop handleSingBox start - elif [[ "${selectTuicType}" == "5" ]]; then + elif [[ "${selectSingBoxType}" == "5" ]]; then singBoxLog ${logStatus} if [[ "${logStatus}" == "false" ]]; then tail -f "${singBoxConfigPath}../box.log" fi - elif [[ "${selectTuicType}" == "6" ]]; then + elif [[ "${selectSingBoxType}" == "6" ]]; then tail -f "${singBoxConfigPath}../box.log" fi } -# Tuic版本管理 -tuicVersionManageMenu() { - echoContent skyBlue "\n进度 $1/${totalProgress} : Tuic版本管理" - if [[ ! -d "/etc/v2ray-agent/tuic/" ]]; then - echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容" - menu - exit 0 - fi - echoContent red "\n==============================================================" - echoContent yellow "1.升级Tuic" - echoContent yellow "2.关闭Tuic" - echoContent yellow "3.打开Tuic" - echoContent yellow "4.重启Tuic" - echoContent red "==============================================================" - - read -r -p "请选择:" selectTuicType - if [[ "${selectTuicType}" == "1" ]]; then - installTuic 1 - handleTuic start - elif [[ "${selectTuicType}" == "2" ]]; then - handleTuic stop - elif [[ "${selectTuicType}" == "3" ]]; then - handleTuic start - elif [[ "${selectTuicType}" == "4" ]]; then - handleTuic stop - handleTuic start - fi -} # 主菜单 menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v2.11.25" + echoContent green "当前版本:v3.1.0-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus @@ -8456,12 +8247,6 @@ menu() { fi echoContent yellow "2.任意组合安装" - if echo ${currentInstallProtocolType} | grep -q trojan; then - echoContent yellow "3.切换VLESS[XTLS]" - elif echo ${currentInstallProtocolType} | grep -q 0; then - echoContent yellow "3.切换Trojan[XTLS]" - fi - echoContent yellow "4.Hysteria2管理" echoContent yellow "5.REALITY管理" echoContent yellow "6.Tuic管理" @@ -8473,7 +8258,6 @@ menu() { echoContent yellow "11.分流工具" echoContent yellow "12.添加新端口" echoContent yellow "13.BT下载管理" - # echoContent yellow "14.切换alpn" echoContent yellow "15.域名黑名单" echoContent skyBlue "-------------------------版本管理-----------------------------" echoContent yellow "16.core管理" From 161b7691eb24b893f67b86531efe7c2f0fc782d8 Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Fri, 15 Dec 2023 16:12:27 +0800 Subject: [PATCH 02/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E6=94=AF=E6=8C=81sing-box?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 100 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 87 insertions(+), 13 deletions(-) diff --git a/install.sh b/install.sh index 013d79f..9af3e42 100644 --- a/install.sh +++ b/install.sh @@ -185,6 +185,11 @@ initVar() { singBoxHysteria2Port= singBoxTuicPort= + # nginx订阅端口 + subscribePort= + + subscribeType= + # sing-box reality serverName publicKey singBoxVLESSRealityGRPCServerName= singBoxVLESSRealityVisionServerName= @@ -331,6 +336,18 @@ readCustomPort() { fi fi } + +# 读取nginx订阅端口 +readNginxSubscribe() { + subscribeType="https" + if [[ -f "${nginxConfigPath}subscribe.conf" ]]; then + subscribePort=$(grep "listen" "${nginxConfigPath}subscribe.conf" | awk '{print $2}') + if ! grep -q "ssl" "${nginxConfigPath}subscribe.conf"; then + subscribeType="http" + fi + fi +} + # 检测安装方式 readInstallType() { coreInstallType= @@ -3456,7 +3473,7 @@ initXrayConfig() { uuid=$(/etc/v2ray-agent/xray/xray uuid) fi - echoContent yellow "\n请输入自定义用户名[需合法],[回车]随机随机用户名" + echoContent yellow "\n请输入自定义用户名[需合法],[回车]随机用户名" read -r -p '用户名:' customEmail if [[ -z ${customEmail} ]]; then customEmail="$(echo "${uuid}" | cut -d "-" -f 1)-VLESS_TCP/TLS_Vision" @@ -4912,6 +4929,7 @@ unInstall() { rm -rf /etc/v2ray-agent rm -rf ${nginxConfigPath}alone.conf rm -rf ${nginxConfigPath}checkPortOpen.conf >/dev/null 2>&1 + rm -rf ${nginxConfigPath}subscribe.conf >/dev/null 2>&1 if [[ -d "${nginxStaticPath}" && -f "${nginxStaticPath}/check" ]]; then rm -rf "${nginxStaticPath}" @@ -7182,10 +7200,6 @@ manageAccount() { if [[ "${manageAccountStatus}" == "1" ]]; then showAccounts 1 elif [[ "${manageAccountStatus}" == "2" ]]; then - if [[ "${coreInstallType}" == "2" ]]; then - echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" - exit 0 - fi subscribe elif [[ "${manageAccountStatus}" == "3" ]]; then if [[ "${coreInstallType}" == "2" ]]; then @@ -7210,6 +7224,56 @@ manageAccount() { fi } +# 安装订阅 +installSubscribe() { + readNginxSubscribe + local nginxSubscribeListen= + local nginxSubscribeSSL= + local serverName= + local SSLType= + + if [[ "${coreInstallType}" == "2" && -z "${subscribePort}" ]]; then + + nginxVersion=$(nginx -v 2>&1) + + mapfile -t result < <(initSingBoxPort "${subscribePort}") + + if ! echo "${currentInstallProtocolType}" | grep -q -E "0|1|2|3|4|5|6|9"; then + echoContent green "未发现tls证书,使用无加密订阅,可能被运营商拦截。请注意风险" + read -r -p "是否使用[y/n]?" addNginxSubscribeStatus + if [[ "${addNginxSubscribeStatus}" != "y" ]]; then + echoContent yellow " ---> 退出安装" + exit + fi + # ipv6 listen [::]:${result[-1]}; + else + SSLType="ssl" + serverName="server_name ${currentHost};" + nginxSubscribeSSL="ssl_certificate /etc/v2ray-agent/tls/${currentHost}.crt;ssl_certificate_key /etc/v2ray-agent/tls/${currentHost}.key;" + fi + + if echo "${nginxVersion}" | grep -q "1.25" && [[ $(echo "${nginxVersion}" | awk -F "[.]" '{print $3}') -gt 0 ]]; then + nginxSubscribeListen="listen ${result[-1]} ${SSLType} so_keepalive=on;http2 on;" + else + nginxSubscribeListen="listen ${result[-1]} ${SSLType} http2 so_keepalive=on;" + fi + + cat <${nginxConfigPath}subscribe.conf +server { + ${nginxSubscribeListen} + ${serverName} + ${nginxSubscribeSSL} + client_max_body_size 100m; + root ${nginxStaticPath}; + location ~ ^/s/(clashMeta|default|clashMetaProfiles)/(.*) { + default_type 'text/plain; charset=utf-8'; + alias /etc/v2ray-agent/subscribe/\$1/\$2; + } +} +EOF + fi +} + # 添加订阅 addSubscribeMenu() { echoContent skyBlue "\n===================== 添加其他机器订阅 =======================" @@ -7659,8 +7723,11 @@ initRandomSalt() { # 订阅 subscribe() { readInstallProtocolType - - if echo "${currentInstallProtocolType}" | grep -q 0 && [[ -n "${configPath}" ]]; then + handleNginx stop + installSubscribe + readNginxSubscribe + handleNginx start + if [[ "${coreInstallType}" == "1" || "${coreInstallType}" == "2" ]]; then echoContent skyBlue "-------------------------备注---------------------------------" echoContent yellow "# 查看订阅会重新生成本地账号的订阅" @@ -7722,11 +7789,18 @@ subscribe() { if [[ -n "${currentDefaultPort}" && "${currentDefaultPort}" != "443" ]]; then currentDomain="${currentHost}:${currentDefaultPort}" fi + if [[ -n "${subscribePort}" ]]; then + if [[ "${subscribeType}" == "http" ]]; then + currentDomain="$(getPublicIP):${subscribePort}" + else + currentDomain="${currentHost}:${subscribePort}" + fi + fi echoContent skyBlue "\n----------默认订阅----------\n" echoContent green "email:${email}\n" - echoContent yellow "url:https://${currentDomain}/s/default/${emailMd5}\n" + echoContent yellow "url:${subscribeType}://${currentDomain}/s/default/${emailMd5}\n" echoContent yellow "在线二维码:https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=https://${currentDomain}/s/default/${emailMd5}\n" - echo "https://${currentDomain}/s/default/${emailMd5}" | qrencode -s 10 -m 1 -t UTF8 + echo "${subscribeType}://${currentDomain}/s/default/${emailMd5}" | qrencode -s 10 -m 1 -t UTF8 # clashMeta if [[ -f "/etc/v2ray-agent/subscribe_local/clashMeta/${email}" ]]; then @@ -7745,12 +7819,12 @@ subscribe() { sed -i '1i\proxies:' "/etc/v2ray-agent/subscribe/clashMeta/${emailMd5}" - local clashProxyUrl="https://${currentDomain}/s/clashMeta/${emailMd5}" + local clashProxyUrl="${subscribeType}://${currentDomain}/s/clashMeta/${emailMd5}" clashMetaConfig "${clashProxyUrl}" "${emailMd5}" echoContent skyBlue "\n----------clashMeta订阅----------\n" - echoContent yellow "url:https://${currentDomain}/s/clashMetaProfiles/${emailMd5}\n" + echoContent yellow "url:${subscribeType}://${currentDomain}/s/clashMetaProfiles/${emailMd5}\n" echoContent yellow "在线二维码:https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=https://${currentDomain}/s/clashMetaProfiles/${emailMd5}\n" - echo "https://${currentDomain}/s/clashMetaProfiles/${emailMd5}" | qrencode -s 10 -m 1 -t UTF8 + echo "${subscribeType}://${currentDomain}/s/clashMetaProfiles/${emailMd5}" | qrencode -s 10 -m 1 -t UTF8 fi echoContent skyBlue "--------------------------------------------------------------" @@ -8230,7 +8304,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v3.1.0-beta" + echoContent green "当前版本:v3.1.1-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus From 9ce2c6b0b427e667834f33b7e67c584f71e9dd61 Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Fri, 15 Dec 2023 17:30:19 +0800 Subject: [PATCH 03/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20sing-box?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 220 ++++++++++++++--------------------------------------- 1 file changed, 58 insertions(+), 162 deletions(-) diff --git a/install.sh b/install.sh index 9af3e42..1cf5afa 100644 --- a/install.sh +++ b/install.sh @@ -4988,24 +4988,6 @@ updateV2RayCDN() { echoContent red " ---> 未安装可用类型" fi } - -# manageUser 用户管理 -manageUser() { - echoContent skyBlue "\n进度 $1/${totalProgress} : 多用户管理" - echoContent skyBlue "-----------------------------------------------------" - echoContent yellow "1.添加用户" - echoContent yellow "2.删除用户" - echoContent skyBlue "-----------------------------------------------------" - read -r -p "请选择:" manageUserType - if [[ "${manageUserType}" == "1" ]]; then - addUser - elif [[ "${manageUserType}" == "2" ]]; then - removeUser - else - echoContent red " ---> 选择错误" - fi -} - # 自定义uuid customUUID() { read -r -p "请输入合法的UUID,[回车]随机UUID:" currentCustomUUID @@ -5057,7 +5039,7 @@ customUserEmail() { } # 添加用户 -addUserXray() { +addUser() { read -r -p "请输入要添加的用户数量:" userNum echo if [[ -z ${userNum} || ${userNum} -le 0 ]]; then @@ -5079,7 +5061,12 @@ addUserXray() { # VLESS TCP if echo "${currentInstallProtocolType}" | grep -q 0; then local clients= - clients=$(initXrayClients 0 "${uuid}" "${email}") + if [[ "${coreInstallType}" == "1" ]]; then + clients=$(initXrayClients 0 "${uuid}" "${email}") + elif [[ "${coreInstallType}" == "2" ]]; then + clients=$(initXrayClients 0 "${uuid}" "${email}") + fi + clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}${frontingType}.json) echo "${clients}" | jq . >${configPath}${frontingType}.json fi @@ -5087,7 +5074,12 @@ addUserXray() { # VLESS WS if echo "${currentInstallProtocolType}" | grep -q 1; then local clients= - clients=$(initXrayClients 1 "${uuid}" "${email}") + if [[ "${coreInstallType}" == "1" ]]; then + clients=$(initXrayClients 1 "${uuid}" "${email}") + elif [[ "${coreInstallType}" == "2" ]]; then + clients=$(initSingBoxClients 1 "${uuid}" "${email}") + fi + clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}03_VLESS_WS_inbounds.json) echo "${clients}" | jq . >${configPath}03_VLESS_WS_inbounds.json fi @@ -5095,14 +5087,24 @@ addUserXray() { # trojan grpc if echo "${currentInstallProtocolType}" | grep -q 2; then local clients= - clients=$(initXrayClients 2 "${uuid}" "${email}") + if [[ "${coreInstallType}" == "1" ]]; then + clients=$(initXrayClients 2 "${uuid}" "${email}") + elif [[ "${coreInstallType}" == "2" ]]; then + clients=$(initSingBoxClients 2 "${uuid}" "${email}") + fi + clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}04_trojan_gRPC_inbounds.json) echo "${clients}" | jq . >${configPath}04_trojan_gRPC_inbounds.json fi # VMess WS if echo "${currentInstallProtocolType}" | grep -q 3; then local clients= - clients=$(initXrayClients 3 "${uuid}" "${email}") + if [[ "${coreInstallType}" == "1" ]]; then + clients=$(initXrayClients 3 "${uuid}" "${email}") + elif [[ "${coreInstallType}" == "2" ]]; then + clients=$(initSingBoxClients 3 "${uuid}" "${email}") + fi + clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}05_VMess_WS_inbounds.json) echo "${clients}" | jq . >${configPath}05_VMess_WS_inbounds.json fi @@ -5110,7 +5112,11 @@ addUserXray() { # trojan tcp if echo "${currentInstallProtocolType}" | grep -q 4; then local clients= - clients=$(initXrayClients 4 "${uuid}" "${email}") + if [[ "${coreInstallType}" == "1" ]]; then + clients=$(initXrayClients 4 "${uuid}" "${email}") + elif [[ "${coreInstallType}" == "2" ]]; then + clients=$(initSingBoxClients 4 "${uuid}" "${email}") + fi clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}04_trojan_TCP_inbounds.json) echo "${clients}" | jq . >${configPath}04_trojan_TCP_inbounds.json fi @@ -5118,7 +5124,11 @@ addUserXray() { # vless grpc if echo "${currentInstallProtocolType}" | grep -q 5; then local clients= - clients=$(initXrayClients 5 "${uuid}" "${email}") + if [[ "${coreInstallType}" == "1" ]]; then + clients=$(initXrayClients 5 "${uuid}" "${email}") + elif [[ "${coreInstallType}" == "2" ]]; then + clients=$(initSingBoxClients 5 "${uuid}" "${email}") + fi clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}06_VLESS_gRPC_inbounds.json) echo "${clients}" | jq . >${configPath}06_VLESS_gRPC_inbounds.json fi @@ -5126,7 +5136,11 @@ addUserXray() { # vless reality vision if echo "${currentInstallProtocolType}" | grep -q 7; then local clients= - clients=$(initXrayClients 7 "${uuid}" "${email}") + if [[ "${coreInstallType}" == "1" ]]; then + clients=$(initXrayClients 7 "${uuid}" "${email}") + elif [[ "${coreInstallType}" == "2" ]]; then + clients=$(initSingBoxClients 7 "${uuid}" "${email}") + fi clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}07_VLESS_vision_reality_inbounds.json) echo "${clients}" | jq . >${configPath}07_VLESS_vision_reality_inbounds.json fi @@ -5134,7 +5148,11 @@ addUserXray() { # vless reality grpc if echo "${currentInstallProtocolType}" | grep -q 8; then local clients= - clients=$(initXrayClients 8 "${uuid}" "${email}") + if [[ "${coreInstallType}" == "1" ]]; then + clients=$(initXrayClients 8 "${uuid}" "${email}") + elif [[ "${coreInstallType}" == "2" ]]; then + clients=$(initSingBoxClients 8 "${uuid}" "${email}") + fi clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}08_VLESS_vision_gRPC_inbounds.json) echo "${clients}" | jq . >${configPath}08_VLESS_vision_gRPC_inbounds.json fi @@ -5142,7 +5160,12 @@ addUserXray() { # hysteria2 if echo ${currentInstallProtocolType} | grep -q 6; then local clients= - clients=$(initXrayClients 6 "${uuid}" "${email}") + + if [[ "${coreInstallType}" == "1" ]]; then + clients=$(initXrayClients 6 "${uuid}" "${email}") + elif [[ "${coreInstallType}" == "2" ]]; then + clients=$(initSingBoxClients 6 "${uuid}" "${email}") + fi clients=$(jq -r ".inbounds[0].users = ${clients}" "${singBoxConfigPath}config/hysteria2.json") echo "${clients}" | jq . >"${singBoxConfigPath}config/hysteria2.json" @@ -5151,7 +5174,11 @@ addUserXray() { # tuic if echo ${currentInstallProtocolType} | grep -q 9; then local clients= - clients=$(initXrayClients 9 "${uuid}" "${email}") + if [[ "${coreInstallType}" == "1" ]]; then + clients=$(initXrayClients 9 "${uuid}" "${email}") + elif [[ "${coreInstallType}" == "2" ]]; then + clients=$(initSingBoxClients 9 "${uuid}" "${email}") + fi clients=$(jq -r ".inbounds[0].users = ${clients}" "${singBoxConfigPath}config/tuic.json") @@ -5162,133 +5189,6 @@ addUserXray() { echoContent green " ---> 添加完成" manageAccount 1 } -# 添加用户 -addUser() { - - echoContent yellow "添加新用户后,需要重新查看订阅" - read -r -p "请输入要添加的用户数量:" userNum - echo - if [[ -z ${userNum} || ${userNum} -le 0 ]]; then - echoContent red " ---> 输入有误,请重新输入" - exit 0 - fi - - # 生成用户 - if [[ "${userNum}" == "1" ]]; then - customUUID - customUserEmail - fi - - while [[ ${userNum} -gt 0 ]]; do - local users= - ((userNum--)) || true - if [[ -n "${currentCustomUUID}" ]]; then - uuid=${currentCustomUUID} - else - uuid=$(${ctlPath} uuid) - fi - - if [[ -n "${currentCustomEmail}" ]]; then - email=${currentCustomEmail}_${uuid} - else - email=${currentHost}_${uuid} - fi - - # 兼容v2ray-core - users="{\"id\":\"${uuid}\",\"flow\":\"xtls-rprx-vision\",\"email\":\"${email}\",\"alterId\":0}" - - if [[ "${coreInstallType}" == "2" ]]; then - users="{\"id\":\"${uuid}\",\"email\":\"${email}\",\"alterId\":0}" - fi - - if echo ${currentInstallProtocolType} | grep -q 0; then - local vlessUsers="${users//\,\"alterId\":0/}" - vlessUsers="${users//${email}/${email}_VLESS_TCP}" - local vlessTcpResult - vlessTcpResult=$(jq -r ".inbounds[0].settings.clients += [${vlessUsers}]" ${configPath}${frontingType}.json) - echo "${vlessTcpResult}" | jq . >${configPath}${frontingType}.json - fi - - if echo ${currentInstallProtocolType} | grep -q trojan; then - local trojanXTLSUsers="${users//\,\"alterId\":0/}" - trojanXTLSUsers="${trojanXTLSUsers//${email}/${email}_Trojan_TCP}" - trojanXTLSUsers=${trojanXTLSUsers//"id"/"password"} - - local trojanXTLSResult - trojanXTLSResult=$(jq -r ".inbounds[0].settings.clients += [${trojanXTLSUsers}]" ${configPath}${frontingType}.json) - echo "${trojanXTLSResult}" | jq . >${configPath}${frontingType}.json - fi - - if echo ${currentInstallProtocolType} | grep -q 1; then - local vlessUsers="${users//\,\"alterId\":0/}" - vlessUsers="${vlessUsers//${email}/${email}_VLESS_TCP}" - vlessUsers="${vlessUsers//\"flow\":\"xtls-rprx-vision\"\,/}" - local vlessWsResult - vlessWsResult=$(jq -r ".inbounds[0].settings.clients += [${vlessUsers}]" ${configPath}03_VLESS_WS_inbounds.json) - echo "${vlessWsResult}" | jq . >${configPath}03_VLESS_WS_inbounds.json - fi - - if echo ${currentInstallProtocolType} | grep -q 2; then - local trojangRPCUsers="${users//\"flow\":\"xtls-rprx-vision\"\,/}" - trojangRPCUsers="${trojangRPCUsers//${email}/${email}_Trojan_gRPC}" - trojangRPCUsers="${trojangRPCUsers//\,\"alterId\":0/}" - trojangRPCUsers=${trojangRPCUsers//"id"/"password"} - - local trojangRPCResult - trojangRPCResult=$(jq -r ".inbounds[0].settings.clients += [${trojangRPCUsers}]" ${configPath}04_trojan_gRPC_inbounds.json) - echo "${trojangRPCResult}" | jq . >${configPath}04_trojan_gRPC_inbounds.json - fi - - if echo ${currentInstallProtocolType} | grep -q 3; then - local vmessUsers="${users//\"flow\":\"xtls-rprx-vision\"\,/}" - vmessUsers="${vmessUsers//${email}/${email}_VMess_TCP}" - local vmessWsResult - vmessWsResult=$(jq -r ".inbounds[0].settings.clients += [${vmessUsers}]" ${configPath}05_VMess_WS_inbounds.json) - echo "${vmessWsResult}" | jq . >${configPath}05_VMess_WS_inbounds.json - fi - - if echo ${currentInstallProtocolType} | grep -q 5; then - local vlessGRPCUsers="${users//\"flow\":\"xtls-rprx-vision\"\,/}" - vlessGRPCUsers="${vlessGRPCUsers//\,\"alterId\":0/}" - vlessGRPCUsers="${vlessGRPCUsers//${email}/${email}_VLESS_gRPC}" - local vlessGRPCResult - vlessGRPCResult=$(jq -r ".inbounds[0].settings.clients += [${vlessGRPCUsers}]" ${configPath}06_VLESS_gRPC_inbounds.json) - echo "${vlessGRPCResult}" | jq . >${configPath}06_VLESS_gRPC_inbounds.json - fi - - if echo ${currentInstallProtocolType} | grep -q 4; then - local trojanUsers="${users//\"flow\":\"xtls-rprx-vision\"\,/}" - trojanUsers="${trojanUsers//id/password}" - trojanUsers="${trojanUsers//\,\"alterId\":0/}" - trojanUsers="${trojanUsers//${email}/${email}_Trojan_TCP}" - - 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 - # hysteria2 - # todo 修改为sing-box - if echo ${currentInstallProtocolType} | grep -q 6; then - local hysteriaResult - users="{\"password\":\"${uuid}\",\"name\":\"${email}_singbox_hysteria2\"}" - hysteriaResult=$(jq -r ".inbounds[0].users += [${users}]" "${singBoxConfigPath}config/hysteria2.json") - echo "${hysteriaResult}" | jq . >"${hysteriaConfigPath}config/hysteria2.json" - fi - - # tuic - if echo ${currentInstallProtocolType} | grep -q 9; then - local hysteriaResult - users="{\"password\":\"${uuid}\",\"uuid\":\"${uuid}\",\"name\":\"${email}_singbox_tuic\"}" - hysteriaResult=$(jq -r ".inbounds[0].users += [\"${uuid}\"]" "${hysteriaConfigPath}config/tuic.json") - echo "${hysteriaResult}" | jq . >"${hysteriaConfigPath}config/tuic.json" - fi - done - - reloadCore - echoContent green " ---> 添加完成" - manageAccount 1 -} - # 移除用户 removeUser() { local uuid= @@ -7208,11 +7108,7 @@ manageAccount() { fi addSubscribeMenu 1 elif [[ "${manageAccountStatus}" == "4" ]]; then - if [[ "${coreInstallType}" == "2" ]]; then - echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" - exit 0 - fi - addUserXray + addUser elif [[ "${manageAccountStatus}" == "5" ]]; then if [[ "${coreInstallType}" == "2" ]]; then echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" @@ -8304,7 +8200,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v3.1.1-beta" + echoContent green "当前版本:v3.1.2-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus From 9ebd7a252360a8a3a0194c539cdafb49879e5fa9 Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Sat, 16 Dec 2023 00:14:54 +0800 Subject: [PATCH 04/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84singbox=20warp=E3=80=81IPv6=E5=88=86=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 181 +++++++++++++++++++++++------------------------------ 1 file changed, 79 insertions(+), 102 deletions(-) diff --git a/install.sh b/install.sh index 1cf5afa..fef67a7 100644 --- a/install.sh +++ b/install.sh @@ -443,10 +443,10 @@ readInstallProtocolType() { done < <(find ${configPath} -name "*inbounds.json" | awk -F "[.]" '{print $1}') - if [[ "${coreInstallType}" == "1" && -n "${singBoxConfigPath}" && -f "/etc/v2ray-agent/sing-box/conf/config.json" ]] && grep -q 'hysteria2' 删除sing-box tuic配置成功" fi if grep -q 'hysteria2' 删除sing-box hysteria2配置成功" fi rm "${singBoxConfigPath}config.json" @@ -809,6 +811,7 @@ readConfigHostPathUUID #readInstallAlpn readCustomPort readXrayCoreRealityConfig +readSingBoxConfig # ------------------------------------------------------------- # 初始化安装目录 @@ -3060,8 +3063,8 @@ EOF initSingBoxRouteConfig() { downloadSingBoxGeositeDB local outboundTag=$1 - if [[ ! -f "${singBoxConfigPath}config/${outboundTag}_route.json" ]]; then - cat <"${singBoxConfigPath}config/${outboundTag}_route.json" + if [[ ! -f "${singBoxConfigPath}${outboundTag}_route.json" ]]; then + cat <"${singBoxConfigPath}${outboundTag}_route.json" { "route": { "geosite": { @@ -3096,8 +3099,8 @@ configurationSingBoxRoute() { if [[ "${type}" == "add" ]]; then addSingBoxRouteRule "${outboundTag}" "${content}" elif [[ "${type}" == "delete" ]]; then - if [[ -f "${singBoxConfigPath}config/${outboundTag}_route.json" ]]; then - rm "${singBoxConfigPath}config/${outboundTag}_route.json" + if [[ -f "${singBoxConfigPath}${outboundTag}_route.json" ]]; then + rm "${singBoxConfigPath}${outboundTag}_route.json" echoContent green "\n ---> 删除成功" fi fi @@ -3105,13 +3108,14 @@ configurationSingBoxRoute() { # 添加sing-box路由规则 addSingBoxRouteRule() { + local outboundTag=$1 local domainList=$2 initSingBoxRouteConfig "${outboundTag}" local rules - rules=$(jq -r '.route.rules[]|select(.outbound=="'"${outboundTag}"'")' "${singBoxConfigPath}config/${outboundTag}_route.json") + rules=$(jq -r '.route.rules[]|select(.outbound=="'"${outboundTag}"'")' "${singBoxConfigPath}${outboundTag}_route.json") while read -r line; do if echo "${rules}" | grep -q "${line}"; then @@ -3126,21 +3130,21 @@ addSingBoxRouteRule() { done < <(echo "${domainList}" | tr ',' '\n') local delRules - delRules=$(jq -r 'del(.route.rules[]|select(.outbound=="'"${outboundTag}"'"))' "${singBoxConfigPath}config/${outboundTag}_route.json") - echo "${delRules}" >"${singBoxConfigPath}config/${outboundTag}_route.json" + delRules=$(jq -r 'del(.route.rules[]|select(.outbound=="'"${outboundTag}"'"))' "${singBoxConfigPath}${outboundTag}_route.json") + echo "${delRules}" >"${singBoxConfigPath}${outboundTag}_route.json" local routeRules - routeRules=$(jq -r ".route.rules += [${rules}]" "${singBoxConfigPath}config/${outboundTag}_route.json") - echo "${routeRules}" >"${singBoxConfigPath}config/${outboundTag}_route.json" + routeRules=$(jq -r ".route.rules += [${rules}]" "${singBoxConfigPath}${outboundTag}_route.json") + echo "${routeRules}" >"${singBoxConfigPath}${outboundTag}_route.json" } # 移除sing-box route rule removeSingBoxRouteRule() { local outboundTag=$1 local delRules - if [[ -f "${singBoxConfigPath}config/${outboundTag}_route.json" ]]; then - delRules=$(jq -r 'del(.route.rules[]|select(.outbound=="'"${outboundTag}"'"))' "${singBoxConfigPath}config/${outboundTag}_route.json") - echo "${delRules}" >"${singBoxConfigPath}config/${outboundTag}_route.json" + if [[ -f "${singBoxConfigPath}${outboundTag}_route.json" ]]; then + delRules=$(jq -r 'del(.route.rules[]|select(.outbound=="'"${outboundTag}"'"))' "${singBoxConfigPath}${outboundTag}_route.json") + echo "${delRules}" >"${singBoxConfigPath}${outboundTag}_route.json" fi } @@ -3153,7 +3157,7 @@ addSingBoxOutbound() { type=ipv6 fi if [[ -n "${detour}" ]]; then - cat <"${singBoxConfigPath}config/${tag}.json" + cat <"${singBoxConfigPath}${tag}.json" { "outbounds": [ { @@ -3167,7 +3171,7 @@ addSingBoxOutbound() { EOF elif echo "${tag}" | grep -q "direct"; then - cat <"${singBoxConfigPath}config/${tag}.json" + cat <"${singBoxConfigPath}${tag}.json" { "outbounds": [ { @@ -3178,7 +3182,7 @@ EOF } EOF else - cat <"${singBoxConfigPath}config/${tag}.json" + cat <"${singBoxConfigPath}${tag}.json" { "outbounds": [ { @@ -3196,15 +3200,15 @@ EOF removeSingBoxOutbound() { local tag=$1 - if [[ -f "${singBoxConfigPath}config/${tag}.json" ]]; then - rm "${singBoxConfigPath}config/${tag}.json" + if [[ -f "${singBoxConfigPath}${tag}.json" ]]; then + rm "${singBoxConfigPath}${tag}.json" fi } # 初始化wireguard出站信息 addSingBoxWireGuardOut() { readConfigWarpReg - cat <"${singBoxConfigPath}config/wireguard_outbound.json" + cat <"${singBoxConfigPath}wireguard_outbound.json" { "outbounds": [ @@ -3227,62 +3231,6 @@ addSingBoxWireGuardOut() { EOF } -# sing-box outbound配置 -configurationSingBoxOutbound() { - # add remove - local type=$1 - local outboundTag=$2 - local content=$3 - if [[ "${outboundTag}" == "" ]]; then - echo - fi -} - -# 初始化sing-box socks5 出站 -initSingBoxSocks5OutboundsConfig() { - local uuid= - uuid=$(/etc/v2ray-agent/xray/xray uuid) - cat </etc/v2ray-agent/sing-box/conf/config/socks5_outbounds.json -{ - "outbounds": [ - { - "type": "socks", - "tag": "singBoxSocks5Out", - "version": "5", - "server":"127.0.0.1", - "server_port":31295, - "username": "singBox_socks5_outbound", - "password": "${uuid}", - "network":"udp" - } -] -} -EOF - - cat <${configPath}/02_socks_inbounds_singbox.json -{ - "inbounds": [ - { - "listen": "127.0.0.1", - "port": 31295, - "protocol": "Socks", - "tag": "socksSingBoxOutbound", - "settings": { - "auth": "password", - "accounts": [ - { - "user": "singBox_socks5_outbound", - "pass": "${uuid}" - } - ], - "udp": true, - "ip": "127.0.0.1" - } - } - ] -} -EOF -} # 初始化 sing-box Hysteria2 配置 initSingBoxHysteria2Config() { echoContent skyBlue "\n进度 $1/${totalProgress} : 初始化Hysteria2配置" @@ -5167,8 +5115,8 @@ addUser() { clients=$(initSingBoxClients 6 "${uuid}" "${email}") fi - clients=$(jq -r ".inbounds[0].users = ${clients}" "${singBoxConfigPath}config/hysteria2.json") - echo "${clients}" | jq . >"${singBoxConfigPath}config/hysteria2.json" + clients=$(jq -r ".inbounds[0].users = ${clients}" "${singBoxConfigPath}hysteria2.json") + echo "${clients}" | jq . >"${singBoxConfigPath}hysteria2.json" fi # tuic @@ -5180,9 +5128,9 @@ addUser() { clients=$(initSingBoxClients 9 "${uuid}" "${email}") fi - clients=$(jq -r ".inbounds[0].users = ${clients}" "${singBoxConfigPath}config/tuic.json") + clients=$(jq -r ".inbounds[0].users = ${clients}" "${singBoxConfigPath}tuic.json") - echo "${clients}" | jq . >"${singBoxConfigPath}config/tuic.json" + echo "${clients}" | jq . >"${singBoxConfigPath}tuic.json" fi done reloadCore @@ -5262,13 +5210,13 @@ removeUser() { if echo ${currentInstallProtocolType} | grep -q 6; then local hysteriaResult - hysteriaResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}config/hysteria2.json") - echo "${hysteriaResult}" | jq . >"${singBoxConfigPath}config/hysteria2.json" + hysteriaResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}hysteria2.json") + echo "${hysteriaResult}" | jq . >"${singBoxConfigPath}hysteria2.json" fi if echo ${currentInstallProtocolType} | grep -q 9; then local tuicResult - tuicResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}config/tuic.json") - echo "${tuicResult}" | jq . >"${singBoxConfigPath}config/tuic.json" + tuicResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}tuic.json") + echo "${tuicResult}" | jq . >"${singBoxConfigPath}tuic.json" fi reloadCore fi @@ -5475,8 +5423,16 @@ ipv6Routing() { echoContent red "==============================================================" read -r -p "请选择:" ipv6Status if [[ "${ipv6Status}" == "1" ]]; then + if [[ "${coreInstallType}" == "1" ]]; then + echoContent yellow "Xray-core:" + jq -r -c '.routing.rules[]|select (.outboundTag=="IPv6_out")|.domain' ${configPath}09_routing.json | jq -r + fi + + if [[ -n "${singBoxConfigPath}" ]]; then + echoContent yellow "sing-box:" + jq -r -c '.route.rules[]|select (.outbound=="IPv6_out")|.geosite' "${singBoxConfigPath}IPv6_out_route.json" | jq -r + fi - jq -r -c '.routing.rules[]|select (.outboundTag=="IPv6_out")|.domain' ${configPath}09_routing.json | jq -r exit 0 elif [[ "${ipv6Status}" == "2" ]]; then echoContent red "==============================================================" @@ -5485,17 +5441,22 @@ ipv6Routing() { echoContent yellow "# 使用教程:https://www.v2ray-agent.com/archives/ba-he-yi-jiao-ben-yu-ming-fen-liu-jiao-cheng \n" read -r -p "请按照上面示例录入域名:" domainList - addInstallRouting IPv6_out outboundTag "${domainList}" + if [[ "${coreInstallType}" == "1" ]]; then + addInstallRouting IPv6_out outboundTag "${domainList}" - unInstallOutbounds IPv6_out + unInstallOutbounds IPv6_out - outbounds=$(jq -r '.outbounds += [{"protocol":"freedom","settings":{"domainStrategy":"UseIPv6"},"tag":"IPv6_out"}]' ${configPath}10_ipv4_outbounds.json) + outbounds=$(jq -r '.outbounds += [{"protocol":"freedom","settings":{"domainStrategy":"UseIPv6"},"tag":"IPv6_out"}]' ${configPath}10_ipv4_outbounds.json) - echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json + echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json + fi + + if [[ "${coreInstallType}" == "2" ]]; then + configurationSingBoxRoute add IPv6_out "${domainList}" + addSingBoxOutbound IPv6_out + addSingBoxOutbound IPv4_out + fi - configurationSingBoxRoute add IPv6_out "${domainList}" - addSingBoxOutbound IPv6_out - addSingBoxOutbound IPv4_out echoContent green " ---> 添加成功" elif [[ "${ipv6Status}" == "3" ]]; then @@ -5981,9 +5942,9 @@ showWireGuardDomain() { fi # sing-box - if [[ -f "${singBoxConfigPath}config/wireguard_out_${type}_route.json" ]]; then + if [[ -f "${singBoxConfigPath}wireguard_out_${type}_route.json" ]]; then echoContent yellow "sing-box" - jq -r -c '.route.rules[]|select (.outbound=="wireguard_out_'"${type}"'")|.geosite' "${singBoxConfigPath}config/wireguard_out_${type}_route.json" | jq -r + jq -r -c '.route.rules[]|select (.outbound=="wireguard_out_'"${type}"'")|.geosite' "${singBoxConfigPath}wireguard_out_${type}_route.json" | jq -r fi } @@ -5993,7 +5954,7 @@ addWireGuardRoute() { local tag=$2 local domainList=$3 # xray - if [[ -n "${configPath}" ]]; then + if [[ "${coreInstallType}" == "1" ]]; then addInstallRouting wireguard_out_"${type}" "${tag}" "${domainList}" unInstallOutbounds wireguard_out_"${type}" @@ -6031,8 +5992,8 @@ unInstallWireGuard() { fi if [[ -n "${singBoxConfigPath}" ]]; then - if [[ ! -f "${singBoxConfigPath}config/wireguard_out_IPv6_route.json" && ! -f "${singBoxConfigPath}config/wireguard_out_IPv4_route.json" ]]; then - rm "${singBoxConfigPath}config/wireguard_outbound.json" >/dev/null 2>&1 + if [[ ! -f "${singBoxConfigPath}wireguard_out_IPv6_route.json" && ! -f "${singBoxConfigPath}wireguard_out_IPv4_route.json" ]]; then + rm "${singBoxConfigPath}wireguard_outbound.json" >/dev/null 2>&1 rm -rf /etc/v2ray-agent/warp/config >/dev/null 2>&1 fi fi @@ -6224,15 +6185,31 @@ routingToolsMenu() { ipv6Routing 1 ;; 4) + if [[ -n "${singBoxConfigPath}" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" + exit 0 + fi dokodemoDoorRouting 1 ;; 5) + if [[ -n "${singBoxConfigPath}" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" + exit 0 + fi dnsRouting 1 ;; 6) + if [[ -n "${singBoxConfigPath}" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" + exit 0 + fi vmessWSRouting 1 ;; 7) + if [[ -n "${singBoxConfigPath}" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" + exit 0 + fi sniRouting 1 ;; esac @@ -8200,7 +8177,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v3.1.2-beta" + echoContent green "当前版本:v3.1.3-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus From 6779ed32f45af9243d61684794da55376a7231ea Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Mon, 18 Dec 2023 00:11:52 +0800 Subject: [PATCH 05/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20sing-box?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AE=89=E8=A3=85reality=E6=97=B6=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E9=80=89=E6=8B=A9=E7=9B=AE=E6=A0=87=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/install.sh b/install.sh index fef67a7..47360af 100644 --- a/install.sh +++ b/install.sh @@ -3940,12 +3940,12 @@ EOF "users":$(initSingBoxClients 7), "tls": { "enabled": true, - "server_name": ${realityServerNames}, + "server_name": "${realityServerNames}", "reality": { "enabled": true, "handshake":{ - "server":${realityServerNames}, - "server_port":443 + "server": "${realityServerNames}", + "server_port":${realityDomainPort} }, "private_key": "${realityPrivateKey}", "short_id": [ @@ -3980,12 +3980,12 @@ EOF "tag": "VLESSRealityGRPC", "tls": { "enabled": true, - "server_name": ${realityServerNames}, + "server_name": "${realityServerNames}", "reality": { "enabled": true, "handshake":{ - "server":${realityServerNames}, - "server_port":443 + "server":"${realityServerNames}", + "server_port":${realityDomainPort} }, "private_key": "${realityPrivateKey}", "short_id": [ @@ -4680,6 +4680,10 @@ updateNginxBlog() { read -r -p "请选择:" selectInstallNginxBlogType if [[ "${selectInstallNginxBlogType}" == "10" ]]; then + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" + exit 0 + fi echoContent red "\n==============================================================" echoContent yellow "重定向的优先级更高,配置302之后如果更改伪装站点,根路由下伪装站点将不起作用" echoContent yellow "如想要伪装站点实现作用需删除302重定向配置\n" @@ -5521,6 +5525,10 @@ EOF # bt下载管理 btTools() { + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" + exit 0 + fi if [[ -z "${configPath}" ]]; then echoContent red " ---> 未安装,请使用脚本安装" menu @@ -5636,6 +5644,10 @@ blacklist() { echoContent green " ---> 添加成功" elif [[ "${blacklistStatus}" == "3" ]]; then + if [[ "${coreInstallType}" == "2" ]]; then + echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" + exit 0 + fi addInstallRouting blackhole_out outboundTag "cn" unInstallOutbounds blackhole_out @@ -7837,7 +7849,7 @@ initRealityDest() { read -r -p "请输入[回车]使用随机:" realityDestDomain if [[ -z "${realityDestDomain}" ]]; then local randomNum= - randomNum=$((RANDOM % 24 + 1)) + randomNum=$((RANDOM % 19 + 1)) realityDestDomain=$(echo "${realityDestDomainList}" | awk -F ',' -v randomNum="$randomNum" '{print $randomNum":443"}') fi if ! echo "${realityDestDomain}" | grep -q ":"; then @@ -7851,6 +7863,7 @@ initRealityDest() { } # 初始化客户端可用的ServersName initRealityClientServersName() { + # todo 兼容xray if [[ -n "${domain}" && "${coreInstallType}" == "1" ]]; then realityServerNames=\"${domain}\" elif [[ -n "${realityDestDomain}" ]]; then @@ -7858,19 +7871,24 @@ initRealityClientServersName() { realityServerNames=\"${realityServerNames//,/\",\"}\" else + local realityDestDomainList="gateway.icloud.com,itunes.apple.com,swdist.apple.com,swcdn.apple.com,updates.cdn-apple.com,mensura.cdn-apple.com,osxapps.itunes.apple.com,aod.itunes.apple.com,download-installer.cdn.mozilla.net,addons.mozilla.org,s0.awsstatic.com,d1.awsstatic.com,images-na.ssl-images-amazon.com,m.media-amazon.com,player.live-video.net,one-piece.com,lol.secure.dyn.riotcdn.net,www.lovelive-anime.jp,www.nokia.com" + realityDomainPort=443 echoContent skyBlue "\n================ 配置客户端可用的serverNames ===============\n" echoContent yellow "#注意事项" - echoContent green "客户端可用的serverNames 列表:https://www.v2ray-agent.com/archives/1680104902581#heading-8\n" - echoContent yellow "录入示例:addons.mozilla.org\n" - read -r -p "请输入[回车]使用随机:" realityServerNames + echoContent green "客户端可用的serverNames 列表:https://www.v2ray-agent.com/archives/1689439383686#heading-3\n" + echoContent yellow "录入示例:addons.mozilla.org:443\n" + read -r -p "请输入目标域名,[回车]随机域名,默认端口443:" realityServerNames if [[ -z "${realityServerNames}" ]]; then - realityServerNames=\"addons.mozilla.org\" - else - realityServerNames=\"${realityServerNames//,/\",\"}\" + randomNum=$((RANDOM % 19 + 1)) + realityServerNames=$(echo "${realityDestDomainList}" | awk -F ',' -v randomNum="$randomNum" '{print $randomNum}') + fi + if echo "${realityServerNames}" | grep -q ":"; then + realityDomainPort=$(echo "${realityServerNames}" | awk -F "[:]" '{print $2}') + realityServerNames=$(echo "${realityServerNames}" | awk -F "[:]" '{print $1}') fi fi - echoContent yellow "\n ---> 客户端可用域名: ${realityServerNames}\n" + echoContent yellow "\n ---> 客户端可用域名: ${realityServerNames}:${realityDomainPort}\n" } # 初始化reality端口 initRealityPort() { @@ -8177,7 +8195,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v3.1.3-beta" + echoContent green "当前版本:v3.1.4-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus From 12e898f104a33b01b662d99ba43c46916f10b5a1 Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:50:23 +0800 Subject: [PATCH 06/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E5=85=BC?= =?UTF-8?q?=E5=AE=B9=E4=B8=8D=E5=90=8C=E6=A0=B8=E5=BF=83=E4=B9=8B=E9=97=B4?= =?UTF-8?q?=E7=9A=84=E7=94=A8=E6=88=B7=E8=AF=BB=E5=8F=96=E3=80=81=E5=AE=89?= =?UTF-8?q?=E8=A3=85=E6=97=B6reality=E5=8F=AF=E4=BB=A5=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E7=9B=AE=E6=A0=87=E5=9F=9F=E5=90=8D=E3=80=81=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?reality=E5=8F=AF=E7=94=A8=E5=9F=9F=E5=90=8D=E3=80=81=E5=AE=8C?= =?UTF-8?q?=E5=96=84sing-box=E8=AE=A2=E9=98=85=EF=BC=88=E9=80=9A=E7=94=A8?= =?UTF-8?q?=E8=AE=A2=E9=98=85&clashmeta=E8=AE=A2=E9=98=85=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 141 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 79 insertions(+), 62 deletions(-) diff --git a/install.sh b/install.sh index 47360af..e39b3a5 100644 --- a/install.sh +++ b/install.sh @@ -292,7 +292,7 @@ initVar() { # Reality realityPrivateKey= - realityServerNames= + realityServerName= realityDestDomain= # 端口状态 @@ -553,7 +553,7 @@ getPublicIP() { if [[ -n "$1" ]]; then type=$1 fi - if [[ -n "${currentHost}" && -n "${currentRealityServerNames}" && "${currentRealityServerNames}" == "${currentHost}" && -z "$1" ]]; then + if [[ -n "${currentHost}" && -n "${currentrealityServerName}" && "${currentrealityServerName}" == "${currentHost}" && -z "$1" ]]; then echo "${currentHost}" else local currentIP= @@ -635,13 +635,13 @@ unInstallSingBox() { # 读取xray reality配置 readXrayCoreRealityConfig() { - currentRealityServerNames= + currentrealityServerName= currentRealityPublicKey= currentRealityPrivateKey= currentRealityPort= if [[ -n "${realityStatus}" ]]; then - currentRealityServerNames=$(jq -r .inbounds[0].streamSettings.realitySettings.serverNames[0] "${configPath}07_VLESS_vision_reality_inbounds.json") + currentrealityServerName=$(jq -r .inbounds[0].streamSettings.realitySettings.serverNames[0] "${configPath}07_VLESS_vision_reality_inbounds.json") currentRealityPublicKey=$(jq -r .inbounds[0].streamSettings.realitySettings.publicKey "${configPath}07_VLESS_vision_reality_inbounds.json") currentRealityPrivateKey=$(jq -r .inbounds[0].streamSettings.realitySettings.privateKey "${configPath}07_VLESS_vision_reality_inbounds.json") currentRealityPort=$(jq -r .inbounds[0].port "${configPath}07_VLESS_vision_reality_inbounds.json") @@ -1138,31 +1138,29 @@ checkPortOpen() { local port=$1 local domain=$2 local checkPortOpenResult= - allowPort "${port}" # 初始化nginx配置 touch ${nginxConfigPath}checkPortOpen.conf cat <${nginxConfigPath}checkPortOpen.conf - server { - listen ${port}; - listen [::]:${port}; - server_name ${domain}; - location /checkPort { - return 200 'fjkvymb6len'; - } - location /ip { - proxy_set_header Host \$host; - proxy_set_header X-Real-IP \$remote_addr; - proxy_set_header REMOTE-HOST \$remote_addr; - proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; - default_type text/plain; - return 200 \$proxy_add_x_forwarded_for; - } +server { + listen ${port}; + listen [::]:${port}; + server_name ${domain}; + location /checkPort { + return 200 'fjkvymb6len'; } + location /ip { + proxy_set_header Host \$host; + proxy_set_header X-Real-IP \$remote_addr; + proxy_set_header REMOTE-HOST \$remote_addr; + proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for; + default_type text/plain; + return 200 \$proxy_add_x_forwarded_for; + } +} EOF handleNginx start - # 检查域名+端口的开放 checkPortOpenResult=$(curl -s -m 10 "http://${domain}:${port}/checkPort") localIP=$(curl -s -m 10 "http://${domain}:${port}/ip") @@ -1213,7 +1211,7 @@ initTLSNginxConfig() { initTLSNginxConfig 3 else dnsTLSDomain=$(echo "${domain}" | awk -F "." '{$1="";print $0}' | sed 's/^[[:space:]]*//' | sed 's/ /./g') - if [[ "${coreInstallType}" == "1" || "${selectCoreType}" == "1" ]]; then + if [[ "${selectCoreType}" == "1" ]]; then customPortFunction fi # 修改配置 @@ -2651,8 +2649,8 @@ initSingBoxClients() { local users= users=[] while read -r user; do - uuid=$(echo "${user}" | jq -r .uuid) - name=$(echo "${user}" | jq -r .name | awk -F "[-]" '{print $1}') + uuid=$(echo "${user}" | jq -r .uuid//.id) + name=$(echo "${user}" | jq -r .name//.email | awk -F "[-]" '{print $1}') currentUser= # VLESS Vision if echo "${type}" | grep -q "0"; then @@ -3750,7 +3748,7 @@ EOF if echo "${selectCustomInstallType}" | grep -q 7 || [[ "$1" == "all" ]]; then echoContent skyBlue "\n===================== 配置VLESS+Reality =====================\n" initRealityPort - initRealityDest + # initRealityDest initRealityClientServersName initRealityKey @@ -3776,10 +3774,10 @@ EOF "security": "reality", "realitySettings": { "show": false, - "dest": "${realityDestDomain}", + "dest": "${realityServerName}:${realityDomainPort}", "xver": 0, "serverNames": [ - ${realityServerNames} + "${realityServerName}" ], "privateKey": "${realityPrivateKey}", "publicKey": "${realityPublicKey}", @@ -3897,6 +3895,7 @@ initSingBoxConfig() { checkDNSIP "${domain}" removeNginxDefaultConf handleSingBox stop + checkPortOpen "${result[-1]}" "${domain}" cat </etc/v2ray-agent/sing-box/conf/config/02_VLESS_TCP_inbounds.json { @@ -3940,11 +3939,11 @@ EOF "users":$(initSingBoxClients 7), "tls": { "enabled": true, - "server_name": "${realityServerNames}", + "server_name": "${realityServerName}", "reality": { "enabled": true, "handshake":{ - "server": "${realityServerNames}", + "server": "${realityServerName}", "server_port":${realityDomainPort} }, "private_key": "${realityPrivateKey}", @@ -3980,11 +3979,11 @@ EOF "tag": "VLESSRealityGRPC", "tls": { "enabled": true, - "server_name": "${realityServerNames}", + "server_name": "${realityServerName}", "reality": { "enabled": true, "handshake":{ - "server":"${realityServerNames}", + "server":"${realityServerName}", "server_port":${realityDomainPort} }, "private_key": "${realityPrivateKey}", @@ -4302,7 +4301,7 @@ EOF echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=hysteria2%3A%2F%2F${id}%40${currentHost}%3A${port}%3Fpeer%3D${currentHost}%26insecure%3D0%26sni%3D${currentHost}%26alpn%3Dh3%23${email}\n" elif [[ "${type}" == "vlessReality" ]]; then - local realityServerName=${currentRealityServerNames} + local realityServerName=${currentrealityServerName} local publicKey=${currentRealityPublicKey} if [[ "${coreInstallType}" == "2" ]]; then realityServerName=${singBoxVLESSRealityVisionServerName} @@ -4336,7 +4335,7 @@ EOF echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40$(getPublicIP)%3A${port}%3Fencryption%3Dnone%26security%3Dreality%26type%3Dtcp%26sni%3D${realityServerName}%26fp%3Dchrome%26pbk%3D${publicKey}%26sid%3D6ba85179e30d4fc2%26flow%3Dxtls-rprx-vision%23${email}\n" elif [[ "${type}" == "vlessRealityGRPC" ]]; then - local realityServerName=${currentRealityServerNames} + local realityServerName=${currentrealityServerName} local publicKey=${currentRealityPublicKey} if [[ "${coreInstallType}" == "2" ]]; then realityServerName=${singBoxVLESSRealityGRPCServerName} @@ -7117,13 +7116,12 @@ installSubscribe() { local serverName= local SSLType= - if [[ "${coreInstallType}" == "2" && -z "${subscribePort}" ]]; then + if [[ "${coreInstallType}" == "2" || "${selectCoreType}" == "2" ]] && [[ -z "${subscribePort}" ]]; then nginxVersion=$(nginx -v 2>&1) - + echoContent skyBlue "配置https订阅\n" mapfile -t result < <(initSingBoxPort "${subscribePort}") - - if ! echo "${currentInstallProtocolType}" | grep -q -E "0|1|2|3|4|5|6|9"; then + if ! echo "${selectCustomInstallType}" | grep -q -E "0|1|2|3|4|5|6|9" && [[ "${selectInstallType}" == "2" ]]; then echoContent green "未发现tls证书,使用无加密订阅,可能被运营商拦截。请注意风险" read -r -p "是否使用[y/n]?" addNginxSubscribeStatus if [[ "${addNginxSubscribeStatus}" != "y" ]]; then @@ -7132,9 +7130,16 @@ installSubscribe() { fi # ipv6 listen [::]:${result[-1]}; else + local subscribeServerName= + if [[ -n "${currentHost}" ]]; then + subscribeServerName="${currentHost}" + else + subscribeServerName="${domain}" + fi + SSLType="ssl" - serverName="server_name ${currentHost};" - nginxSubscribeSSL="ssl_certificate /etc/v2ray-agent/tls/${currentHost}.crt;ssl_certificate_key /etc/v2ray-agent/tls/${currentHost}.key;" + serverName="server_name ${subscribeServerName};" + nginxSubscribeSSL="ssl_certificate /etc/v2ray-agent/tls/${subscribeServerName}.crt;ssl_certificate_key /etc/v2ray-agent/tls/${subscribeServerName}.key;" fi if echo "${nginxVersion}" | grep -q "1.25" && [[ $(echo "${nginxVersion}" | awk -F "[.]" '{print $3}') -gt 0 ]]; then @@ -7645,6 +7650,7 @@ subscribe() { showAccounts >/dev/null if [[ -n $(ls /etc/v2ray-agent/subscribe_local/default/) ]]; then + local subscribePortLocal="${subscribePort}" find /etc/v2ray-agent/subscribe_local/default/* | while read -r email; do email=$(echo "${email}" | awk -F "[d][e][f][a][u][l][t][/]" '{print $2}') # md5加密 @@ -7674,7 +7680,7 @@ subscribe() { if [[ -n "${currentDefaultPort}" && "${currentDefaultPort}" != "443" ]]; then currentDomain="${currentHost}:${currentDefaultPort}" fi - if [[ -n "${subscribePort}" ]]; then + if [[ -n "${subscribePortLocal}" ]]; then if [[ "${subscribeType}" == "http" ]]; then currentDomain="$(getPublicIP):${subscribePort}" else @@ -7842,14 +7848,14 @@ initRealityDest() { realityDestDomain=${domain}:${port} else local realityDestDomainList= - realityDestDomainList="gateway.icloud.com,itunes.apple.com,swdist.apple.com,swcdn.apple.com,updates.cdn-apple.com,mensura.cdn-apple.com,osxapps.itunes.apple.com,aod.itunes.apple.com,download-installer.cdn.mozilla.net,addons.mozilla.org,s0.awsstatic.com,d1.awsstatic.com,images-na.ssl-images-amazon.com,m.media-amazon.com,player.live-video.net,one-piece.com,lol.secure.dyn.riotcdn.net,www.lovelive-anime.jp,www.nokia.com" + realityDestDomainList="gateway.icloud.com,itunes.apple.com,swdist.apple.com,swcdn.apple.com,updates.cdn-apple.com,mensura.cdn-apple.com,osxapps.itunes.apple.com,aod.itunes.apple.com,download-installer.cdn.mozilla.net,addons.mozilla.org,s0.awsstatic.com,d1.awsstatic.com,images-na.ssl-images-amazon.com,m.media-amazon.com,player.live-video.net,one-piece.com,lol.secure.dyn.riotcdn.net,www.lovelive-anime.jp,www.swift.com,academy.nvidia.com,www.cisco.com,www.asus.com,www.samsung.com,www.amd.com,www.googletagmanager.com,cdn-dynmedia-1.microsoft.com,update.microsoft,software.download.prss.microsoft.com,dl.google.com,www.google-analytics.com" echoContent skyBlue "\n===== 生成配置回落的域名 例如:[addons.mozilla.org:443] ======\n" echoContent green "回落域名列表:https://www.v2ray-agent.com/archives/1680104902581#heading-8\n" read -r -p "请输入[回车]使用随机:" realityDestDomain if [[ -z "${realityDestDomain}" ]]; then local randomNum= - randomNum=$((RANDOM % 19 + 1)) + randomNum=$((RANDOM % 30 + 1)) realityDestDomain=$(echo "${realityDestDomainList}" | awk -F ',' -v randomNum="$randomNum" '{print $randomNum":443"}') fi if ! echo "${realityDestDomain}" | grep -q ":"; then @@ -7863,32 +7869,43 @@ initRealityDest() { } # 初始化客户端可用的ServersName initRealityClientServersName() { - # todo 兼容xray - if [[ -n "${domain}" && "${coreInstallType}" == "1" ]]; then - realityServerNames=\"${domain}\" - elif [[ -n "${realityDestDomain}" ]]; then - realityServerNames=$(echo "${realityDestDomain}" | cut -d ":" -f 1) + realityServerName= + if [[ -n "${domain}" ]]; then + echo + read -r -p "是否使用${domain}此域名作为Reality目标域名 ?[y/n]:" realityServerNameCurrentDomainStatus + if [[ "${realityServerNameCurrentDomainStatus}" == "y" ]]; then + realityServerName="${domain}" + if [[ "${selectCoreType}" == "1" ]]; then + realityDomainPort="${port}" + fi - realityServerNames=\"${realityServerNames//,/\",\"}\" - else - local realityDestDomainList="gateway.icloud.com,itunes.apple.com,swdist.apple.com,swcdn.apple.com,updates.cdn-apple.com,mensura.cdn-apple.com,osxapps.itunes.apple.com,aod.itunes.apple.com,download-installer.cdn.mozilla.net,addons.mozilla.org,s0.awsstatic.com,d1.awsstatic.com,images-na.ssl-images-amazon.com,m.media-amazon.com,player.live-video.net,one-piece.com,lol.secure.dyn.riotcdn.net,www.lovelive-anime.jp,www.nokia.com" + if [[ "${selectCoreType}" == "2" && -z "${subscribePort}" ]]; then + echo + installSubscribe + readNginxSubscribe + realityDomainPort="${subscribePort}" + fi + fi + fi + if [[ -z "${realityServerName}" ]]; then + local realityDestDomainList="gateway.icloud.com,itunes.apple.com,swdist.apple.com,swcdn.apple.com,updates.cdn-apple.com,mensura.cdn-apple.com,osxapps.itunes.apple.com,aod.itunes.apple.com,download-installer.cdn.mozilla.net,addons.mozilla.org,s0.awsstatic.com,d1.awsstatic.com,images-na.ssl-images-amazon.com,m.media-amazon.com,player.live-video.net,one-piece.com,lol.secure.dyn.riotcdn.net,www.lovelive-anime.jp,www.swift.com,academy.nvidia.com,www.cisco.com,www.asus.com,www.samsung.com,www.amd.com,www.googletagmanager.com,cdn-dynmedia-1.microsoft.com,update.microsoft,software.download.prss.microsoft.com,dl.google.com,www.google-analytics.com" realityDomainPort=443 echoContent skyBlue "\n================ 配置客户端可用的serverNames ===============\n" echoContent yellow "#注意事项" - echoContent green "客户端可用的serverNames 列表:https://www.v2ray-agent.com/archives/1689439383686#heading-3\n" + echoContent green "Reality目标可用域名列表:https://www.v2ray-agent.com/archives/1689439383686#heading-3\n" echoContent yellow "录入示例:addons.mozilla.org:443\n" - read -r -p "请输入目标域名,[回车]随机域名,默认端口443:" realityServerNames - if [[ -z "${realityServerNames}" ]]; then - randomNum=$((RANDOM % 19 + 1)) - realityServerNames=$(echo "${realityDestDomainList}" | awk -F ',' -v randomNum="$randomNum" '{print $randomNum}') + read -r -p "请输入目标域名,[回车]随机域名,默认端口443:" realityServerName + if [[ -z "${realityServerName}" ]]; then + randomNum=$((RANDOM % 30 + 1)) + realityServerName=$(echo "${realityDestDomainList}" | awk -F ',' -v randomNum="$randomNum" '{print $randomNum}') fi - if echo "${realityServerNames}" | grep -q ":"; then - realityDomainPort=$(echo "${realityServerNames}" | awk -F "[:]" '{print $2}') - realityServerNames=$(echo "${realityServerNames}" | awk -F "[:]" '{print $1}') + if echo "${realityServerName}" | grep -q ":"; then + realityDomainPort=$(echo "${realityServerName}" | awk -F "[:]" '{print $2}') + realityServerName=$(echo "${realityServerName}" | awk -F "[:]" '{print $1}') fi fi - echoContent yellow "\n ---> 客户端可用域名: ${realityServerNames}:${realityDomainPort}\n" + echoContent yellow "\n ---> 客户端可用域名: ${realityServerName}:${realityDomainPort}\n" } # 初始化reality端口 initRealityPort() { @@ -7932,7 +7949,7 @@ initXrayRealityConfig() { echoContent skyBlue "\n进度 $1/${totalProgress} : 初始化 Xray-core reality配置" initRealityPort initRealityKey - initRealityDest + # initRealityDest initRealityClientServersName } # 修改reality域名端口等信息 @@ -7941,7 +7958,7 @@ updateXrayRealityConfig() { local realityVisionResult realityVisionResult=$(jq -r ".inbounds[0].port = ${realityPort}" ${configPath}07_VLESS_vision_reality_inbounds.json) realityVisionResult=$(echo "${realityVisionResult}" | jq -r ".inbounds[0].streamSettings.realitySettings.dest = \"${realityDestDomain}\"") - realityVisionResult=$(echo "${realityVisionResult}" | jq -r ".inbounds[0].streamSettings.realitySettings.serverNames = [${realityServerNames}]") + realityVisionResult=$(echo "${realityVisionResult}" | jq -r ".inbounds[0].streamSettings.realitySettings.serverNames = [${realityServerName}]") realityVisionResult=$(echo "${realityVisionResult}" | jq -r ".inbounds[0].streamSettings.realitySettings.privateKey = \"${realityPrivateKey}\"") realityVisionResult=$(echo "${realityVisionResult}" | jq -r ".inbounds[0].streamSettings.realitySettings.publicKey = \"${realityPublicKey}\"") echo "${realityVisionResult}" | jq . >${configPath}07_VLESS_vision_reality_inbounds.json @@ -8195,7 +8212,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v3.1.4-beta" + echoContent green "当前版本:v3.1.5-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus From 5215cbf8b9f70c7d014a6221c424b8d50999cb2e Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Tue, 19 Dec 2023 14:14:52 +0800 Subject: [PATCH 07/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8Dxray-core=20reality=E8=AE=A2=E9=98=85=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E4=BD=BF=E7=94=A8=E9=97=AE=E9=A2=98=E3=80=81=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E5=8D=95=E7=8B=AC=E7=AE=A1=E7=90=86reality=E7=9A=84?= =?UTF-8?q?=E9=80=89=E9=A1=B9=E3=80=81=E5=85=BC=E5=AE=B9=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E6=A0=B8=E5=BF=83=E4=B9=8B=E5=89=8D=E8=AE=A2=E9=98=85=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index e39b3a5..e0039cd 100644 --- a/install.sh +++ b/install.sh @@ -683,9 +683,13 @@ readConfigHostPathUUID() { fi # reality - if [[ -n "${realityStatus}" && -z "${currentClients}" ]]; then - currentUUID=$(jq -r .inbounds[0].settings.clients[0].id ${configPath}07_VLESS_vision_reality_inbounds.json) - currentClients=$(jq -r .inbounds[0].settings.clients ${configPath}07_VLESS_vision_reality_inbounds.json) + if echo ${currentInstallProtocolType} | grep -q 7; then + # currentUUID=$(jq -r .inbounds[0].settings.clients[0].id ${configPath}07_VLESS_vision_reality_inbounds.json) + # currentClients=$(jq -r .inbounds[0].settings.clients ${configPath}07_VLESS_vision_reality_inbounds.json) + xrayVLESSRealityVisionPort=$(jq -r .inbounds[0].port ${configPath}07_VLESS_vision_reality_inbounds.json) + if [[ "${currentPort}" == "${xrayVLESSRealityVisionPort}" ]]; then + xrayVLESSRealityVisionPort="${currentDefaultPort}" + fi fi elif [[ "${coreInstallType}" == "2" ]]; then currentHost=$(jq -r .inbounds[0].tls.server_name ${configPath}${frontingType}.json) @@ -4555,7 +4559,7 @@ showAccounts() { echoContent skyBlue "\n ---> 账号:${email}" echo - defaultBase64Code vlessReality "${currentDefaultPort}${singBoxVLESSRealityVisionPort}" "${email}" "$(echo "${user}" | jq -r .id//.uuid)" + defaultBase64Code vlessReality "${xrayVLESSRealityVisionPort}${singBoxVLESSRealityVisionPort}" "${email}" "$(echo "${user}" | jq -r .id//.uuid)" done fi # VLESS reality gRPC @@ -4568,7 +4572,7 @@ showAccounts() { echoContent skyBlue "\n ---> 账号:${email}" echo - defaultBase64Code vlessRealityGRPC "${currentDefaultPort}${singBoxVLESSRealityGRPCPort}" "${email}" "$(echo "${user}" | jq -r .id//.uuid)" + defaultBase64Code vlessRealityGRPC "${xrayVLESSRealityVisionPort}${singBoxVLESSRealityGRPCPort}" "${email}" "$(echo "${user}" | jq -r .id//.uuid)" done fi # tuic @@ -6797,7 +6801,7 @@ customXrayInstall() { if ! echo "${selectCustomInstallType}" | grep -q "0"; then selectCustomInstallType="0${selectCustomInstallType}" fi - + unInstallSubscribe checkBTPanel totalProgress=12 installTools 1 @@ -6886,7 +6890,7 @@ selectCoreInstall() { # xray-core 安装 xrayCoreInstall() { - + unInstallSubscribe checkBTPanel selectCustomInstallType= totalProgress=13 @@ -7163,6 +7167,10 @@ server { EOF fi } +# 卸载订阅 +unInstallSubscribe() { + rm -rf ${nginxConfigPath}subscribe.conf >/dev/null 2>&1 +} # 添加订阅 addSubscribeMenu() { @@ -8212,7 +8220,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v3.1.5-beta" + echoContent green "当前版本:v3.1.6-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus @@ -8230,7 +8238,7 @@ menu() { echoContent yellow "2.任意组合安装" echoContent yellow "4.Hysteria2管理" - echoContent yellow "5.REALITY管理" + # echoContent yellow "5.REALITY管理" echoContent yellow "6.Tuic管理" echoContent skyBlue "-------------------------工具管理-----------------------------" echoContent yellow "7.账号管理" @@ -8265,9 +8273,9 @@ menu() { 4) manageHysteria ;; - 5) - manageReality 1 - ;; + # 5) + # manageReality 1 + # ;; 6) manageTuic ;; From 20f5ed6d34e7a184371dfe162f001f394a4b79ed Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Tue, 19 Dec 2023 15:25:04 +0800 Subject: [PATCH 08/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E5=AE=8C?= =?UTF-8?q?=E5=96=84=E4=B8=8D=E5=90=8C=E6=A0=B8=E5=BF=83=E4=B9=8B=E9=97=B4?= =?UTF-8?q?=E7=9A=84=E8=AE=A2=E9=98=85=E9=97=AE=E9=A2=98=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E6=94=B9xray-core=E4=B8=8Bhy2=E5=92=8Ctuic=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98=E4=BB=A5=E5=8F=8A=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 91 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 34 deletions(-) diff --git a/install.sh b/install.sh index e0039cd..915372f 100644 --- a/install.sh +++ b/install.sh @@ -366,10 +366,12 @@ readInstallType() { if [[ -f "${configPath}07_VLESS_vision_reality_inbounds.json" ]]; then realityStatus=1 fi + if [[ -f "/etc/v2ray-agent/sing-box/conf/config/06_hysteria2_inbounds.json" || -f "/etc/v2ray-agent/sing-box/conf/config/09_tuic_inbounds.json" ]]; then + singBoxConfigPath=/etc/v2ray-agent/sing-box/conf/config/ + fi fi - fi - # 检测sing-box - if [[ -d "/etc/v2ray-agent/sing-box" && -f "/etc/v2ray-agent/sing-box/sing-box" && -f "/etc/v2ray-agent/sing-box/conf/config.json" ]]; then + elif [[ -d "/etc/v2ray-agent/sing-box" && -f "/etc/v2ray-agent/sing-box/sing-box" && -f "/etc/v2ray-agent/sing-box/conf/config.json" ]]; then + # 检测sing-box coreInstallType=2 configPath=/etc/v2ray-agent/sing-box/conf/config/ singBoxConfigPath=/etc/v2ray-agent/sing-box/conf/config/ @@ -408,7 +410,7 @@ readInstallProtocolType() { if echo "${row}" | grep -q hysteria2_inbounds; then currentInstallProtocolType=${currentInstallProtocolType}'6' if [[ "${coreInstallType}" == "2" ]]; then - frontingType=hysteria2_inbounds + frontingType=06_hysteria2_inbounds singBoxHysteria2Port=$(jq .inbounds[0].listen_port "${row}.json") fi fi @@ -443,11 +445,15 @@ readInstallProtocolType() { done < <(find ${configPath} -name "*inbounds.json" | awk -F "[.]" '{print $1}') - if [[ "${coreInstallType}" == "1" && -n "${singBoxConfigPath}" && -f "/etc/v2ray-agent/sing-box/conf/06_hysteria2_inbounds.json" ]]; then - currentInstallProtocolType=${currentInstallProtocolType}'6' - fi - if [[ "${coreInstallType}" == "1" && -n "${singBoxConfigPath}" && -f "/etc/v2ray-agent/sing-box/conf/09_tuic_inbounds.json" ]]; then - currentInstallProtocolType=${currentInstallProtocolType}'9' + if [[ "${coreInstallType}" == "1" && -n "${singBoxConfigPath}" ]]; then + if [[ -f "${singBoxConfigPath}06_hysteria2_inbounds.json" ]]; then + currentInstallProtocolType=${currentInstallProtocolType}'6' + singBoxHysteria2Port=$(jq .inbounds[0].listen_port "${singBoxConfigPath}06_hysteria2_inbounds.json") + fi + if [[ -f "${singBoxConfigPath}09_tuic_inbounds.json" ]]; then + currentInstallProtocolType=${currentInstallProtocolType}'9' + singBoxTuicPort=$(jq .inbounds[0].listen_port "${singBoxConfigPath}09_tuic_inbounds.json") + fi fi } @@ -3278,7 +3284,9 @@ singBoxTuicInstall() { totalProgress=5 installSingBox 1 - initSingBoxTuicConfig 2 + selectCustomInstallType=9 + # initSingBoxTuicConfig 2 + initSingBoxConfig custom 2 installSingBoxService 3 reloadCore showAccounts 4 @@ -3297,7 +3305,8 @@ singBoxHysteria2Install() { totalProgress=5 installSingBox 1 - initSingBoxHysteria2Config 2 + selectCustomInstallType=6 + initSingBoxConfig custom 2 installSingBoxService 3 reloadCore showAccounts 4 @@ -3850,9 +3859,16 @@ initTCPBrutal() { # 初始化sing-box配置文件 initSingBoxConfig() { echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化sing-box配置" + echo local uuid= local addClientsStatus= + local sslDomain= + if [[ -n "${domain}" ]]; then + sslDomain="${domain}" + elif [[ -n "${currentHost}" ]]; then + sslDomain="${currentHost}" + fi if [[ -n "${currentUUID}" ]]; then read -r -p "读取到上次用户配置,是否使用上次安装的配置 ?[y/n]:" historyUUIDStatus if [[ "${historyUUIDStatus}" == "y" ]]; then @@ -3911,10 +3927,10 @@ initSingBoxConfig() { "tag":"VLESSTCP", "users":$(initSingBoxClients 0), "tls":{ - "server_name": "${domain}", + "server_name": "${sslDomain}", "enabled": true, - "certificate_path": "/etc/v2ray-agent/tls/${domain}.crt", - "key_path": "/etc/v2ray-agent/tls/${domain}.key" + "certificate_path": "/etc/v2ray-agent/tls/${sslDomain}.crt", + "key_path": "/etc/v2ray-agent/tls/${sslDomain}.key" } } ] @@ -4015,7 +4031,6 @@ EOF mapfile -t result < <(initSingBoxPort "${singBoxHysteria2Port}") echoContent green "\n ---> Hysteria2端口:${result[-1]}" initHysteria2Network - cat </etc/v2ray-agent/sing-box/conf/config/06_hysteria2_inbounds.json { "inbounds": [ @@ -4028,12 +4043,12 @@ EOF "down_mbps":${hysteria2ClientUploadSpeed}, "tls": { "enabled": true, - "server_name":"${domain}", + "server_name":"${sslDomain}", "alpn": [ "h3" ], - "certificate_path": "/etc/v2ray-agent/tls/${domain}.crt", - "key_path": "/etc/v2ray-agent/tls/${domain}.key" + "certificate_path": "/etc/v2ray-agent/tls/${sslDomain}.crt", + "key_path": "/etc/v2ray-agent/tls/${sslDomain}.key" } } ] @@ -4044,7 +4059,7 @@ EOF fi if echo "${selectCustomInstallType}" | grep -q 9 || [[ "$1" == "all" ]]; then - echoContent red "\n================== 配置 Tuic ==================\n" + echoContent red "\n==================== 配置 Tuic =====================\n" echo mapfile -t result < <(initSingBoxPort "${singBoxTuicPort}") echoContent green "\n ---> Tuic端口:${result[-1]}" @@ -4061,12 +4076,12 @@ EOF "congestion_control": "${tuicAlgorithm}", "tls": { "enabled": true, - "server_name":"${domain}", + "server_name":"${sslDomain}", "alpn": [ "h3" ], - "certificate_path": "/etc/v2ray-agent/tls/${domain}.crt", - "key_path": "/etc/v2ray-agent/tls/${domain}.key" + "certificate_path": "/etc/v2ray-agent/tls/${sslDomain}.crt", + "key_path": "/etc/v2ray-agent/tls/${sslDomain}.key" } } ] @@ -4539,12 +4554,16 @@ showAccounts() { done fi # hysteria2 - if echo ${currentInstallProtocolType} | grep -q 6; then + if echo ${currentInstallProtocolType} | grep -q 6 || [[ -n "${hysteriaPort}" ]]; then echoContent skyBlue "\n================================ Hysteria2 TLS [推荐] ================================\n" - jq -r -c '.inbounds[]|.users[]' "${configPath}06_hysteria2_inbounds.json" | while read -r user; do + local path="${configPath}" + if [[ "${coreInstallType}" == "1" ]]; then + path="${singBoxConfigPath}" + fi + jq -r -c '.inbounds[]|.users[]' "${path}06_hysteria2_inbounds.json" | while read -r user; do echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .name)" echo - defaultBase64Code hysteria "${currentDefaultPort}${singBoxHysteria2Port}" "$(echo "${user}" | jq -r .name)" "$(echo "${user}" | jq -r .password)" + defaultBase64Code hysteria "${singBoxHysteria2Port}" "$(echo "${user}" | jq -r .name)" "$(echo "${user}" | jq -r .password)" done fi @@ -4576,12 +4595,16 @@ showAccounts() { done fi # tuic - if echo ${currentInstallProtocolType} | grep -q 9; then + if echo ${currentInstallProtocolType} | grep -q 9 || [[ -n "${tuicPort}" ]]; then echoContent skyBlue "\n================================ Tuic TLS [推荐] ================================\n" - jq -r -c '.inbounds[].users[]' "${configPath}09_tuic_inbounds.json" | while read -r user; do + local path="${configPath}" + if [[ "${coreInstallType}" == "1" ]]; then + path="${singBoxConfigPath}" + fi + jq -r -c '.inbounds[].users[]' "${path}09_tuic_inbounds.json" | while read -r user; do echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .name)" echo - defaultBase64Code tuic "${currentDefaultPort}${singBoxTuicPort}" "$(echo "${user}" | jq -r .name)" "$(echo "${user}" | jq -r .uuid)_$(echo "${user}" | jq -r .password)" + defaultBase64Code tuic "${singBoxTuicPort}" "$(echo "${user}" | jq -r .name)" "$(echo "${user}" | jq -r .uuid)_$(echo "${user}" | jq -r .password)" done fi @@ -6532,7 +6555,8 @@ reloadCore() { if [[ "${coreInstallType}" == "1" ]]; then handleXray stop handleXray start - elif [[ "${coreInstallType}" == "2" ]]; then + fi + if [[ "${coreInstallType}" == "2" || -n "${singBoxConfigPath}" ]]; then handleSingBox stop handleSingBox start fi @@ -7056,7 +7080,7 @@ coreVersionManageMenu() { if [[ "${selectCore}" == "1" ]]; then xrayVersionManageMenu 1 - elif [[ "${coreInstallType}" == "2" ]]; then + elif [[ "${selectCore}" == "2" ]]; then singBoxVersionManageMenu 1 fi } @@ -8080,11 +8104,10 @@ manageHysteria() { echoContent skyBlue "\n进度 1/1 : Hysteria2 管理" echoContent red "\n==============================================================" local hysteria2Status= - if [[ -n "${singBoxConfigPath}" ]] && [[ -f "/etc/v2ray-agent/sing-box/conf/config.json" ]] && grep -q 'hysteria2' Date: Tue, 19 Dec 2023 16:10:47 +0800 Subject: [PATCH 09/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0sing-box=E4=B8=AA=E6=80=A7=E5=8C=96=E5=AE=89=E8=A3=85?= =?UTF-8?q?=E3=80=81=E5=A2=9E=E5=8A=A0=E4=BD=BF=E7=94=A8=E6=97=A0=E8=AF=81?= =?UTF-8?q?=E4=B9=A6=E5=8D=8F=E8=AE=AE=E6=97=B6=E6=8F=90=E7=A4=BA=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=BD=BF=E7=94=A8http=E8=AE=A2=E9=98=85=EF=BC=88?= =?UTF-8?q?=E4=B8=8D=E6=8E=A8=E8=8D=90=E4=BD=BF=E7=94=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 62 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/install.sh b/install.sh index 915372f..a616d15 100644 --- a/install.sh +++ b/install.sh @@ -417,6 +417,7 @@ readInstallProtocolType() { if echo "${row}" | grep -q VLESS_vision_reality_inbounds; then currentInstallProtocolType=${currentInstallProtocolType}'7' if [[ "${coreInstallType}" == "2" ]]; then + frontingType=07_VLESS_vision_reality_inbounds singBoxVLESSRealityVisionPort=$(jq -r .inbounds[0].listen_port "${row}.json") singBoxVLESSRealityVisionServerName=$(jq -r .inbounds[0].tls.server_name "${row}.json") if [[ -f "${configPath}reality_key" ]]; then @@ -427,6 +428,7 @@ readInstallProtocolType() { if echo "${row}" | grep -q VLESS_vision_gRPC_inbounds; then currentInstallProtocolType=${currentInstallProtocolType}'8' if [[ "${coreInstallType}" == "2" ]]; then + frontingType=08_VLESS_vision_reality_inbounds singBoxVLESSRealityGRPCPort=$(jq -r .inbounds[0].listen_port "${row}.json") singBoxVLESSRealityGRPCServerName=$(jq -r .inbounds[0].tls.server_name "${row}.json") if [[ -f "${configPath}reality_key" ]]; then @@ -599,11 +601,15 @@ readSingBoxConfig() { if [[ -f "${singBoxConfigPath}09_tuic_inbounds.json" ]]; then tuicPort=$(jq -r '.inbounds[0].listen_port' "${singBoxConfigPath}09_tuic_inbounds.json") tuicAlgorithm=$(jq -r '.inbounds[0].congestion_control' "${singBoxConfigPath}09_tuic_inbounds.json") + else + tuicPort= fi if [[ -f "${singBoxConfigPath}06_hysteria2_inbounds.json" ]]; then hysteriaPort=$(jq -r '.inbounds[0].listen_port' "${singBoxConfigPath}06_hysteria2_inbounds.json") hysteria2ClientUploadSpeed=$(jq -r '.inbounds[0].down_mbps' "${singBoxConfigPath}06_hysteria2_inbounds.json") hysteria2ClientDownloadSpeed=$(jq -r '.inbounds[0].up_mbps' "${singBoxConfigPath}06_hysteria2_inbounds.json") + else + hysteriaPort= fi fi @@ -698,9 +704,10 @@ readConfigHostPathUUID() { fi fi elif [[ "${coreInstallType}" == "2" ]]; then + currentHost=$(jq -r .inbounds[0].tls.server_name ${configPath}${frontingType}.json) - # currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json) + # currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json) if [[ "${currentAdd}" == "null" ]]; then currentAdd=${currentHost} @@ -3937,7 +3944,7 @@ initSingBoxConfig() { } EOF else - rm /etc/v2ray-agent/sing-box/conf/config/01_VLESS_TCP_inbounds.json >/dev/null 2>&1 + rm /etc/v2ray-agent/sing-box/conf/config/02_VLESS_TCP_inbounds.json >/dev/null 2>&1 fi # VLESS_Reality_Vision @@ -3978,7 +3985,7 @@ EOF } EOF else - rm /etc/v2ray-agent/sing-box/conf/config/02_VLESS_vision_reality_inbounds.json >/dev/null 2>&1 + rm /etc/v2ray-agent/sing-box/conf/config/07_VLESS_vision_reality_inbounds.json >/dev/null 2>&1 fi if echo "${selectCustomInstallType}" | grep -q 8 || [[ "$1" == "all" ]]; then @@ -4022,7 +4029,7 @@ EOF } EOF else - rm /etc/v2ray-agent/sing-box/conf/03_VLESS_vision_gRPC_inbounds.json >/dev/null 2>&1 + rm /etc/v2ray-agent/sing-box/conf/config/08_VLESS_vision_gRPC_inbounds.json >/dev/null 2>&1 fi if echo "${selectCustomInstallType}" | grep -q 6 || [[ "$1" == "all" ]]; then @@ -4055,7 +4062,7 @@ EOF } EOF else - rm /etc/v2ray-agent/sing-box/conf/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 if echo "${selectCustomInstallType}" | grep -q 9 || [[ "$1" == "all" ]]; then @@ -4088,7 +4095,7 @@ EOF } EOF else - rm /etc/v2ray-agent/sing-box/conf/09_tuic_inbounds.json >/dev/null 2>&1 + rm /etc/v2ray-agent/sing-box/conf/config/09_tuic_inbounds.json >/dev/null 2>&1 fi } # 初始化Xray Reality配置 @@ -6760,21 +6767,25 @@ EOF customSingBoxInstall() { echoContent skyBlue "\n========================个性化安装============================" echoContent yellow "0.VLESS+Vision+TCP" + echoContent yellow "6.Hysteria2" echoContent yellow "7.VLESS+Reality+Vision" echoContent yellow "8.VLESS+Reality+gRPC" - # echoContent yellow "4.Hysteria2" - # echoContent yellow "5.Tuic" + echoContent yellow "9.Tuic" + read -r -p "请选择[多选],[例如:123]:" selectCustomInstallType echoContent skyBlue "--------------------------------------------------------------" - if [[ "${selectCustomInstallType}" =~ ^[0-8]+$ ]]; then - checkBTPanel + if [[ "${selectCustomInstallType}" =~ ^[0-9]+$ ]]; then + # checkBTPanel totalProgress=17 installTools 1 # 申请tls - initTLSNginxConfig 2 - installTLS 3 - handleNginx stop + if echo "${selectCustomInstallType}" | grep -q -E "0|6|9"; then + initTLSNginxConfig 2 + installTLS 3 + handleNginx stop + fi + # 随机path # if echo "${selectCustomInstallType}" | grep -q 1 || echo "${selectCustomInstallType}" | grep -q 3 || echo "${selectCustomInstallType}" | grep -q 4; then # randomPathFunction 5 @@ -6784,19 +6795,17 @@ customSingBoxInstall() { # updateRedirectNginxConf # handleNginx start - # 安装V2Ray - # installV2Ray 8 - installSingBox - # installV2RayService 9 - installSingBoxService - initSingBoxConfig custom 10 + installSingBox 4 + installSingBoxService 5 + initSingBoxConfig custom 6 + unInstallSubscribe cleanUp xrayDel - installCronTLS 14 + installCronTLS 7 handleSingBox stop handleSingBox start # 生成账号 - # checkGFWStatue 15 - # showAccounts 16 + checkGFWStatue 8 + showAccounts 9 else echoContent red " ---> 输入不合法" customSingBoxInstall @@ -6898,8 +6907,6 @@ selectCoreInstall() { ;; 2) if [[ "${selectInstallType}" == "2" ]]; then - echoContent red "\n ---> 暂不支持,请等待后续更新" - exit 0 customSingBoxInstall else singBoxInstall @@ -7147,9 +7154,10 @@ installSubscribe() { if [[ "${coreInstallType}" == "2" || "${selectCoreType}" == "2" ]] && [[ -z "${subscribePort}" ]]; then nginxVersion=$(nginx -v 2>&1) - echoContent skyBlue "配置https订阅\n" + echoContent skyBlue "配置订阅中\n" + mapfile -t result < <(initSingBoxPort "${subscribePort}") - if ! echo "${selectCustomInstallType}" | grep -q -E "0|1|2|3|4|5|6|9" && [[ "${selectInstallType}" == "2" ]]; then + if ! echo "${selectCustomInstallType}" | grep -q -E "0|1|2|3|4|5|6|9" || ! echo "${currentInstallProtocolType}" | grep -q -E "0|1|2|3|4|5|6|9"; then echoContent green "未发现tls证书,使用无加密订阅,可能被运营商拦截。请注意风险" read -r -p "是否使用[y/n]?" addNginxSubscribeStatus if [[ "${addNginxSubscribeStatus}" != "y" ]]; then @@ -8243,7 +8251,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v3.1.7-beta" + echoContent green "当前版本:v3.1.8-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus From 7a49fb0f856948491832a6005904da82a60a6c1b Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Tue, 19 Dec 2023 16:33:20 +0800 Subject: [PATCH 10/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E7=A7=BB?= =?UTF-8?q?=E5=8A=A819=E6=9F=A5=E7=9C=8B=E6=97=A5=E5=BF=97=E5=88=B0xray-co?= =?UTF-8?q?re=E5=86=85=E6=A0=B8=E7=AE=A1=E7=90=86=E3=80=81=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E9=A6=96=E6=AC=A1=E5=AE=89=E8=A3=85=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E8=AE=A2=E9=98=85=E6=97=A0=E8=AF=81=E4=B9=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index a616d15..b910c9e 100644 --- a/install.sh +++ b/install.sh @@ -2072,9 +2072,8 @@ v2rayVersionManageMenu() { # xray版本管理 xrayVersionManageMenu() { echoContent skyBlue "\n进度 $1/${totalProgress} : Xray版本管理" - if [[ ! -d "/etc/v2ray-agent/xray/" ]]; then + if [[ "${coreInstallType}" != "1" ]]; then echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容" - menu exit 0 fi echoContent red "\n==============================================================" @@ -2086,6 +2085,7 @@ xrayVersionManageMenu() { echoContent yellow "6.重启Xray-core" echoContent yellow "7.更新geosite、geoip" echoContent yellow "8.设置自动更新geo文件[每天凌晨更新]" + echoContent yellow "9.查看日志" echoContent red "==============================================================" read -r -p "请选择:" selectXrayType if [[ "${selectXrayType}" == "1" ]]; then @@ -2119,6 +2119,8 @@ xrayVersionManageMenu() { updateGeoSite elif [[ "${selectXrayType}" == "8" ]]; then installCronUpdateGeo + elif [[ "${selectXrayType}" == "9" ]]; then + checkLog 1 fi } @@ -7154,10 +7156,11 @@ installSubscribe() { if [[ "${coreInstallType}" == "2" || "${selectCoreType}" == "2" ]] && [[ -z "${subscribePort}" ]]; then nginxVersion=$(nginx -v 2>&1) - echoContent skyBlue "配置订阅中\n" + echoContent yellow " ---> 配置订阅中\n" mapfile -t result < <(initSingBoxPort "${subscribePort}") - if ! echo "${selectCustomInstallType}" | grep -q -E "0|1|2|3|4|5|6|9" || ! echo "${currentInstallProtocolType}" | grep -q -E "0|1|2|3|4|5|6|9"; then + + if (! echo "${selectCustomInstallType}" | grep -q -E "0|1|2|3|4|5|6|9" || ! echo "${currentInstallProtocolType}" | grep -q -E "0|1|2|3|4|5|6|9") && [[ "${selectInstallType}" == "2" ]]; then echoContent green "未发现tls证书,使用无加密订阅,可能被运营商拦截。请注意风险" read -r -p "是否使用[y/n]?" addNginxSubscribeStatus if [[ "${addNginxSubscribeStatus}" != "y" ]]; then @@ -8202,7 +8205,7 @@ hysteriaVersionManageMenu() { # sing-box 版本管理 singBoxVersionManageMenu() { echoContent skyBlue "\n进度 $1/${totalProgress} : sing-box 版本管理" - if [[ ! -f "/etc/v2ray-agent/sing-box/sing-box" ]]; then + if [[ -z "${singBoxConfigPath}" ]]; then echoContent red " ---> 没有检测到安装程序,请执行脚本安装内容" menu exit 0 @@ -8226,6 +8229,9 @@ singBoxVersionManageMenu() { echoContent red "==============================================================" read -r -p "请选择:" selectSingBoxType + if [[ ! -f "${singBoxConfigPath}../box.log" ]]; then + touch "${singBoxConfigPath}../box.log" >/dev/null 2>&1 + fi if [[ "${selectSingBoxType}" == "1" ]]; then installSingBox 1 handleSingBox start @@ -8251,7 +8257,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v3.1.8-beta" + echoContent green "当前版本:v3.1.9-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus @@ -8285,7 +8291,7 @@ menu() { echoContent yellow "17.更新脚本" echoContent yellow "18.安装BBR、DD脚本" echoContent skyBlue "-------------------------脚本管理-----------------------------" - echoContent yellow "19.查看日志" + # echoContent yellow "19.查看日志" echoContent yellow "20.卸载脚本" echoContent red "==============================================================" mkdirTools @@ -8346,9 +8352,9 @@ menu() { 18) bbrInstall ;; - 19) - checkLog 1 - ;; + # 19) + # checkLog 1 + # ;; 20) unInstall 1 ;; From bc458444431d0f6b4d25c69a0e4b2ba139ffa871 Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Tue, 19 Dec 2023 17:51:46 +0800 Subject: [PATCH 11/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E8=AE=A2=E9=98=85=E5=AE=89=E8=A3=85=E6=97=B6=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E5=90=AF=E5=8A=A8nginx=E9=97=AE=E9=A2=98=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AF=BB=E5=8F=96=E5=9F=9F=E5=90=8D=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index b910c9e..ed6b6cf 100644 --- a/install.sh +++ b/install.sh @@ -417,7 +417,7 @@ readInstallProtocolType() { if echo "${row}" | grep -q VLESS_vision_reality_inbounds; then currentInstallProtocolType=${currentInstallProtocolType}'7' if [[ "${coreInstallType}" == "2" ]]; then - frontingType=07_VLESS_vision_reality_inbounds + frontingTypeReality=07_VLESS_vision_reality_inbounds singBoxVLESSRealityVisionPort=$(jq -r .inbounds[0].listen_port "${row}.json") singBoxVLESSRealityVisionServerName=$(jq -r .inbounds[0].tls.server_name "${row}.json") if [[ -f "${configPath}reality_key" ]]; then @@ -428,7 +428,7 @@ readInstallProtocolType() { if echo "${row}" | grep -q VLESS_vision_gRPC_inbounds; then currentInstallProtocolType=${currentInstallProtocolType}'8' if [[ "${coreInstallType}" == "2" ]]; then - frontingType=08_VLESS_vision_reality_inbounds + frontingTypeReality=08_VLESS_vision_gRPC_inbounds singBoxVLESSRealityGRPCPort=$(jq -r .inbounds[0].listen_port "${row}.json") singBoxVLESSRealityGRPCServerName=$(jq -r .inbounds[0].tls.server_name "${row}.json") if [[ -f "${configPath}reality_key" ]]; then @@ -704,17 +704,21 @@ readConfigHostPathUUID() { fi fi elif [[ "${coreInstallType}" == "2" ]]; then - - currentHost=$(jq -r .inbounds[0].tls.server_name ${configPath}${frontingType}.json) + if [[ -n "${frontingType}" ]]; then + currentHost=$(jq -r .inbounds[0].tls.server_name ${configPath}${frontingType}.json) + currentUUID=$(jq -r .inbounds[0].users[0].uuid ${configPath}${frontingType}.json) + currentClients=$(jq -r .inbounds[0].users ${configPath}${frontingType}.json) + else + currentUUID=$(jq -r .inbounds[0].users[0].uuid ${configPath}${frontingTypeReality}.json) + currentClients=$(jq -r .inbounds[0].users ${configPath}${frontingTypeReality}.json) + fi # currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json) if [[ "${currentAdd}" == "null" ]]; then currentAdd=${currentHost} fi - currentUUID=$(jq -r .inbounds[0].users[0].uuid ${configPath}${frontingType}.json) - # currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json) - currentClients=$(jq -r .inbounds[0].users ${configPath}${frontingType}.json) + fi # 读取path @@ -7160,7 +7164,7 @@ installSubscribe() { mapfile -t result < <(initSingBoxPort "${subscribePort}") - if (! echo "${selectCustomInstallType}" | grep -q -E "0|1|2|3|4|5|6|9" || ! echo "${currentInstallProtocolType}" | grep -q -E "0|1|2|3|4|5|6|9") && [[ "${selectInstallType}" == "2" ]]; then + if (! echo "${selectCustomInstallType}" | grep -q -E "0|1|2|3|4|5|6|9" || ! echo "${currentInstallProtocolType}" | grep -q -E "0|1|2|3|4|5|6|9") && [[ "${selectInstallType}" == "2" || "${coreInstallType}" == "2" ]]; then echoContent green "未发现tls证书,使用无加密订阅,可能被运营商拦截。请注意风险" read -r -p "是否使用[y/n]?" addNginxSubscribeStatus if [[ "${addNginxSubscribeStatus}" != "y" ]]; then @@ -7200,6 +7204,8 @@ server { } } EOF + handleNginx stop + handleNginx start fi } # 卸载订阅 @@ -7656,10 +7662,9 @@ initRandomSalt() { # 订阅 subscribe() { readInstallProtocolType - handleNginx stop + installSubscribe readNginxSubscribe - handleNginx start if [[ "${coreInstallType}" == "1" || "${coreInstallType}" == "2" ]]; then echoContent skyBlue "-------------------------备注---------------------------------" @@ -8257,7 +8262,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v3.1.9-beta" + echoContent green "当前版本:v3.1.10-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus From 2220d82a4bf68b5d8eeb4d3176e5cfd585ab0b29 Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Wed, 20 Dec 2023 14:34:36 +0800 Subject: [PATCH 12/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9singbox=E6=97=A5=E5=BF=97=E6=97=A0=E6=B3=95=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E9=97=AE=E9=A2=98=E3=80=81=E4=BF=AE=E6=94=B9=E6=97=A0?= =?UTF-8?q?=E8=AF=81=E4=B9=A6=E8=AE=A2=E9=98=85=E7=9A=84=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=94=B9nginx=E5=BC=82=E5=B8=B8=E6=9C=AA?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/install.sh b/install.sh index ed6b6cf..23bd16b 100644 --- a/install.sh +++ b/install.sh @@ -383,6 +383,15 @@ readInstallType() { readInstallProtocolType() { currentInstallProtocolType= frontingType= + singBoxVLESSVisionPort= + singBoxHysteria2Port= + frontingTypeReality= + singBoxVLESSRealityVisionPort= + singBoxVLESSRealityVisionServerName= + singBoxVLESSRealityGRPCPort= + singBoxVLESSRealityGRPCServerName= + singBoxTuicPort= + singBoxHysteria2Port= while read -r row; do if echo "${row}" | grep -q VLESS_TCP_inbounds; then @@ -439,7 +448,7 @@ readInstallProtocolType() { if echo "${row}" | grep -q tuic_inbounds; then currentInstallProtocolType=${currentInstallProtocolType}'9' if [[ "${coreInstallType}" == "2" ]]; then - frontingType=tuic_inbounds + frontingType=09_tuic_inbounds singBoxTuicPort=$(jq .inbounds[0].listen_port "${row}.json") fi @@ -596,22 +605,19 @@ checkFirewalldAllowPort() { # 读取Tuic配置 readSingBoxConfig() { + tuicPort= + hysteriaPort= if [[ -n "${singBoxConfigPath}" ]]; then if [[ -f "${singBoxConfigPath}09_tuic_inbounds.json" ]]; then tuicPort=$(jq -r '.inbounds[0].listen_port' "${singBoxConfigPath}09_tuic_inbounds.json") tuicAlgorithm=$(jq -r '.inbounds[0].congestion_control' "${singBoxConfigPath}09_tuic_inbounds.json") - else - tuicPort= fi if [[ -f "${singBoxConfigPath}06_hysteria2_inbounds.json" ]]; then hysteriaPort=$(jq -r '.inbounds[0].listen_port' "${singBoxConfigPath}06_hysteria2_inbounds.json") hysteria2ClientUploadSpeed=$(jq -r '.inbounds[0].down_mbps' "${singBoxConfigPath}06_hysteria2_inbounds.json") hysteria2ClientDownloadSpeed=$(jq -r '.inbounds[0].up_mbps' "${singBoxConfigPath}06_hysteria2_inbounds.json") - else - hysteriaPort= fi - fi } @@ -2590,8 +2596,8 @@ initXrayClients() { local users= users=[] while read -r user; do - uuid=$(echo "${user}" | jq -r .id) - email=$(echo "${user}" | jq -r .email | awk -F "[-]" '{print $1}') + uuid=$(echo "${user}" | jq -r .id//.uuid) + email=$(echo "${user}" | jq -r .email//.name | awk -F "[-]" '{print $1}') currentUser= if echo "${type}" | grep -q "0"; then currentUser="{\"id\":\"${uuid}\",\"flow\":\"xtls-rprx-vision\",\"email\":\"${email}-VLESS_TCP/TLS_Vision\"}" @@ -4447,16 +4453,14 @@ showAccounts() { readInstallType readInstallProtocolType readConfigHostPathUUID - readSingBoxConfig readXrayCoreRealityConfig + readSingBoxConfig echo echoContent skyBlue "\n进度 $1/${totalProgress} : 账号" - local show # VLESS TCP if echo ${currentInstallProtocolType} | grep -q 0; then - show=1 echoContent skyBlue "============================= VLESS TCP TLS_Vision [推荐] ==============================\n" jq .inbounds[0].settings.clients//.inbounds[0].users ${configPath}02_VLESS_TCP_inbounds.json | jq -c '.[]' | while read -r user; do @@ -4583,7 +4587,6 @@ showAccounts() { # VLESS reality vision if echo ${currentInstallProtocolType} | grep -q 7; then - show=1 echoContent skyBlue "============================= VLESS reality_vision [推荐] ==============================\n" jq .inbounds[0].settings.clients//.inbounds[0].users ${configPath}07_VLESS_vision_reality_inbounds.json | jq -c '.[]' | while read -r user; do local email= @@ -4596,7 +4599,6 @@ showAccounts() { fi # VLESS reality gRPC if echo ${currentInstallProtocolType} | grep -q 8; then - show=1 echoContent skyBlue "============================== VLESS reality_gRPC [推荐] ===============================\n" jq .inbounds[0].settings.clients//.inbounds[0].users ${configPath}08_VLESS_vision_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do local email= @@ -4621,10 +4623,6 @@ showAccounts() { done fi - - if [[ -z ${show} ]]; then - echoContent red " ---> 未安装" - fi } # 移除nginx302配置 removeNginx302() { @@ -7007,14 +7005,10 @@ singBoxInstall() { cleanUp xrayDel installCronTLS 8 - # updateRedirectNginxConf - handleSingBox stop - handleNginx stop sleep 2 handleSingBox start - # handleNginx start # 生成账号 # checkGFWStatue 12 showAccounts 9 @@ -7164,7 +7158,7 @@ installSubscribe() { mapfile -t result < <(initSingBoxPort "${subscribePort}") - if (! echo "${selectCustomInstallType}" | grep -q -E "0|1|2|3|4|5|6|9" || ! echo "${currentInstallProtocolType}" | grep -q -E "0|1|2|3|4|5|6|9") && [[ "${selectInstallType}" == "2" || "${coreInstallType}" == "2" ]]; then + if ( ([[ -n "${selectCustomInstallType}" ]] && ! echo "${selectCustomInstallType}" | grep -q -E "0|1|2|3|4|5|6|9") || ([[ -n "${currentInstallProtocolType}" ]] && ! echo "${currentInstallProtocolType}" | grep -q -E "0|1|2|3|4|5|6|9")) && [[ "${selectInstallType}" == "2" || "${coreInstallType}" == "2" ]]; then echoContent green "未发现tls证书,使用无加密订阅,可能被运营商拦截。请注意风险" read -r -p "是否使用[y/n]?" addNginxSubscribeStatus if [[ "${addNginxSubscribeStatus}" != "y" ]]; then @@ -8169,7 +8163,7 @@ singBoxLog() { "log": { "disabled": $1, "level": "debug", - "output": "/etc/v2ray-agent/sing-box/box.log", + "output": "/etc/v2ray-agent/sing-box/conf/box.log", "timestamp": true } } @@ -8262,7 +8256,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v3.1.10-beta" + echoContent green "当前版本:v3.1.11-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus From 7a95ec222e840fbb3c3885c57d69e1d6c4bde65e Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Wed, 20 Dec 2023 16:15:05 +0800 Subject: [PATCH 13/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20sing-box?= =?UTF-8?q?=E5=85=BC=E5=AE=B9=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=E3=80=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=94=A8=E6=88=B7=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 101 +++++++++++++++++++++++++++++------------------------ 1 file changed, 55 insertions(+), 46 deletions(-) diff --git a/install.sh b/install.sh index 23bd16b..5ddc0c9 100644 --- a/install.sh +++ b/install.sh @@ -372,6 +372,7 @@ readInstallType() { fi elif [[ -d "/etc/v2ray-agent/sing-box" && -f "/etc/v2ray-agent/sing-box/sing-box" && -f "/etc/v2ray-agent/sing-box/conf/config.json" ]]; then # 检测sing-box + ctlPath=/etc/v2ray-agent/sing-box/sing-box coreInstallType=2 configPath=/etc/v2ray-agent/sing-box/conf/config/ singBoxConfigPath=/etc/v2ray-agent/sing-box/conf/config/ @@ -626,12 +627,12 @@ unInstallSingBox() { local type=$1 if [[ -n "${singBoxConfigPath}" ]]; then if grep -q 'tuic' 删除sing-box tuic配置成功" fi if grep -q 'hysteria2' 删除sing-box hysteria2配置成功" fi rm "${singBoxConfigPath}config.json" @@ -4982,7 +4983,12 @@ customUUID() { read -r -p "请输入合法的UUID,[回车]随机UUID:" currentCustomUUID echo if [[ -z "${currentCustomUUID}" ]]; then - currentCustomUUID=$(${ctlPath} uuid) + if [[ "${selectInstallType}" == "1" || "${coreInstallType}" == "1" ]]; then + currentCustomUUID=$(${ctlPath} uuid) + elif [[ "${selectInstallType}" == "2" || "${coreInstallType}" == "2" ]]; then + currentCustomUUID=$(${ctlPath} generate uuid) + fi + echoContent yellow "uuid:${currentCustomUUID}\n" else @@ -5035,6 +5041,12 @@ addUser() { echoContent red " ---> 输入有误,请重新输入" exit 0 fi + local userConfig= + if [[ "${coreInstallType}" == "1" ]]; then + userConfig=".inbounds[0].settings.clients" + elif [[ "${coreInstallType}" == "2" ]]; then + userConfig=".inbounds[0].users" + fi while [[ ${userNum} -gt 0 ]]; do readConfigHostPathUUID @@ -5053,10 +5065,9 @@ addUser() { if [[ "${coreInstallType}" == "1" ]]; then clients=$(initXrayClients 0 "${uuid}" "${email}") elif [[ "${coreInstallType}" == "2" ]]; then - clients=$(initXrayClients 0 "${uuid}" "${email}") + clients=$(initSingBoxClients 0 "${uuid}" "${email}") fi - - clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}${frontingType}.json) + clients=$(jq -r "${userConfig} = ${clients}" ${configPath}${frontingType}.json) echo "${clients}" | jq . >${configPath}${frontingType}.json fi @@ -5069,7 +5080,7 @@ addUser() { clients=$(initSingBoxClients 1 "${uuid}" "${email}") fi - clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}03_VLESS_WS_inbounds.json) + clients=$(jq -r "${userConfig} = ${clients}" ${configPath}03_VLESS_WS_inbounds.json) echo "${clients}" | jq . >${configPath}03_VLESS_WS_inbounds.json fi @@ -5082,7 +5093,7 @@ addUser() { clients=$(initSingBoxClients 2 "${uuid}" "${email}") fi - clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}04_trojan_gRPC_inbounds.json) + clients=$(jq -r "${userConfig} = ${clients}" ${configPath}04_trojan_gRPC_inbounds.json) echo "${clients}" | jq . >${configPath}04_trojan_gRPC_inbounds.json fi # VMess WS @@ -5094,7 +5105,7 @@ addUser() { clients=$(initSingBoxClients 3 "${uuid}" "${email}") fi - clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}05_VMess_WS_inbounds.json) + clients=$(jq -r "${userConfig} = ${clients}" ${configPath}05_VMess_WS_inbounds.json) echo "${clients}" | jq . >${configPath}05_VMess_WS_inbounds.json fi @@ -5106,7 +5117,7 @@ addUser() { elif [[ "${coreInstallType}" == "2" ]]; then clients=$(initSingBoxClients 4 "${uuid}" "${email}") fi - clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}04_trojan_TCP_inbounds.json) + clients=$(jq -r "${userConfig} = ${clients}" ${configPath}04_trojan_TCP_inbounds.json) echo "${clients}" | jq . >${configPath}04_trojan_TCP_inbounds.json fi @@ -5118,7 +5129,7 @@ addUser() { elif [[ "${coreInstallType}" == "2" ]]; then clients=$(initSingBoxClients 5 "${uuid}" "${email}") fi - clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}06_VLESS_gRPC_inbounds.json) + clients=$(jq -r "${userConfig} = ${clients}" ${configPath}06_VLESS_gRPC_inbounds.json) echo "${clients}" | jq . >${configPath}06_VLESS_gRPC_inbounds.json fi @@ -5130,7 +5141,7 @@ addUser() { elif [[ "${coreInstallType}" == "2" ]]; then clients=$(initSingBoxClients 7 "${uuid}" "${email}") fi - clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}07_VLESS_vision_reality_inbounds.json) + clients=$(jq -r "${userConfig} = ${clients}" ${configPath}07_VLESS_vision_reality_inbounds.json) echo "${clients}" | jq . >${configPath}07_VLESS_vision_reality_inbounds.json fi @@ -5142,7 +5153,7 @@ addUser() { elif [[ "${coreInstallType}" == "2" ]]; then clients=$(initSingBoxClients 8 "${uuid}" "${email}") fi - clients=$(jq -r ".inbounds[0].settings.clients = ${clients}" ${configPath}08_VLESS_vision_gRPC_inbounds.json) + clients=$(jq -r "${userConfig} = ${clients}" ${configPath}08_VLESS_vision_gRPC_inbounds.json) echo "${clients}" | jq . >${configPath}08_VLESS_vision_gRPC_inbounds.json fi @@ -5156,8 +5167,8 @@ addUser() { clients=$(initSingBoxClients 6 "${uuid}" "${email}") fi - clients=$(jq -r ".inbounds[0].users = ${clients}" "${singBoxConfigPath}hysteria2.json") - echo "${clients}" | jq . >"${singBoxConfigPath}hysteria2.json" + clients=$(jq -r ".inbounds[0].users = ${clients}" "${singBoxConfigPath}06_hysteria2_inbounds.json") + echo "${clients}" | jq . >"${singBoxConfigPath}06_hysteria2_inbounds.json" fi # tuic @@ -5169,9 +5180,9 @@ addUser() { clients=$(initSingBoxClients 9 "${uuid}" "${email}") fi - clients=$(jq -r ".inbounds[0].users = ${clients}" "${singBoxConfigPath}tuic.json") + clients=$(jq -r ".inbounds[0].users = ${clients}" "${singBoxConfigPath}09_tuic_inbounds.json") - echo "${clients}" | jq . >"${singBoxConfigPath}tuic.json" + echo "${clients}" | jq . >"${singBoxConfigPath}09_tuic_inbounds.json" fi done reloadCore @@ -5180,34 +5191,36 @@ addUser() { } # 移除用户 removeUser() { + local userConfigType= + if [[ -n "${frontingType}" ]]; then + userConfigType="${frontingType}" + elif [[ -n "${frontingTypeReality}" ]]; then + userConfigType="${frontingTypeReality}" + fi + local uuid= - if echo ${currentInstallProtocolType} | grep -q 0 || echo ${currentInstallProtocolType} | grep -q trojan; then - jq -r -c .inbounds[0].settings.clients[].email ${configPath}${frontingType}.json | awk '{print NR""":"$0}' - read -r -p "请选择要删除的用户编号[仅支持单个删除]:" delUserIndex - if [[ $(jq -r '.inbounds[0].settings.clients|length' ${configPath}${frontingType}.json) -lt ${delUserIndex} ]]; then - echoContent red " ---> 选择错误" - else - delUserIndex=$((delUserIndex - 1)) - local vlessTcpResult - uuid=$(jq -r ".inbounds[0].settings.clients[${delUserIndex}].id" ${configPath}${frontingType}.json) - vlessTcpResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}${frontingType}.json) - echo "${vlessTcpResult}" | jq . >${configPath}${frontingType}.json + if [[ -n "${userConfigType}" ]]; then + if [[ "${coreInstallType}" == "1" ]]; then + jq -r -c .inbounds[0].settings.clients[].email ${configPath}${userConfigType}.json | awk '{print NR""":"$0}' + elif [[ "${coreInstallType}" == "2" ]]; then + jq -r -c .inbounds[0].users[].name ${configPath}${userConfigType}.json | awk '{print NR""":"$0}' fi - elif [[ -n "${realityStatus}" ]]; then - jq -r -c .inbounds[0].settings.clients[].email ${configPath}07_VLESS_vision_reality_inbounds.json | awk '{print NR""":"$0}' + read -r -p "请选择要删除的用户编号[仅支持单个删除]:" delUserIndex - if [[ $(jq -r '.inbounds[0].settings.clients|length' ${configPath}07_VLESS_vision_reality_inbounds.json) -lt ${delUserIndex} ]]; then + if [[ $(jq -r '.inbounds[0].settings.clients|length' ${configPath}${userConfigType}.json) -lt ${delUserIndex} && $(jq -r '.inbounds[0].users|length' ${configPath}${userConfigType}.json) -lt ${delUserIndex} ]]; then echoContent red " ---> 选择错误" else delUserIndex=$((delUserIndex - 1)) - local vlessRealityResult - uuid=$(jq -r ".inbounds[0].settings.clients[${delUserIndex}].id" ${configPath}${frontingType}.json) - vlessRealityResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}07_VLESS_vision_reality_inbounds.json) - echo "${vlessRealityResult}" | jq . >${configPath}07_VLESS_vision_reality_inbounds.json fi fi if [[ -n "${delUserIndex}" ]]; then + + if echo ${currentInstallProtocolType} | grep -q 0; then + local vlessVision + vlessVision=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' ${configPath}02_VLESS_TCP_inbounds.json) + echo "${vlessVision}" | jq . >${configPath}02_VLESS_TCP_inbounds.json + fi if echo ${currentInstallProtocolType} | grep -q 1; then local vlessWSResult vlessWSResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}03_VLESS_WS_inbounds.json) @@ -5240,24 +5253,24 @@ removeUser() { if echo ${currentInstallProtocolType} | grep -q 7; then local vlessRealityResult - vlessRealityResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}07_VLESS_vision_reality_inbounds.json) + vlessRealityResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' ${configPath}07_VLESS_vision_reality_inbounds.json) echo "${vlessRealityResult}" | jq . >${configPath}07_VLESS_vision_reality_inbounds.json fi if echo ${currentInstallProtocolType} | grep -q 8; then local vlessRealityGRPCResult - vlessRealityGRPCResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}08_VLESS_vision_gRPC_inbounds.json) + vlessRealityGRPCResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' ${configPath}08_VLESS_vision_gRPC_inbounds.json) echo "${vlessRealityGRPCResult}" | jq . >${configPath}08_VLESS_vision_gRPC_inbounds.json fi if echo ${currentInstallProtocolType} | grep -q 6; then local hysteriaResult - hysteriaResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}hysteria2.json") - echo "${hysteriaResult}" | jq . >"${singBoxConfigPath}hysteria2.json" + hysteriaResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}06_hysteria2_inbounds.json") + echo "${hysteriaResult}" | jq . >"${singBoxConfigPath}06_hysteria2_inbounds.json" fi if echo ${currentInstallProtocolType} | grep -q 9; then local tuicResult - tuicResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}tuic.json") - echo "${tuicResult}" | jq . >"${singBoxConfigPath}tuic.json" + tuicResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}09_tuic_inbounds.json") + echo "${tuicResult}" | jq . >"${singBoxConfigPath}09_tuic_inbounds.json" fi reloadCore fi @@ -7133,10 +7146,6 @@ manageAccount() { elif [[ "${manageAccountStatus}" == "4" ]]; then addUser elif [[ "${manageAccountStatus}" == "5" ]]; then - if [[ "${coreInstallType}" == "2" ]]; then - echoContent red "\n ---> 此功能仅支持Xray-core内核,请等待后续更新" - exit 0 - fi removeUser else echoContent red " ---> 选择错误" @@ -8256,7 +8265,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v3.1.11-beta" + echoContent green "当前版本:v3.1.12-beta" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus From 781a4c98871b5f974ef2083bc700670a195e9b98 Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Thu, 21 Dec 2023 14:17:32 +0800 Subject: [PATCH 14/14] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E7=94=B3=E8=AF=B7=E9=80=9A=E9=85=8D=E7=AC=A6=E8=AF=81?= =?UTF-8?q?=E4=B9=A6=E7=9A=84=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install.sh b/install.sh index 5ddc0c9..df54d83 100644 --- a/install.sh +++ b/install.sh @@ -1482,6 +1482,10 @@ initDNSAPIConfig() { initDNSAPIConfig "$1" else echo + if ! echo "${dnsTLSDomain}" | grep -q "."; then + echoContent green " ---> 不支持此域名申请通配符证书,建议使用此格式[xx.xx.xx]" + exit 0 + fi read -r -p "是否使用*.${dnsTLSDomain}进行API申请通配符证书?[y/n]:" dnsAPIStatus if [[ "${dnsAPIStatus}" != "y" ]]; then exit 0