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管理"