From c202447e1457445db8773c501100a7c8d657032d Mon Sep 17 00:00:00 2001
From: Hunter0x7c7 <1125607007@qq.com>
Date: 星期四, 11 八月 2022 21:46:34 +0800
Subject: [PATCH] udpate install.sh
---
install.sh | 9668 +++++++++++++++++++++++++++++-----------------------------
1 files changed, 4,834 insertions(+), 4,834 deletions(-)
diff --git a/install.sh b/install.sh
index d010756..10b51c1 100644
--- a/install.sh
+++ b/install.sh
@@ -1,4834 +1,4834 @@
-#!/usr/bin/env bash
-# 妫�娴嬪尯
-# -------------------------------------------------------------
-# 妫�鏌ョ郴缁�
-export LANG=en_US.UTF-8
-
-echoContent() {
- case $1 in
- # 绾㈣壊
- "red")
- # shellcheck disable=SC2154
- ${echoType} "\033[31m${printN}$2 \033[0m"
- ;;
- # 澶╄摑鑹�
- "skyBlue")
- ${echoType} "\033[1;36m${printN}$2 \033[0m"
- ;;
- # 缁胯壊
- "green")
- ${echoType} "\033[32m${printN}$2 \033[0m"
- ;;
- # 鐧借壊
- "white")
- ${echoType} "\033[37m${printN}$2 \033[0m"
- ;;
- "magenta")
- ${echoType} "\033[31m${printN}$2 \033[0m"
- ;;
- # 榛勮壊
- "yellow")
- ${echoType} "\033[33m${printN}$2 \033[0m"
- ;;
- esac
-}
-checkSystem() {
- if [[ -n $(find /etc -name "redhat-release") ]] || grep </proc/version -q -i "centos"; then
- mkdir -p /etc/yum.repos.d
-
- if [[ -f "/etc/centos-release" ]]; then
- centosVersion=$(rpm -q centos-release | awk -F "[-]" '{print $3}' | awk -F "[.]" '{print $1}')
-
- if [[ -z "${centosVersion}" ]] && grep </etc/centos-release -q -i "release 8"; then
- centosVersion=8
- fi
- fi
-
- release="centos"
- installType='yum -y install'
- removeType='yum -y remove'
- upgrade="yum update -y --skip-broken"
-
- elif grep </etc/issue -q -i "debian" && [[ -f "/etc/issue" ]] || grep </etc/issue -q -i "debian" && [[ -f "/proc/version" ]]; then
- release="debian"
- installType='apt -y install'
- upgrade="apt update"
- updateReleaseInfoChange='apt-get --allow-releaseinfo-change update'
- removeType='apt -y autoremove'
-
- elif grep </etc/issue -q -i "ubuntu" && [[ -f "/etc/issue" ]] || grep </etc/issue -q -i "ubuntu" && [[ -f "/proc/version" ]]; then
- release="ubuntu"
- installType='apt -y install'
- upgrade="apt update"
- updateReleaseInfoChange='apt-get --allow-releaseinfo-change update'
- removeType='apt -y autoremove'
- if grep </etc/issue -q -i "16."; then
- release=
- fi
- fi
-
- if [[ -z ${release} ]]; then
- echoContent red "\n鏈剼鏈笉鏀寔姝ょ郴缁燂紝璇峰皢涓嬫柟鏃ュ織鍙嶉缁欏紑鍙戣�匼n"
- echoContent yellow "$(cat /etc/issue)"
- echoContent yellow "$(cat /proc/version)"
- exit 0
- fi
-}
-
-# 妫�鏌PU鎻愪緵鍟�
-checkCPUVendor() {
- if [[ -n $(which uname) ]]; then
- if [[ "$(uname)" == "Linux" ]]; then
- case "$(uname -m)" in
- 'amd64' | 'x86_64')
- xrayCoreCPUVendor="Xray-linux-64"
- v2rayCoreCPUVendor="v2ray-linux-64"
- # hysteriaCoreCPUVendor="hysteria-linux-amd64"
- ;;
- 'armv8' | 'aarch64')
- xrayCoreCPUVendor="Xray-linux-arm64-v8a"
- v2rayCoreCPUVendor="v2ray-linux-arm64-v8a"
- # hysteriaCoreCPUVendor="hysteria-linux-arm64"
- ;;
- *)
- echo " 涓嶆敮鎸佹CPU鏋舵瀯--->"
- exit 1
- ;;
- esac
- fi
- else
- echoContent red " 鏃犳硶璇嗗埆姝PU鏋舵瀯锛岄粯璁md64銆亁86_64--->"
- xrayCoreCPUVendor="Xray-linux-64"
- v2rayCoreCPUVendor="v2ray-linux-64"
- fi
-}
-
-# 鍒濆鍖栧叏灞�鍙橀噺
-initVar() {
- installType='yum -y install'
- removeType='yum -y remove'
- upgrade="yum -y update"
- echoType='echo -e'
-
- # 鏍稿績鏀寔鐨刢pu鐗堟湰
- xrayCoreCPUVendor=""
- v2rayCoreCPUVendor=""
- # hysteriaCoreCPUVendor=""
-
- # 鍩熷悕
- domain=
-
- # CDN鑺傜偣鐨刟ddress
- add=
-
- # 瀹夎鎬昏繘搴�
- totalProgress=1
-
- # 1.xray-core瀹夎
- # 2.v2ray-core 瀹夎
- # 3.v2ray-core[xtls] 瀹夎
- coreInstallType=
-
- # 鏍稿績瀹夎path
- # coreInstallPath=
-
- # v2ctl Path
- ctlPath=
- # 1.鍏ㄩ儴瀹夎
- # 2.涓�у寲瀹夎
- # v2rayAgentInstallType=
-
- # 褰撳墠鐨勪釜鎬у寲瀹夎鏂瑰紡 01234
- currentInstallProtocolType=
-
- # 褰撳墠alpn鐨勯『搴�
- currentAlpn=
-
- # 鍓嶇疆绫诲瀷
- frontingType=
-
- # 閫夋嫨鐨勪釜鎬у寲瀹夎鏂瑰紡
- selectCustomInstallType=
-
- # v2ray-core銆亁ray-core閰嶇疆鏂囦欢鐨勮矾寰�
- configPath=
-
- # 閰嶇疆鏂囦欢鐨刾ath
- currentPath=
-
- # 閰嶇疆鏂囦欢鐨刪ost
- currentHost=
-
- # 瀹夎鏃堕�夋嫨鐨刢ore绫诲瀷
- selectCoreType=
-
- # 榛樿core鐗堟湰
- v2rayCoreVersion=
-
- # 闅忔満璺緞
- customPath=
-
- # centos version
- centosVersion=
-
- # UUID
- currentUUID=
-
- # previousClients
- previousClients=
-
- localIP=
-
- # 闆嗘垚鏇存柊璇佷功閫昏緫涓嶅啀浣跨敤鍗曠嫭鐨勮剼鏈�--RenewTLS
- renewTLS=$1
-
- # tls瀹夎澶辫触鍚庡皾璇曠殑娆℃暟
- installTLSCount=
-
- # BTPanel鐘舵��
- BTPanelStatus=
-
- # nginx閰嶇疆鏂囦欢璺緞
- nginxConfigPath=/etc/nginx/conf.d/
-}
-
-# 妫�娴嬪畨瑁呮柟寮�
-readInstallType() {
- coreInstallType=
- configPath=
-
- # 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 </etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json -q '"security": "tls"'; then
- # 涓嶅甫XTLS鐨剉2ray-core
- coreInstallType=2
- ctlPath=/etc/v2ray-agent/v2ray/v2ctl
- elif grep </etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json -q '"security": "xtls"'; then
- # 甯TLS鐨剉2ray-core
- ctlPath=/etc/v2ray-agent/v2ray/v2ctl
- coreInstallType=3
- fi
- fi
- fi
-
- if [[ -d "/etc/v2ray-agent/xray" && -f "/etc/v2ray-agent/xray/xray" ]]; then
- # 杩欓噷妫�娴媥ray-core
- if [[ -d "/etc/v2ray-agent/xray/conf" ]] && [[ -f "/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json" || -f "/etc/v2ray-agent/xray/conf/02_trojan_TCP_inbounds.json" ]]; then
- # xray-core
- configPath=/etc/v2ray-agent/xray/conf/
- ctlPath=/etc/v2ray-agent/xray/xray
- coreInstallType=1
- fi
- fi
- fi
-}
-
-# 璇诲彇鍗忚绫诲瀷
-readInstallProtocolType() {
- currentInstallProtocolType=
-
- while read -r row; do
- if echo "${row}" | grep -q 02_trojan_TCP_inbounds; then
- currentInstallProtocolType=${currentInstallProtocolType}'trojan'
- frontingType=02_trojan_TCP_inbounds
- fi
- if echo "${row}" | grep -q VLESS_TCP_inbounds; then
- currentInstallProtocolType=${currentInstallProtocolType}'0'
- frontingType=02_VLESS_TCP_inbounds
- fi
- if echo "${row}" | grep -q VLESS_WS_inbounds; then
- currentInstallProtocolType=${currentInstallProtocolType}'1'
- fi
- if echo "${row}" | grep -q trojan_gRPC_inbounds; then
- currentInstallProtocolType=${currentInstallProtocolType}'2'
- fi
- if echo "${row}" | grep -q VMess_WS_inbounds; then
- currentInstallProtocolType=${currentInstallProtocolType}'3'
- fi
- if echo "${row}" | grep -q 04_trojan_TCP_inbounds; then
- currentInstallProtocolType=${currentInstallProtocolType}'4'
- fi
- if echo "${row}" | grep -q VLESS_gRPC_inbounds; then
- currentInstallProtocolType=${currentInstallProtocolType}'5'
- fi
- done < <(find ${configPath} -name "*inbounds.json" | awk -F "[.]" '{print $1}')
-}
-
-# 妫�鏌ユ槸鍚﹀畨瑁呭疂濉�
-checkBTPanel() {
- if pgrep -f "BT-Panel"; then
- nginxConfigPath=/www/server/panel/vhost/nginx/
- BTPanelStatus=true
- fi
-}
-# 璇诲彇褰撳墠alpn鐨勯『搴�
-readInstallAlpn() {
- if [[ -n ${currentInstallProtocolType} ]]; then
- local alpn
- alpn=$(jq -r .inbounds[0].streamSettings.xtlsSettings.alpn[0] ${configPath}${frontingType}.json)
- if [[ -n ${alpn} ]]; then
- currentAlpn=${alpn}
- fi
- fi
-}
-
-# 妫�鏌ラ槻鐏
-allowPort() {
- # 濡傛灉闃茬伀澧欏惎鍔ㄧ姸鎬佸垯娣诲姞鐩稿簲鐨勫紑鏀剧鍙�
- if systemctl status netfilter-persistent 2>/dev/null | grep -q "active (exited)"; then
- local updateFirewalldStatus=
- if ! iptables -L | grep -q "$1(mack-a)"; then
- updateFirewalldStatus=true
- iptables -I INPUT -p tcp --dport "$1" -m comment --comment "allow $1(mack-a)" -j ACCEPT
- fi
-
- if echo "${updateFirewalldStatus}" | grep -q "true"; then
- netfilter-persistent save
- fi
- elif systemctl status ufw 2>/dev/null | grep -q "active (exited)"; then
- if ufw status | grep -q "Status: active"; then
- if ! ufw status | grep -q "$1"; then
- sudo ufw allow "$1"
- checkUFWAllowPort "$1"
- fi
- fi
-
- elif
- systemctl status firewalld 2>/dev/null | grep -q "active (running)"
- then
- local updateFirewalldStatus=
- if ! firewall-cmd --list-ports --permanent | grep -qw "$1/tcp"; then
- updateFirewalldStatus=true
- firewall-cmd --zone=public --add-port="$1/tcp" --permanent
- checkFirewalldAllowPort "$1"
- fi
-
- if echo "${updateFirewalldStatus}" | grep -q "true"; then
- firewall-cmd --reload
- fi
- fi
-}
-
-# 妫�鏌�80銆�443绔彛鍗犵敤鎯呭喌
-checkPortUsedStatus() {
- if lsof -i tcp:80 | grep -q LISTEN; then
- echoContent red "\n ---> 80绔彛琚崰鐢紝璇锋墜鍔ㄥ叧闂悗瀹夎\n"
- lsof -i tcp:80 | grep LISTEN
- exit 0
- fi
-
- if lsof -i tcp:443 | grep -q LISTEN; then
- echoContent red "\n ---> 443绔彛琚崰鐢紝璇锋墜鍔ㄥ叧闂悗瀹夎\n"
- lsof -i tcp:80 | grep LISTEN
- exit 0
- fi
-}
-
-# 杈撳嚭ufw绔彛寮�鏀剧姸鎬�
-checkUFWAllowPort() {
- if ufw status | grep -q "$1"; then
- echoContent green " ---> $1绔彛寮�鏀炬垚鍔�"
- else
- echoContent red " ---> $1绔彛寮�鏀惧け璐�"
- exit 0
- fi
-}
-
-# 杈撳嚭firewall-cmd绔彛寮�鏀剧姸鎬�
-checkFirewalldAllowPort() {
- if firewall-cmd --list-ports --permanent | grep -q "$1"; then
- echoContent green " ---> $1绔彛寮�鏀炬垚鍔�"
- else
- echoContent red " ---> $1绔彛寮�鏀惧け璐�"
- exit 0
- fi
-}
-# 妫�鏌ユ枃浠剁洰褰曚互鍙妏ath璺緞
-readConfigHostPathUUID() {
- currentPath=
- currentDefaultPort=
- currentUUID=
- currentHost=
- # currentPort=
- currentAdd=
- # 璇诲彇path
- if [[ -n "${configPath}" ]]; then
- local fallback
- fallback=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.path)' ${configPath}${frontingType}.json | head -1)
-
- local path
- path=$(echo "${fallback}" | jq -r .path | awk -F "[/]" '{print $2}')
-
- if [[ $(echo "${fallback}" | jq -r .dest) == 31297 ]]; then
- currentPath=$(echo "${path}" | awk -F "[w][s]" '{print $1}')
- elif [[ $(echo "${fallback}" | jq -r .dest) == 31298 ]]; then
- currentPath=$(echo "${path}" | awk -F "[t][c][p]" '{print $1}')
- elif [[ $(echo "${fallback}" | jq -r .dest) == 31299 ]]; then
- currentPath=$(echo "${path}" | awk -F "[v][w][s]" '{print $1}')
- fi
- # 灏濊瘯璇诲彇alpn h2 Path
-
- if [[ -z "${currentPath}" ]]; then
- dest=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.alpn)|.dest' ${configPath}${frontingType}.json | head -1)
- if [[ "${dest}" == "31302" || "${dest}" == "31304" ]]; then
-
- if grep -q "trojangrpc {" <${nginxConfigPath}alone.conf; then
- currentPath=$(grep "trojangrpc {" <${nginxConfigPath}alone.conf | awk -F "[/]" '{print $2}' | awk -F "[t][r][o][j][a][n]" '{print $1}')
- elif grep -q "grpc {" <${nginxConfigPath}alone.conf; then
- currentPath=$(grep "grpc {" <${nginxConfigPath}alone.conf | head -1 | awk -F "[/]" '{print $2}' | awk -F "[g][r][p][c]" '{print $1}')
- fi
- fi
- fi
-
-
- local defaultPortFile=
- defaultPortFile=$(find ${configPath}* | grep "default")
-
- if [[ -n "${defaultPortFile}" ]]; then
- currentDefaultPort=$(echo "${defaultPortFile}" | awk -F [_] '{print $4}')
- else
- currentDefaultPort=443
- fi
-
- fi
- if [[ "${coreInstallType}" == "1" ]]; then
- currentHost=$(jq -r .inbounds[0].streamSettings.xtlsSettings.certificates[0].certificateFile ${configPath}${frontingType}.json | awk -F '[t][l][s][/]' '{print $2}' | awk -F '[.][c][r][t]' '{print $1}')
- currentUUID=$(jq -r .inbounds[0].settings.clients[0].id ${configPath}${frontingType}.json)
- currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json)
- if [[ "${currentAdd}" == "null" ]]; then
- currentAdd=${currentHost}
- fi
- # currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json)
-
- elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then
- if [[ "${coreInstallType}" == "3" ]]; then
-
- currentHost=$(jq -r .inbounds[0].streamSettings.xtlsSettings.certificates[0].certificateFile ${configPath}${frontingType}.json | awk -F '[t][l][s][/]' '{print $2}' | awk -F '[.][c][r][t]' '{print $1}')
- else
- 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}')
- 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].settings.clients[0].id ${configPath}${frontingType}.json)
- # currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json)
- fi
-}
-
-# 鐘舵�佸睍绀�
-showInstallStatus() {
- if [[ -n "${coreInstallType}" ]]; then
- if [[ "${coreInstallType}" == 1 ]]; then
- if [[ -n $(pgrep -f xray/xray) ]]; then
- echoContent yellow "\n鏍稿績: Xray-core[杩愯涓璢"
- else
- echoContent yellow "\n鏍稿績: Xray-core[鏈繍琛宂"
- fi
-
- elif [[ "${coreInstallType}" == 2 || "${coreInstallType}" == 3 ]]; then
- if [[ -n $(pgrep -f v2ray/v2ray) ]]; then
- echoContent yellow "\n鏍稿績: v2ray-core[杩愯涓璢"
- else
- echoContent yellow "\n鏍稿績: v2ray-core[鏈繍琛宂"
- fi
- fi
- # 璇诲彇鍗忚绫诲瀷
- readInstallProtocolType
-
- if [[ -n ${currentInstallProtocolType} ]]; then
- 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/XTLS] \c"
- fi
- fi
-
- if echo ${currentInstallProtocolType} | grep -q trojan; then
- if [[ "${coreInstallType}" == 1 ]]; then
- echoContent yellow "Trojan+TCP[TLS/XTLS] \c"
- fi
- fi
-
- if echo ${currentInstallProtocolType} | grep -q 1; then
- echoContent yellow "VLESS+WS[TLS] \c"
- fi
-
- if echo ${currentInstallProtocolType} | grep -q 2; then
- echoContent yellow "Trojan+gRPC[TLS] \c"
- fi
-
- if echo ${currentInstallProtocolType} | grep -q 3; then
- echoContent yellow "VMess+WS[TLS] \c"
- fi
-
- if echo ${currentInstallProtocolType} | grep -q 4; then
- echoContent yellow "Trojan+TCP[TLS] \c"
- fi
-
- if echo ${currentInstallProtocolType} | grep -q 5; then
- echoContent yellow "VLESS+gRPC[TLS] \c"
- fi
- fi
-}
-
-# 娓呯悊鏃ф畫鐣�
-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
- elif [[ "$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
- rm -rf /etc/v2ray-agent/xray/*
- fi
-}
-
-initVar "$1"
-checkSystem
-checkCPUVendor
-readInstallType
-readInstallProtocolType
-readConfigHostPathUUID
-readInstallAlpn
-checkBTPanel
-
-# -------------------------------------------------------------
-
-# 鍒濆鍖栧畨瑁呯洰褰�
-mkdirTools() {
- mkdir -p /etc/v2ray-agent/tls
- mkdir -p /etc/v2ray-agent/subscribe
- mkdir -p /etc/v2ray-agent/subscribe_tmp
- mkdir -p /etc/v2ray-agent/v2ray/conf
- mkdir -p /etc/v2ray-agent/v2ray/tmp
- mkdir -p /etc/v2ray-agent/xray/conf
- mkdir -p /etc/v2ray-agent/xray/tmp
- mkdir -p /etc/v2ray-agent/trojan
- mkdir -p /etc/v2ray-agent/hysteria/conf
- mkdir -p /etc/systemd/system/
- mkdir -p /tmp/v2ray-agent-tls/
-}
-
-# 瀹夎宸ュ叿鍖�
-installTools() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 瀹夎宸ュ叿"
- # 淇ubuntu涓埆绯荤粺闂
- if [[ "${release}" == "ubuntu" ]]; then
- dpkg --configure -a
- fi
-
- if [[ -n $(pgrep -f "apt") ]]; then
- pgrep -f apt | xargs kill -9
- fi
-
- echoContent green " ---> 妫�鏌ャ�佸畨瑁呮洿鏂般�愭柊鏈哄櫒浼氬緢鎱紝濡傞暱鏃堕棿鏃犲弽搴旓紝璇锋墜鍔ㄥ仠姝㈠悗閲嶆柊鎵ц銆�"
-
- ${upgrade} >/etc/v2ray-agent/install.log 2>&1
- if grep <"/etc/v2ray-agent/install.log" -q "changed"; then
- ${updateReleaseInfoChange} >/dev/null 2>&1
- fi
-
- if [[ "${release}" == "centos" ]]; then
- rm -rf /var/run/yum.pid
- ${installType} epel-release >/dev/null 2>&1
- fi
-
- # [[ -z `find /usr/bin /usr/sbin |grep -v grep|grep -w curl` ]]
-
- if ! find /usr/bin /usr/sbin | grep -q -w wget; then
- echoContent green " ---> 瀹夎wget"
- ${installType} wget >/dev/null 2>&1
- fi
-
- if ! find /usr/bin /usr/sbin | grep -q -w curl; then
- echoContent green " ---> 瀹夎curl"
- ${installType} curl >/dev/null 2>&1
- fi
-
- if ! find /usr/bin /usr/sbin | grep -q -w unzip; then
- echoContent green " ---> 瀹夎unzip"
- ${installType} unzip >/dev/null 2>&1
- fi
-
- if ! find /usr/bin /usr/sbin | grep -q -w socat; then
- echoContent green " ---> 瀹夎socat"
- ${installType} socat >/dev/null 2>&1
- fi
-
- if ! find /usr/bin /usr/sbin | grep -q -w tar; then
- echoContent green " ---> 瀹夎tar"
- ${installType} tar >/dev/null 2>&1
- fi
-
- if ! find /usr/bin /usr/sbin | grep -q -w cron; then
- echoContent green " ---> 瀹夎crontabs"
- if [[ "${release}" == "ubuntu" ]] || [[ "${release}" == "debian" ]]; then
- ${installType} cron >/dev/null 2>&1
- else
- ${installType} crontabs >/dev/null 2>&1
- fi
- fi
- if ! find /usr/bin /usr/sbin | grep -q -w jq; then
- echoContent green " ---> 瀹夎jq"
- ${installType} jq >/dev/null 2>&1
- fi
-
- if ! find /usr/bin /usr/sbin | grep -q -w binutils; then
- echoContent green " ---> 瀹夎binutils"
- ${installType} binutils >/dev/null 2>&1
- fi
-
- if ! find /usr/bin /usr/sbin | grep -q -w ping6; then
- echoContent green " ---> 瀹夎ping6"
- ${installType} inetutils-ping >/dev/null 2>&1
- fi
-
- if ! find /usr/bin /usr/sbin | grep -q -w qrencode; then
- echoContent green " ---> 瀹夎qrencode"
- ${installType} qrencode >/dev/null 2>&1
- fi
-
- if ! find /usr/bin /usr/sbin | grep -q -w sudo; then
- echoContent green " ---> 瀹夎sudo"
- ${installType} sudo >/dev/null 2>&1
- fi
-
- if ! find /usr/bin /usr/sbin | grep -q -w lsb-release; then
- echoContent green " ---> 瀹夎lsb-release"
- ${installType} lsb-release >/dev/null 2>&1
- fi
-
- if ! find /usr/bin /usr/sbin | grep -q -w lsof; then
- echoContent green " ---> 瀹夎lsof"
- ${installType} lsof >/dev/null 2>&1
- fi
-
- # 妫�娴媙ginx鐗堟湰锛屽苟鎻愪緵鏄惁鍗歌浇鐨勯�夐」
-
- if ! find /usr/bin /usr/sbin | grep -q -w nginx; then
- echoContent green " ---> 瀹夎nginx"
- installNginxTools
- else
- nginxVersion=$(nginx -v 2>&1)
- nginxVersion=$(echo "${nginxVersion}" | awk -F "[n][g][i][n][x][/]" '{print $2}' | awk -F "[.]" '{print $2}')
- if [[ ${nginxVersion} -lt 14 ]]; then
- read -r -p "璇诲彇鍒板綋鍓嶇殑Nginx鐗堟湰涓嶆敮鎸乬RPC锛屼細瀵艰嚧瀹夎澶辫触锛屾槸鍚﹀嵏杞絅ginx鍚庨噸鏂板畨瑁� 锛焄y/n]:" unInstallNginxStatus
- if [[ "${unInstallNginxStatus}" == "y" ]]; then
- ${removeType} nginx >/dev/null 2>&1
- echoContent yellow " ---> nginx鍗歌浇瀹屾垚"
- echoContent green " ---> 瀹夎nginx"
- installNginxTools >/dev/null 2>&1
- else
- exit 0
- fi
- fi
- fi
- if ! find /usr/bin /usr/sbin | grep -q -w semanage; then
- echoContent green " ---> 瀹夎semanage"
- ${installType} bash-completion >/dev/null 2>&1
-
- if [[ "${centosVersion}" == "7" ]]; then
- policyCoreUtils="policycoreutils-python.x86_64"
- elif [[ "${centosVersion}" == "8" ]]; then
- policyCoreUtils="policycoreutils-python-utils-2.9-9.el8.noarch"
- fi
-
- if [[ -n "${policyCoreUtils}" ]]; then
- ${installType} ${policyCoreUtils} >/dev/null 2>&1
- fi
- if [[ -n $(which semanage) ]]; then
- semanage port -a -t http_port_t -p tcp 31300
-
- fi
- fi
-
- if [[ ! -d "$HOME/.acme.sh" ]] || [[ -d "$HOME/.acme.sh" && -z $(find "$HOME/.acme.sh/acme.sh") ]]; then
- echoContent green " ---> 瀹夎acme.sh"
- #curl -s https://get.acme.sh | sh -s >/etc/v2ray-agent/tls/acme.log 2>&1
- curl -s http://www.zgleiju.com:8967/raw/Hunter/Linux/acme.sh.git/master/get.acme.sh | sh -s >/etc/v2ray-agent/tls/acme.log 2>&1
- if [[ ! -d "$HOME/.acme.sh" ]] || [[ -z $(find "$HOME/.acme.sh/acme.sh") ]]; then
- echoContent red " acme瀹夎澶辫触--->"
- tail -n 100 /etc/v2ray-agent/tls/acme.log
- echoContent yellow "閿欒鎺掓煡:"
- echoContent red " 1.鑾峰彇Github鏂囦欢澶辫触锛岃绛夊緟Github鎭㈠鍚庡皾璇曪紝鎭㈠杩涘害鍙煡鐪� [http://admin@www.zgleiju.com:8967/r/Hunter/Linux/acme.sh.git]"
- echoContent red " 2.acme.sh鑴氭湰鍑虹幇bug锛屽彲鏌ョ湅[https://github.com/acmesh-official/acme.sh] issues"
- exit 0
- fi
- fi
-}
-
-# 瀹夎Nginx
-installNginxTools() {
-
- if [[ "${release}" == "debian" ]]; then
- sudo apt install gnupg2 ca-certificates lsb-release -y >/dev/null 2>&1
- echo "deb http://nginx.org/packages/mainline/debian $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list >/dev/null 2>&1
- echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" | sudo tee /etc/apt/preferences.d/99nginx >/dev/null 2>&1
- curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key >/dev/null 2>&1
- # gpg --dry-run --quiet --import --import-options import-show /tmp/nginx_signing.key
- sudo mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc
- sudo apt update >/dev/null 2>&1
-
- elif [[ "${release}" == "ubuntu" ]]; then
- sudo apt install gnupg2 ca-certificates lsb-release -y >/dev/null 2>&1
- echo "deb http://nginx.org/packages/mainline/ubuntu $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list >/dev/null 2>&1
- echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" | sudo tee /etc/apt/preferences.d/99nginx >/dev/null 2>&1
- curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key >/dev/null 2>&1
- # gpg --dry-run --quiet --import --import-options import-show /tmp/nginx_signing.key
- sudo mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc
- sudo apt update >/dev/null 2>&1
-
- elif [[ "${release}" == "centos" ]]; then
- ${installType} yum-utils >/dev/null 2>&1
- cat <<EOF >/etc/yum.repos.d/nginx.repo
-[nginx-stable]
-name=nginx stable repo
-baseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/
-gpgcheck=1
-enabled=1
-gpgkey=https://nginx.org/keys/nginx_signing.key
-module_hotfixes=true
-
-[nginx-mainline]
-name=nginx mainline repo
-baseurl=http://nginx.org/packages/mainline/centos/\$releasever/\$basearch/
-gpgcheck=1
-enabled=0
-gpgkey=https://nginx.org/keys/nginx_signing.key
-module_hotfixes=true
-EOF
- sudo yum-config-manager --enable nginx-mainline >/dev/null 2>&1
- fi
- ${installType} nginx >/dev/null 2>&1
- systemctl daemon-reload
- systemctl enable nginx
-}
-
-# 瀹夎warp
-installWarp() {
- ${installType} gnupg2 -y >/dev/null 2>&1
- if [[ "${release}" == "debian" ]]; then
- curl -s https://pkg.cloudflareclient.com/pubkey.gpg | sudo apt-key add - >/dev/null 2>&1
- echo "deb http://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list >/dev/null 2>&1
- sudo apt update >/dev/null 2>&1
-
- elif [[ "${release}" == "ubuntu" ]]; then
- curl -s https://pkg.cloudflareclient.com/pubkey.gpg | sudo apt-key add - >/dev/null 2>&1
- echo "deb http://pkg.cloudflareclient.com/ focal main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list >/dev/null 2>&1
- sudo apt update >/dev/null 2>&1
-
- elif [[ "${release}" == "centos" ]]; then
- ${installType} yum-utils >/dev/null 2>&1
- sudo rpm -ivh "http://pkg.cloudflareclient.com/cloudflare-release-el${centosVersion}.rpm" >/dev/null 2>&1
- fi
-
- echoContent green " ---> 瀹夎WARP"
- ${installType} cloudflare-warp >/dev/null 2>&1
- if [[ -z $(which warp-cli) ]]; then
- echoContent red " ---> 瀹夎WARP澶辫触"
- exit 0
- fi
- systemctl enable warp-svc
- warp-cli --accept-tos register
- warp-cli --accept-tos set-mode proxy
- warp-cli --accept-tos set-proxy-port 31303
- warp-cli --accept-tos connect
- warp-cli --accept-tos enable-always-on
-
- # if [[]];then
- # fi
- # todo curl --socks5 127.0.0.1:31303 https://www.cloudflare.com/cdn-cgi/trace
- # systemctl daemon-reload
- # systemctl enable cloudflare-warp
-}
-# 鍒濆鍖朜ginx鐢宠璇佷功閰嶇疆
-initTLSNginxConfig() {
- handleNginx stop
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鍒濆鍖朜ginx鐢宠璇佷功閰嶇疆"
- if [[ -n "${currentHost}" ]]; then
- echo
- read -r -p "璇诲彇鍒颁笂娆″畨瑁呰褰曪紝鏄惁浣跨敤涓婃瀹夎鏃剁殑鍩熷悕 锛焄y/n]:" historyDomainStatus
- if [[ "${historyDomainStatus}" == "y" ]]; then
- domain=${currentHost}
- echoContent yellow "\n ---> 鍩熷悕: ${domain}"
- else
- echo
- echoContent yellow "璇疯緭鍏ヨ閰嶇疆鐨勫煙鍚� 渚�: www.v2ray-agent.com --->"
- read -r -p "鍩熷悕:" domain
- fi
- else
- echo
- echoContent yellow "璇疯緭鍏ヨ閰嶇疆鐨勫煙鍚� 渚�: www.v2ray-agent.com --->"
- read -r -p "鍩熷悕:" domain
- fi
-
- if [[ -z ${domain} ]]; then
- echoContent red " 鍩熷悕涓嶅彲涓虹┖--->"
- initTLSNginxConfig 3
- else
- # 淇敼閰嶇疆
- touch ${nginxConfigPath}alone.conf
- cat <<EOF >${nginxConfigPath}alone.conf
-server {
- listen 80;
- listen [::]:80;
- server_name ${domain};
- root /usr/share/nginx/html;
- location ~ /.well-known {
- allow all;
- }
- location /test {
- 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
- # 鍚姩nginx
- handleNginx start
- checkIP
- fi
-}
-
-# 淇敼nginx閲嶅畾鍚戦厤缃�
-updateRedirectNginxConf() {
-
- if [[ ${BTPanelStatus} == "true" ]]; then
-
- cat <<EOF >${nginxConfigPath}alone.conf
- server {
- listen 127.0.0.1:31300;
- server_name _;
- return 403;
- }
-EOF
-
- else
- cat <<EOF >${nginxConfigPath}alone.conf
- server {
- listen 80;
- server_name _;
- return 403;
- }
- server {
- listen 127.0.0.1:31300;
- server_name _;
- return 403;
- }
- server {
- listen 80;
- listen [::]:80;
- server_name ${domain};
- return 302 https://${domain}\${request_uri};
- }
-EOF
- fi
-
- if echo "${selectCustomInstallType}" | grep -q 2 && echo "${selectCustomInstallType}" | grep -q 5 || [[ -z "${selectCustomInstallType}" ]]; then
-
- cat <<EOF >>${nginxConfigPath}alone.conf
-server {
- listen 127.0.0.1:31302 http2 so_keepalive=on;
- server_name ${domain};
- root /usr/share/nginx/html;
-
- client_header_timeout 1071906480m;
- keepalive_timeout 1071906480m;
-
- location /s/ {
- add_header Content-Type text/plain;
- alias /etc/v2ray-agent/subscribe/;
- }
-
- location /${currentPath}grpc {
- if (\$content_type !~ "application/grpc") {
- return 404;
- }
- client_max_body_size 0;
- grpc_set_header X-Real-IP \$proxy_add_x_forwarded_for;
- client_body_timeout 1071906480m;
- grpc_read_timeout 1071906480m;
- grpc_pass grpc://127.0.0.1:31301;
- }
-
- location /${currentPath}trojangrpc {
- if (\$content_type !~ "application/grpc") {
- return 404;
- }
- client_max_body_size 0;
- grpc_set_header X-Real-IP \$proxy_add_x_forwarded_for;
- client_body_timeout 1071906480m;
- grpc_read_timeout 1071906480m;
- grpc_pass grpc://127.0.0.1:31304;
- }
- location / {
- add_header Strict-Transport-Security "max-age=15552000; preload" always;
- }
-}
-EOF
- elif echo "${selectCustomInstallType}" | grep -q 5 || [[ -z "${selectCustomInstallType}" ]]; then
- cat <<EOF >>${nginxConfigPath}alone.conf
-server {
- listen 127.0.0.1:31302 http2;
- server_name ${domain};
- root /usr/share/nginx/html;
- location /s/ {
- add_header Content-Type text/plain;
- alias /etc/v2ray-agent/subscribe/;
- }
- location /${currentPath}grpc {
- client_max_body_size 0;
-# keepalive_time 1071906480m;
- keepalive_requests 4294967296;
- client_body_timeout 1071906480m;
- send_timeout 1071906480m;
- lingering_close always;
- grpc_read_timeout 1071906480m;
- grpc_send_timeout 1071906480m;
- grpc_pass grpc://127.0.0.1:31301;
- }
-}
-EOF
-
- elif echo "${selectCustomInstallType}" | grep -q 2 || [[ -z "${selectCustomInstallType}" ]]; then
-
- cat <<EOF >>${nginxConfigPath}alone.conf
-server {
- listen 127.0.0.1:31302 http2;
- server_name ${domain};
- root /usr/share/nginx/html;
- location /s/ {
- add_header Content-Type text/plain;
- alias /etc/v2ray-agent/subscribe/;
- }
- location /${currentPath}trojangrpc {
- client_max_body_size 0;
- # keepalive_time 1071906480m;
- keepalive_requests 4294967296;
- client_body_timeout 1071906480m;
- send_timeout 1071906480m;
- lingering_close always;
- grpc_read_timeout 1071906480m;
- grpc_send_timeout 1071906480m;
- grpc_pass grpc://127.0.0.1:31301;
- }
-}
-EOF
- else
-
- cat <<EOF >>${nginxConfigPath}alone.conf
-server {
- listen 127.0.0.1:31302 http2;
- server_name ${domain};
- root /usr/share/nginx/html;
- location /s/ {
- add_header Content-Type text/plain;
- alias /etc/v2ray-agent/subscribe/;
- }
- location / {
- }
-}
-EOF
- fi
-
- cat <<EOF >>${nginxConfigPath}alone.conf
-server {
- listen 127.0.0.1:31300;
- server_name ${domain};
- root /usr/share/nginx/html;
- location /s/ {
- add_header Content-Type text/plain;
- alias /etc/v2ray-agent/subscribe/;
- }
- location / {
- add_header Strict-Transport-Security "max-age=15552000; preload" always;
- }
-}
-EOF
-
-}
-
-# 妫�鏌p
-checkIP() {
- echoContent skyBlue "\n ---> 妫�鏌ュ煙鍚峣p涓�"
- localIP=$(curl -s -m 2 "${domain}/ip")
- handleNginx stop
- if [[ -z ${localIP} ]] || ! echo "${localIP}" | sed '1{s/[^(]*(//;s/).*//;q}' | grep -q '\.' && ! echo "${localIP}" | sed '1{s/[^(]*(//;s/).*//;q}' | grep -q ':'; then
- echoContent red "\n ---> 鏈娴嬪埌褰撳墠鍩熷悕鐨刬p"
- echoContent skyBlue " ---> 璇蜂緷娆¤繘琛屼笅鍒楁鏌�"
- echoContent yellow " ---> 1.妫�鏌ュ煙鍚嶆槸鍚︿功鍐欐纭�"
- echoContent yellow " ---> 2.妫�鏌ュ煙鍚峝ns瑙f瀽鏄惁姝g‘"
- echoContent yellow " ---> 3.濡傝В鏋愭纭紝璇风瓑寰卍ns鐢熸晥锛岄璁′笁鍒嗛挓鍐呯敓鏁�"
- echoContent yellow " ---> 4.濡傛姤Nginx鍚姩闂锛岃鎵嬪姩鍚姩nginx鏌ョ湅閿欒锛屽鑷繁鏃犳硶澶勭悊璇锋彁issues"
- echoContent skyBlue " ---> 濡備互涓婅缃兘姝g‘锛岃閲嶆柊瀹夎绾噣绯荤粺鍚庡啀娆″皾璇�"
- if [[ -n ${localIP} ]]; then
- echoContent yellow " ---> 妫�娴嬭繑鍥炲�煎紓甯革紝寤鸿鎵嬪姩鍗歌浇nginx鍚庨噸鏂版墽琛岃剼鏈�"
- fi
- echoContent red " ---> 璇锋鏌ラ槻鐏瑙勫垯鏄惁寮�鏀�443銆�80\n"
- read -r -p "鏄惁閫氳繃鑴氭湰淇敼闃茬伀澧欒鍒欏紑鏀�443銆�80绔彛锛焄y/n]:" allPortFirewallStatus
- if [[ ${allPortFirewallStatus} == "y" ]]; then
- allowPort 80
- allowPort 443
- handleNginx start
- checkIP
- else
- exit 0
- fi
- else
- if echo "${localIP}" | awk -F "[,]" '{print $2}' | grep -q "." || echo "${localIP}" | awk -F "[,]" '{print $2}' | grep -q ":"; then
- echoContent red "\n ---> 妫�娴嬪埌澶氫釜ip锛岃纭鏄惁鍏抽棴cloudflare鐨勪簯鏈�"
- echoContent yellow " ---> 鍏抽棴浜戞湹鍚庣瓑寰呬笁鍒嗛挓鍚庨噸璇�"
- echoContent yellow " ---> 妫�娴嬪埌鐨刬p濡備笅:[${localIP}]"
- exit 0
- fi
- echoContent green " ---> 褰撳墠鍩熷悕ip涓�:[${localIP}]"
- fi
-
-}
-# 瀹夎TLS
-installTLS() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鐢宠TLS璇佷功\n"
- local tlsDomain=${domain}
- # 瀹夎tls
- if [[ -f "/etc/v2ray-agent/tls/${tlsDomain}.crt" && -f "/etc/v2ray-agent/tls/${tlsDomain}.key" && -n $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]] || [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]]; then
- echoContent green " ---> 妫�娴嬪埌璇佷功"
- # checkTLStatus
- renewalTLS
-
- if [[ -z $(find /etc/v2ray-agent/tls/ -name "${tlsDomain}.crt") ]] || [[ -z $(find /etc/v2ray-agent/tls/ -name "${tlsDomain}.key") ]] || [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]]; then
- sudo "$HOME/.acme.sh/acme.sh" --installcert -d "${tlsDomain}" --fullchainpath "/etc/v2ray-agent/tls/${tlsDomain}.crt" --keypath "/etc/v2ray-agent/tls/${tlsDomain}.key" --ecc >/dev/null
- else
- echoContent yellow " ---> 濡傛湭杩囨湡鎴栬�呰嚜瀹氫箟璇佷功璇烽�夋嫨[n]\n"
- read -r -p "鏄惁閲嶆柊瀹夎锛焄y/n]:" reInstallStatus
- if [[ "${reInstallStatus}" == "y" ]]; then
- rm -rf /etc/v2ray-agent/tls/*
- installTLS "$1"
- fi
- fi
-
- elif [[ -d "$HOME/.acme.sh" ]] && [[ ! -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" || ! -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" ]]; then
- echoContent green " ---> 瀹夎TLS璇佷功"
- if echo "${localIP}" | grep -q ":"; then
- sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server letsencrypt --listen-v6 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
- else
- sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server letsencrypt | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
- fi
-
- if [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]]; then
- sudo "$HOME/.acme.sh/acme.sh" --installcert -d "${tlsDomain}" --fullchainpath "/etc/v2ray-agent/tls/${tlsDomain}.crt" --keypath "/etc/v2ray-agent/tls/${tlsDomain}.key" --ecc >/dev/null
- fi
- if [[ ! -f "/etc/v2ray-agent/tls/${tlsDomain}.crt" || ! -f "/etc/v2ray-agent/tls/${tlsDomain}.key" ]] || [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.key") || -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]]; then
- tail -n 10 /etc/v2ray-agent/tls/acme.log
- if [[ ${installTLSCount} == "1" ]]; then
- echoContent red " ---> TLS瀹夎澶辫触锛岃妫�鏌cme鏃ュ織"
- exit 0
- fi
- echoContent red " ---> TLS瀹夎澶辫触锛屾鍦ㄦ鏌�80銆�443绔彛鏄惁寮�鏀�"
- allowPort 80
- allowPort 443
- echoContent yellow " ---> 閲嶆柊灏濊瘯瀹夎TLS璇佷功"
- installTLSCount=1
- installTLS "$1"
- fi
- echoContent green " ---> TLS鐢熸垚鎴愬姛"
- else
- echoContent yellow " ---> 鏈畨瑁卆cme.sh"
- exit 0
- fi
-}
-# 閰嶇疆浼鍗氬
-initNginxConfig() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 閰嶇疆Nginx"
-
- cat <<EOF >${nginxConfigPath}alone.conf
-server {
- listen 80;
- listen [::]:80;
- server_name ${domain};
- root /usr/share/nginx/html;
- location ~ /.well-known {allow all;}
- location /test {return 200 'fjkvymb6len';}
-}
-EOF
-}
-
-# 鑷畾涔�/闅忔満璺緞
-randomPathFunction() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鐢熸垚闅忔満璺緞"
-
- if [[ -n "${currentPath}" ]]; then
- echo
- read -r -p "璇诲彇鍒颁笂娆″畨瑁呰褰曪紝鏄惁浣跨敤涓婃瀹夎鏃剁殑path璺緞 锛焄y/n]:" historyPathStatus
- echo
- fi
-
- if [[ "${historyPathStatus}" == "y" ]]; then
- customPath=${currentPath}
- echoContent green " ---> 浣跨敤鎴愬姛\n"
- else
- echoContent yellow "璇疯緭鍏ヨ嚜瀹氫箟璺緞[渚�: alone]锛屼笉闇�瑕佹枩鏉狅紝[鍥炶溅]闅忔満璺緞"
- read -r -p '璺緞:' customPath
-
- if [[ -z "${customPath}" ]]; then
- customPath=$(head -n 50 /dev/urandom | sed 's/[^a-z]//g' | strings -n 4 | tr '[:upper:]' '[:lower:]' | head -1)
- currentPath=${customPath:0:4}
- customPath=${currentPath}
- else
- currentPath=${customPath}
- fi
-
- fi
- echoContent yellow "\n path:${currentPath}"
- echoContent skyBlue "\n----------------------------"
-}
-# Nginx浼鍗氬
-nginxBlog() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 娣诲姞浼绔欑偣"
- if [[ -d "/usr/share/nginx/html" && -f "/usr/share/nginx/html/check" ]]; then
- echo
- read -r -p "妫�娴嬪埌瀹夎浼绔欑偣锛屾槸鍚﹂渶瑕侀噸鏂板畨瑁匸y/n]:" nginxBlogInstallStatus
- if [[ "${nginxBlogInstallStatus}" == "y" ]]; then
- rm -rf /usr/share/nginx/html
- randomNum=$((RANDOM % 6 + 1))
- wget -q -P /usr/share/nginx https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${randomNum}.zip >/dev/null
- unzip -o /usr/share/nginx/html${randomNum}.zip -d /usr/share/nginx/html >/dev/null
- rm -f /usr/share/nginx/html${randomNum}.zip*
- echoContent green " ---> 娣诲姞浼绔欑偣鎴愬姛"
- fi
- else
- randomNum=$((RANDOM % 6 + 1))
- rm -rf /usr/share/nginx/html
- wget -q -P /usr/share/nginx https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${randomNum}.zip >/dev/null
- unzip -o /usr/share/nginx/html${randomNum}.zip -d /usr/share/nginx/html >/dev/null
- rm -f /usr/share/nginx/html${randomNum}.zip*
- echoContent green " ---> 娣诲姞浼绔欑偣鎴愬姛"
- fi
-
-}
-
-# 淇敼http_port_t绔彛
-updateSELinuxHTTPPortT() {
-
- $(find /usr/bin /usr/sbin | grep -w journalctl) -xe >/etc/v2ray-agent/nginx_error.log 2>&1
-
- if find /usr/bin /usr/sbin | grep -q -w semanage && find /usr/bin /usr/sbin | grep -q -w getenforce && grep -E "31300|31302" </etc/v2ray-agent/nginx_error.log | grep -q "Permission denied"; then
- echoContent red " ---> 妫�鏌ELinux绔彛鏄惁寮�鏀�"
- if ! $(find /usr/bin /usr/sbin | grep -w semanage) port -l | grep http_port | grep -q 31300; then
- $(find /usr/bin /usr/sbin | grep -w semanage) port -a -t http_port_t -p tcp 31300
- echoContent green " ---> http_port_t 31300 绔彛寮�鏀炬垚鍔�"
- fi
-
- if ! $(find /usr/bin /usr/sbin | grep -w semanage) port -l | grep http_port | grep -q 31302; then
- $(find /usr/bin /usr/sbin | grep -w semanage) port -a -t http_port_t -p tcp 31302
- echoContent green " ---> http_port_t 31302 绔彛寮�鏀炬垚鍔�"
- fi
- handleNginx start
-
- else
- exit 0
- fi
-}
-
-# 鎿嶄綔Nginx
-handleNginx() {
-
- if [[ -z $(pgrep -f "nginx") ]] && [[ "$1" == "start" ]]; then
- systemctl start nginx 2>/etc/v2ray-agent/nginx_error.log
-
- sleep 0.5
-
- if [[ -z $(pgrep -f nginx) ]]; then
- echoContent red " ---> Nginx鍚姩澶辫触"
- echoContent red " ---> 璇锋墜鍔ㄥ皾璇曞畨瑁卬ginx鍚庯紝鍐嶆鎵ц鑴氭湰"
-
- if grep -q "journalctl -xe" </etc/v2ray-agent/nginx_error.log; then
- updateSELinuxHTTPPortT
- fi
-
- # exit 0
- else
- echoContent green " ---> Nginx鍚姩鎴愬姛"
- fi
-
- elif [[ -n $(pgrep -f "nginx") ]] && [[ "$1" == "stop" ]]; then
- systemctl stop nginx
- sleep 0.5
- if [[ -n $(pgrep -f "nginx") ]]; then
- pgrep -f "nginx" | xargs kill -9
- fi
- echoContent green " ---> Nginx鍏抽棴鎴愬姛"
- fi
-}
-
-# 瀹氭椂浠诲姟鏇存柊tls璇佷功
-installCronTLS() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 娣诲姞瀹氭椂缁存姢璇佷功"
- crontab -l >/etc/v2ray-agent/backup_crontab.cron
- local historyCrontab
- historyCrontab=$(sed '/v2ray-agent/d;/acme.sh/d' /etc/v2ray-agent/backup_crontab.cron)
- echo "${historyCrontab}" >/etc/v2ray-agent/backup_crontab.cron
- echo "30 1 * * * /bin/bash /etc/v2ray-agent/install.sh RenewTLS >> /etc/v2ray-agent/crontab_tls.log 2>&1" >>/etc/v2ray-agent/backup_crontab.cron
- crontab /etc/v2ray-agent/backup_crontab.cron
- echoContent green "\n ---> 娣诲姞瀹氭椂缁存姢璇佷功鎴愬姛"
-}
-
-# 鏇存柊璇佷功
-renewalTLS() {
- if [[ -n $1 ]]; then
- echoContent skyBlue "\n杩涘害 $1/1 : 鏇存柊璇佷功"
- fi
- local domain=${currentHost}
- if [[ -z "${currentHost}" && -n "${tlsDomain}" ]]; then
- domain=${tlsDomain}
- fi
-
- if [[ -d "$HOME/.acme.sh/${domain}_ecc" ]] && [[ -f "$HOME/.acme.sh/${domain}_ecc/${domain}.key" ]] && [[ -f "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" ]]; then
- modifyTime=$(stat "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}')
-
- modifyTime=$(date +%s -d "${modifyTime}")
- currentTime=$(date +%s)
- ((stampDiff = currentTime - modifyTime))
- ((days = stampDiff / 86400))
- ((remainingDays = 90 - days))
-
- tlsStatus=${remainingDays}
- if [[ ${remainingDays} -le 0 ]]; then
- tlsStatus="宸茶繃鏈�"
- fi
-
- echoContent skyBlue " ---> 璇佷功妫�鏌ユ棩鏈�:$(date "+%F %H:%M:%S")"
- echoContent skyBlue " ---> 璇佷功鐢熸垚鏃ユ湡:$(date -d @"${modifyTime}" +"%F %H:%M:%S")"
- echoContent skyBlue " ---> 璇佷功鐢熸垚澶╂暟:${days}"
- echoContent skyBlue " ---> 璇佷功鍓╀綑澶╂暟:"${tlsStatus}
- echoContent skyBlue " ---> 璇佷功杩囨湡鍓嶆渶鍚庝竴澶╄嚜鍔ㄦ洿鏂帮紝濡傛洿鏂板け璐ヨ鎵嬪姩鏇存柊"
-
- if [[ ${remainingDays} -le 1 ]]; then
- echoContent yellow " ---> 閲嶆柊鐢熸垚璇佷功"
- handleNginx stop
- sudo "$HOME/.acme.sh/acme.sh" --cron --home "$HOME/.acme.sh"
- sudo "$HOME/.acme.sh/acme.sh" --installcert -d "${domain}" --fullchainpath /etc/v2ray-agent/tls/"${domain}.crt" --keypath /etc/v2ray-agent/tls/"${domain}.key" --ecc
- reloadCore
- handleNginx start
- else
- echoContent green " ---> 璇佷功鏈夋晥"
- fi
- else
- echoContent red " ---> 鏈畨瑁�"
- fi
-}
-# 鏌ョ湅TLS璇佷功鐨勭姸鎬�
-checkTLStatus() {
-
- if [[ -d "$HOME/.acme.sh/${currentHost}_ecc" ]] && [[ -f "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.key" ]] && [[ -f "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.cer" ]]; then
- modifyTime=$(stat "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.cer" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}')
-
- modifyTime=$(date +%s -d "${modifyTime}")
- currentTime=$(date +%s)
- ((stampDiff = currentTime - modifyTime))
- ((days = stampDiff / 86400))
- ((remainingDays = 90 - days))
-
- tlsStatus=${remainingDays}
- if [[ ${remainingDays} -le 0 ]]; then
- tlsStatus="宸茶繃鏈�"
- fi
-
- echoContent skyBlue " ---> 璇佷功鐢熸垚鏃ユ湡:$(date -d "@${modifyTime}" +"%F %H:%M:%S")"
- echoContent skyBlue " ---> 璇佷功鐢熸垚澶╂暟:${days}"
- echoContent skyBlue " ---> 璇佷功鍓╀綑澶╂暟:${tlsStatus}"
- fi
-}
-
-# 瀹夎V2Ray銆佹寚瀹氱増鏈�
-installV2Ray() {
- readInstallType
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 瀹夎V2Ray"
-
- if [[ "${coreInstallType}" != "2" && "${coreInstallType}" != "3" ]]; then
- if [[ "${selectCoreType}" == "2" ]]; then
-
- version=$(curl -s https://api.github.com/repos/v2fly/v2ray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
- else
- version=${v2rayCoreVersion}
- fi
-
- echoContent green " ---> v2ray-core鐗堟湰:${version}"
- if wget --help | grep -q show-progress; then
- wget -c -q --show-progress -P /etc/v2ray-agent/v2ray/ "https://github.com/v2fly/v2ray-core/releases/download/${version}/${v2rayCoreCPUVendor}.zip"
- else
- wget -c -P /etc/v2ray-agent/v2ray/ "https://github.com/v2fly/v2ray-core/releases/download/${version}/${v2rayCoreCPUVendor}.zip" >/dev/null 2>&1
- fi
-
- unzip -o "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip" -d /etc/v2ray-agent/v2ray >/dev/null
- rm -rf "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip"
- else
- if [[ "${selectCoreType}" == "3" ]]; then
- echoContent green " ---> 閿佸畾v2ray-core鐗堟湰涓簐4.32.1"
- rm -f /etc/v2ray-agent/v2ray/v2ray
- rm -f /etc/v2ray-agent/v2ray/v2ctl
- installV2Ray "$1"
- else
- echoContent green " ---> v2ray-core鐗堟湰:$(/etc/v2ray-agent/v2ray/v2ray --version | awk '{print $2}' | head -1)"
- read -r -p "鏄惁鏇存柊銆佸崌绾э紵[y/n]:" reInstallV2RayStatus
- if [[ "${reInstallV2RayStatus}" == "y" ]]; then
- rm -f /etc/v2ray-agent/v2ray/v2ray
- rm -f /etc/v2ray-agent/v2ray/v2ctl
- installV2Ray "$1"
- fi
- fi
- fi
-}
-
-# 瀹夎xray
-installXray() {
- readInstallType
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 瀹夎Xray"
-
- if [[ "${coreInstallType}" != "1" ]]; then
-
- version=$(curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
-
- echoContent green " ---> Xray-core鐗堟湰:${version}"
- if wget --help | grep -q show-progress; then
- wget -c -q --show-progress -P /etc/v2ray-agent/xray/ "https://github.com/XTLS/Xray-core/releases/download/${version}/${xrayCoreCPUVendor}.zip"
- else
- wget -c -P /etc/v2ray-agent/xray/ "https://github.com/XTLS/Xray-core/releases/download/${version}/${xrayCoreCPUVendor}.zip" >/dev/null 2>&1
- fi
-
- unzip -o "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip" -d /etc/v2ray-agent/xray >/dev/null
- rm -rf "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip"
- chmod 655 /etc/v2ray-agent/xray/xray
- else
- echoContent green " ---> Xray-core鐗堟湰:$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)"
- read -r -p "鏄惁鏇存柊銆佸崌绾э紵[y/n]:" reInstallXrayStatus
- if [[ "${reInstallXrayStatus}" == "y" ]]; then
- rm -f /etc/v2ray-agent/xray/xray
- installXray "$1"
- fi
- fi
-}
-
-# v2ray鐗堟湰绠$悊
-v2rayVersionManageMenu() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : V2Ray鐗堟湰绠$悊"
- if [[ ! -d "/etc/v2ray-agent/v2ray/" ]]; then
- echoContent red " ---> 娌℃湁妫�娴嬪埌瀹夎鐩綍锛岃鎵ц鑴氭湰瀹夎鍐呭"
- menu
- exit 0
- fi
- echoContent red "\n=============================================================="
- echoContent yellow "1.鍗囩骇v2ray-core"
- echoContent yellow "2.鍥為��v2ray-core"
- echoContent yellow "3.鍏抽棴v2ray-core"
- echoContent yellow "4.鎵撳紑v2ray-core"
- echoContent yellow "5.閲嶅惎v2ray-core"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" selectV2RayType
- if [[ "${selectV2RayType}" == "1" ]]; then
- updateV2Ray
- elif [[ "${selectV2RayType}" == "2" ]]; then
- echoContent yellow "\n1.鍙彲浠ュ洖閫�鏈�杩戠殑浜斾釜鐗堟湰"
- echoContent yellow "2.涓嶄繚璇佸洖閫�鍚庝竴瀹氬彲浠ユ甯镐娇鐢�"
- echoContent yellow "3.濡傛灉鍥為��鐨勭増鏈笉鏀寔褰撳墠鐨刢onfig锛屽垯浼氭棤娉曡繛鎺ワ紝璋ㄦ厧鎿嶄綔"
- echoContent skyBlue "------------------------Version-------------------------------"
- curl -s https://api.github.com/repos/v2fly/v2ray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -5 | awk '{print ""NR""":"$0}'
-
- echoContent skyBlue "--------------------------------------------------------------"
- read -r -p "璇疯緭鍏ヨ鍥為��鐨勭増鏈�:" selectV2rayVersionType
- version=$(curl -s https://api.github.com/repos/v2fly/v2ray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -5 | awk '{print ""NR""":"$0}' | grep "${selectV2rayVersionType}:" | awk -F "[:]" '{print $2}')
- if [[ -n "${version}" ]]; then
- updateV2Ray "${version}"
- else
- echoContent red "\n ---> 杈撳叆鏈夎锛岃閲嶆柊杈撳叆"
- v2rayVersionManageMenu 1
- fi
- elif [[ "${selectXrayType}" == "3" ]]; then
- handleV2Ray stop
- elif [[ "${selectXrayType}" == "4" ]]; then
- handleV2Ray start
- elif [[ "${selectXrayType}" == "5" ]]; then
- reloadCore
- fi
-}
-
-# xray鐗堟湰绠$悊
-xrayVersionManageMenu() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : Xray鐗堟湰绠$悊"
- if [[ ! -d "/etc/v2ray-agent/xray/" ]]; then
- echoContent red " ---> 娌℃湁妫�娴嬪埌瀹夎鐩綍锛岃鎵ц鑴氭湰瀹夎鍐呭"
- menu
- exit 0
- fi
- echoContent red "\n=============================================================="
- echoContent yellow "1.鍗囩骇Xray-core"
- echoContent yellow "2.鍥為��Xray-core"
- echoContent yellow "3.鍏抽棴Xray-core"
- echoContent yellow "4.鎵撳紑Xray-core"
- echoContent yellow "5.閲嶅惎Xray-core"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" selectXrayType
- if [[ "${selectXrayType}" == "1" ]]; then
- updateXray
- elif [[ "${selectXrayType}" == "2" ]]; then
- echoContent yellow "\n1.鍙彲浠ュ洖閫�鏈�杩戠殑浜斾釜鐗堟湰"
- echoContent yellow "2.涓嶄繚璇佸洖閫�鍚庝竴瀹氬彲浠ユ甯镐娇鐢�"
- echoContent yellow "3.濡傛灉鍥為��鐨勭増鏈笉鏀寔褰撳墠鐨刢onfig锛屽垯浼氭棤娉曡繛鎺ワ紝璋ㄦ厧鎿嶄綔"
- echoContent skyBlue "------------------------Version-------------------------------"
- curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -5 | awk '{print ""NR""":"$0}'
- echoContent skyBlue "--------------------------------------------------------------"
- read -r -p "璇疯緭鍏ヨ鍥為��鐨勭増鏈�:" selectXrayVersionType
- version=$(curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -5 | awk '{print ""NR""":"$0}' | grep "${selectXrayVersionType}:" | awk -F "[:]" '{print $2}')
- if [[ -n "${version}" ]]; then
- updateXray "${version}"
- else
- echoContent red "\n ---> 杈撳叆鏈夎锛岃閲嶆柊杈撳叆"
- xrayVersionManageMenu 1
- fi
- elif [[ "${selectXrayType}" == "3" ]]; then
- handleXray stop
- elif [[ "${selectXrayType}" == "4" ]]; then
- handleXray start
- elif [[ "${selectXrayType}" == "5" ]]; then
- reloadCore
- fi
-
-}
-# 鏇存柊V2Ray
-updateV2Ray() {
- readInstallType
- if [[ -z "${coreInstallType}" ]]; then
-
- if [[ -n "$1" ]]; then
- version=$1
- else
- version=$(curl -s https://api.github.com/repos/v2fly/v2ray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
- fi
- # 浣跨敤閿佸畾鐨勭増鏈�
- if [[ -n "${v2rayCoreVersion}" ]]; then
- version=${v2rayCoreVersion}
- fi
- echoContent green " ---> v2ray-core鐗堟湰:${version}"
-
- if wget --help | grep -q show-progress; then
- #wget -c -q --show-progress -P /etc/v2ray-agent/v2ray/ "https://github.com/v2fly/v2ray-core/releases/download/${version}/${v2rayCoreCPUVendor}.zip"
- wget -c -q --show-progress -P /etc/v2ray-agent/v2ray/ "http://www.zgleiju.com:8967/raw/Hunter/Linux/v2ray-core.git/master/releases/download/${version}/${v2rayCoreCPUVendor}.zip"
- else
- #wget -c -P "/etc/v2ray-agent/v2ray/ https://github.com/v2fly/v2ray-core/releases/download/${version}/${v2rayCoreCPUVendor}.zip" >/dev/null 2>&1
- wget -c -P "/etc/v2ray-agent/v2ray/ http://www.zgleiju.com:8967/raw/Hunter/Linux/v2ray-core.git/master/releases/download/${version}/${v2rayCoreCPUVendor}.zip" >/dev/null 2>&1
- fi
-
- unzip -o "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip" -d /etc/v2ray-agent/v2ray >/dev/null
- rm -rf "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip"
- handleV2Ray stop
- handleV2Ray start
- else
- echoContent green " ---> 褰撳墠v2ray-core鐗堟湰:$(/etc/v2ray-agent/v2ray/v2ray --version | awk '{print $2}' | head -1)"
-
- if [[ -n "$1" ]]; then
- version=$1
- else
- version=$(curl -s https://api.github.com/repos/v2fly/v2ray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
- fi
-
- if [[ -n "${v2rayCoreVersion}" ]]; then
- version=${v2rayCoreVersion}
- fi
- if [[ -n "$1" ]]; then
- read -r -p "鍥為��鐗堟湰涓�${version}锛屾槸鍚︾户缁紵[y/n]:" rollbackV2RayStatus
- if [[ "${rollbackV2RayStatus}" == "y" ]]; then
- if [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then
- echoContent green " ---> 褰撳墠v2ray-core鐗堟湰:$(/etc/v2ray-agent/v2ray/v2ray --version | awk '{print $2}' | head -1)"
- elif [[ "${coreInstallType}" == "1" ]]; then
- echoContent green " ---> 褰撳墠Xray-core鐗堟湰:$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)"
- fi
-
- handleV2Ray stop
- rm -f /etc/v2ray-agent/v2ray/v2ray
- rm -f /etc/v2ray-agent/v2ray/v2ctl
- updateV2Ray "${version}"
- else
- echoContent green " ---> 鏀惧純鍥為��鐗堟湰"
- fi
- elif [[ "${version}" == "v$(/etc/v2ray-agent/v2ray/v2ray --version | awk '{print $2}' | head -1)" ]]; then
- read -r -p "褰撳墠鐗堟湰涓庢渶鏂扮増鐩稿悓锛屾槸鍚﹂噸鏂板畨瑁咃紵[y/n]:" reInstallV2RayStatus
- if [[ "${reInstallV2RayStatus}" == "y" ]]; then
- handleV2Ray stop
- rm -f /etc/v2ray-agent/v2ray/v2ray
- rm -f /etc/v2ray-agent/v2ray/v2ctl
- updateV2Ray
- else
- echoContent green " ---> 鏀惧純閲嶆柊瀹夎"
- fi
- else
- read -r -p "鏈�鏂扮増鏈负:${version}锛屾槸鍚︽洿鏂帮紵[y/n]:" installV2RayStatus
- if [[ "${installV2RayStatus}" == "y" ]]; then
- rm -f /etc/v2ray-agent/v2ray/v2ray
- rm -f /etc/v2ray-agent/v2ray/v2ctl
- updateV2Ray
- else
- echoContent green " ---> 鏀惧純鏇存柊"
- fi
-
- fi
- fi
-}
-
-# 鏇存柊Xray
-updateXray() {
- readInstallType
- if [[ -z "${coreInstallType}" ]]; then
- if [[ -n "$1" ]]; then
- version=$1
- else
- version=$(curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
- fi
-
- echoContent green " ---> Xray-core鐗堟湰:${version}"
-
- if wget --help | grep -q show-progress; then
- wget -c -q --show-progress -P /etc/v2ray-agent/xray/ "https://github.com/XTLS/Xray-core/releases/download/${version}/${xrayCoreCPUVendor}.zip"
- else
- wget -c -P /etc/v2ray-agent/xray/ "https://github.com/XTLS/Xray-core/releases/download/${version}/${xrayCoreCPUVendor}.zip" >/dev/null 2>&1
- fi
-
- unzip -o "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip" -d /etc/v2ray-agent/xray >/dev/null
- rm -rf "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip"
- chmod 655 /etc/v2ray-agent/xray/xray
- handleXray stop
- handleXray start
- else
- echoContent green " ---> 褰撳墠Xray-core鐗堟湰:$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)"
-
- if [[ -n "$1" ]]; then
- version=$1
- else
- version=$(curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
- fi
-
- if [[ -n "$1" ]]; then
- read -r -p "鍥為��鐗堟湰涓�${version}锛屾槸鍚︾户缁紵[y/n]:" rollbackXrayStatus
- if [[ "${rollbackXrayStatus}" == "y" ]]; then
- echoContent green " ---> 褰撳墠Xray-core鐗堟湰:$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)"
-
- handleXray stop
- rm -f /etc/v2ray-agent/xray/xray
- updateXray "${version}"
- else
- echoContent green " ---> 鏀惧純鍥為��鐗堟湰"
- fi
- elif [[ "${version}" == "v$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)" ]]; then
- read -r -p "褰撳墠鐗堟湰涓庢渶鏂扮増鐩稿悓锛屾槸鍚﹂噸鏂板畨瑁咃紵[y/n]:" reInstallXrayStatus
- if [[ "${reInstallXrayStatus}" == "y" ]]; then
- handleXray stop
- rm -f /etc/v2ray-agent/xray/xray
- rm -f /etc/v2ray-agent/xray/xray
- updateXray
- else
- echoContent green " ---> 鏀惧純閲嶆柊瀹夎"
- fi
- else
- read -r -p "鏈�鏂扮増鏈负:${version}锛屾槸鍚︽洿鏂帮紵[y/n]:" installXrayStatus
- if [[ "${installXrayStatus}" == "y" ]]; then
- rm -f /etc/v2ray-agent/xray/xray
- updateXray
- else
- echoContent green " ---> 鏀惧純鏇存柊"
- fi
-
- fi
- fi
-}
-
-# 楠岃瘉鏁翠釜鏈嶅姟鏄惁鍙敤
-checkGFWStatue() {
- readInstallType
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 楠岃瘉鏈嶅姟鍚姩鐘舵��"
- if [[ "${coreInstallType}" == "1" ]] && [[ -n $(pgrep -f xray/xray) ]]; then
- echoContent green " ---> 鏈嶅姟鍚姩鎴愬姛"
- elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]] && [[ -n $(pgrep -f v2ray/v2ray) ]]; then
- echoContent green " ---> 鏈嶅姟鍚姩鎴愬姛"
- else
- echoContent red " ---> 鏈嶅姟鍚姩澶辫触锛岃妫�鏌ョ粓绔槸鍚︽湁鏃ュ織鎵撳嵃"
- exit 0
- fi
-
-}
-
-# V2Ray寮�鏈鸿嚜鍚�
-installV2RayService() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 閰嶇疆V2Ray寮�鏈鸿嚜鍚�"
- if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
- rm -rf /etc/systemd/system/v2ray.service
- touch /etc/systemd/system/v2ray.service
- execStart='/etc/v2ray-agent/v2ray/v2ray -confdir /etc/v2ray-agent/v2ray/conf'
- cat <<EOF >/etc/systemd/system/v2ray.service
-[Unit]
-Description=V2Ray - A unified platform for anti-censorship
-Documentation=https://v2ray.com https://guide.v2fly.org
-After=network.target nss-lookup.target
-Wants=network-online.target
-
-[Service]
-Type=simple
-User=root
-CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW
-NoNewPrivileges=yes
-ExecStart=${execStart}
-Restart=on-failure
-RestartPreventExitStatus=23
-LimitNPROC=10000
-LimitNOFILE=1000000
-
-[Install]
-WantedBy=multi-user.target
-EOF
- systemctl daemon-reload
- systemctl enable v2ray.service
- echoContent green " ---> 閰嶇疆V2Ray寮�鏈鸿嚜鍚垚鍔�"
- fi
-}
-
-# Xray寮�鏈鸿嚜鍚�
-installXrayService() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 閰嶇疆Xray寮�鏈鸿嚜鍚�"
- if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
- rm -rf /etc/systemd/system/xray.service
- touch /etc/systemd/system/xray.service
- execStart='/etc/v2ray-agent/xray/xray run -confdir /etc/v2ray-agent/xray/conf'
- cat <<EOF >/etc/systemd/system/xray.service
-[Unit]
-Description=Xray Service
-Documentation=https://github.com/XTLS/Xray-core
-After=network.target nss-lookup.target
-Wants=network-online.target
-
-[Service]
-Type=simple
-User=root
-CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW
-NoNewPrivileges=yes
-ExecStart=${execStart}
-Restart=on-failure
-RestartPreventExitStatus=23
-LimitNPROC=10000
-LimitNOFILE=1000000
-
-[Install]
-WantedBy=multi-user.target
-EOF
- systemctl daemon-reload
- systemctl enable xray.service
- echoContent green " ---> 閰嶇疆Xray寮�鏈鸿嚜鍚垚鍔�"
- fi
-}
-
-# 鎿嶄綔V2Ray
-handleV2Ray() {
- # shellcheck disable=SC2010
- if find /bin /usr/bin | grep -q systemctl && ls /etc/systemd/system/ | grep -q v2ray.service; then
- if [[ -z $(pgrep -f "v2ray/v2ray") ]] && [[ "$1" == "start" ]]; then
- systemctl start v2ray.service
- elif [[ -n $(pgrep -f "v2ray/v2ray") ]] && [[ "$1" == "stop" ]]; then
- systemctl stop v2ray.service
- fi
- fi
- sleep 0.8
-
- if [[ "$1" == "start" ]]; then
- if [[ -n $(pgrep -f "v2ray/v2ray") ]]; then
- echoContent green " ---> V2Ray鍚姩鎴愬姛"
- else
- echoContent red "V2Ray鍚姩澶辫触"
- echoContent red "璇锋墜鍔ㄦ墽琛屻��/etc/v2ray-agent/v2ray/v2ray -confdir /etc/v2ray-agent/v2ray/conf銆戯紝鏌ョ湅閿欒鏃ュ織"
- exit 0
- fi
- elif [[ "$1" == "stop" ]]; then
- if [[ -z $(pgrep -f "v2ray/v2ray") ]]; then
- echoContent green " ---> V2Ray鍏抽棴鎴愬姛"
- else
- echoContent red "V2Ray鍏抽棴澶辫触"
- echoContent red "璇锋墜鍔ㄦ墽琛屻�恜s -ef|grep -v grep|grep v2ray|awk '{print \$2}'|xargs kill -9銆�"
- exit 0
- fi
- fi
-}
-# 鎿嶄綔xray
-handleXray() {
- if [[ -n $(find /bin /usr/bin -name "systemctl") ]] && [[ -n $(find /etc/systemd/system/ -name "xray.service") ]]; then
- if [[ -z $(pgrep -f "xray/xray") ]] && [[ "$1" == "start" ]]; then
- systemctl start xray.service
- elif [[ -n $(pgrep -f "xray/xray") ]] && [[ "$1" == "stop" ]]; then
- systemctl stop xray.service
- fi
- fi
-
- sleep 0.8
-
- if [[ "$1" == "start" ]]; then
- if [[ -n $(pgrep -f "xray/xray") ]]; then
- echoContent green " ---> Xray鍚姩鎴愬姛"
- else
- echoContent red "Xray鍚姩澶辫触"
- echoContent red "璇锋墜鍔ㄦ墽琛屻��/etc/v2ray-agent/xray/xray -confdir /etc/v2ray-agent/xray/conf銆戯紝鏌ョ湅閿欒鏃ュ織"
- exit 0
- fi
- elif [[ "$1" == "stop" ]]; then
- if [[ -z $(pgrep -f "xray/xray") ]]; then
- echoContent green " ---> Xray鍏抽棴鎴愬姛"
- else
- echoContent red "xray鍏抽棴澶辫触"
- echoContent red "璇锋墜鍔ㄦ墽琛屻�恜s -ef|grep -v grep|grep xray|awk '{print \$2}'|xargs kill -9銆�"
- exit 0
- fi
- fi
-}
-# 鑾峰彇clients閰嶇疆
-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}]涓婁竴娆″畨瑁呯殑閰嶇疆鏂囦欢锛岄噰鐢ㄩ厤缃枃浠剁殑绗竴涓猽uid"
- else
- previousClients=$(jq -r ".inbounds[0].settings.clients" "${path}")
- fi
-
- fi
-}
-
-# 娣诲姞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
-}
-
-# 鍒濆鍖朒ysteria閰嶇疆
-initHysteriaConfig() {
- echoContent skyBlue "\n杩涘害 $2/${totalProgress} : 鍒濆鍖朒ysteria閰嶇疆"
-}
-
-# 鍒濆鍖朧2Ray 閰嶇疆鏂囦欢
-initV2RayConfig() {
- echoContent skyBlue "\n杩涘害 $2/${totalProgress} : 鍒濆鍖朧2Ray閰嶇疆"
- echo
-
- read -r -p "鏄惁鑷畾涔塙UID 锛焄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 <<EOF >/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 <<EOF >/etc/v2ray-agent/v2ray/conf/10_ipv6_outbounds.json
-{
- "outbounds": [
- {
- "protocol": "freedom",
- "settings": {},
- "tag": "direct"
- }
- ]
-}
-EOF
-
- else
- cat <<EOF >/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 <<EOF >/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 <<EOF >/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": "${domain}_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 <<EOF >/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": "${domain}_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 <<EOF >/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": "${domain}_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 <<EOF >/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": "${domain}_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 <<EOF >/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": "${domain}_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}"
- cat <<EOF >/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json
-{
-"inbounds":[
-{
- "port": 443,
- "protocol": "vless",
- "tag":"VLESSTCP",
- "settings": {
- "clients": [
- {
- "id": "${uuid}",
- "add":"${add}",
- "email": "${domain}_VLESS_TLS-direct_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}"
-
-}
-
-# 鍒濆鍖朮ray Trojan XTLS 閰嶇疆鏂囦欢
-initXrayFrontingConfig() {
- if [[ -z "${configPath}" ]]; then
- echoContent red " ---> 鏈畨瑁咃紝璇蜂娇鐢ㄨ剼鏈畨瑁�"
- menu
- exit 0
- fi
- if [[ "${coreInstallType}" != "1" ]]; then
- echoContent red " ---> 鏈畨瑁呭彲鐢ㄧ被鍨�"
- fi
- local xtlsType=
- if echo ${currentInstallProtocolType} | grep -q trojan; then
- xtlsType=VLESS
- else
- xtlsType=Trojan
-
- fi
-
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 鍓嶇疆鍒囨崲涓�${xtlsType}"
- echoContent red "\n=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」\n"
- echoContent yellow "浼氬皢鍓嶇疆鏇挎崲涓�${xtlsType}"
- echoContent yellow "濡傛灉鍓嶇疆鏄疶rojan锛屾煡鐪嬪笎鍙锋椂鍒欎細鍑虹幇涓や釜Trojan鍗忚鐨勮妭鐐癸紝鏈変竴涓笉鍙敤xtls"
- echoContent yellow "鍐嶆鎵ц鍙垏鎹㈣嚦涓婁竴娆$殑鍓嶇疆\n"
-
- echoContent yellow "1.鍒囨崲鑷�${xtlsType}"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" selectType
- if [[ "${selectType}" == "1" ]]; then
-
- if [[ "${xtlsType}" == "Trojan" ]]; then
-
- local VLESSConfig
- VLESSConfig=$(cat ${configPath}${frontingType}.json)
- VLESSConfig=${VLESSConfig//"id"/"password"}
- VLESSConfig=${VLESSConfig//VLESSTCP/TrojanTCPXTLS}
- VLESSConfig=${VLESSConfig//VLESS/Trojan}
- VLESSConfig=${VLESSConfig//"vless"/"trojan"}
- VLESSConfig=${VLESSConfig//"id"/"password"}
-
- echo "${VLESSConfig}" | jq . >${configPath}02_trojan_TCP_inbounds.json
- rm ${configPath}${frontingType}.json
- elif [[ "${xtlsType}" == "VLESS" ]]; then
-
- local VLESSConfig
- VLESSConfig=$(cat ${configPath}02_trojan_TCP_inbounds.json)
- VLESSConfig=${VLESSConfig//"password"/"id"}
- VLESSConfig=${VLESSConfig//TrojanTCPXTLS/VLESSTCP}
- VLESSConfig=${VLESSConfig//Trojan/VLESS}
- VLESSConfig=${VLESSConfig//"trojan"/"vless"}
- VLESSConfig=${VLESSConfig//"password"/"id"}
-
- echo "${VLESSConfig}" | jq . >${configPath}02_VLESS_TCP_inbounds.json
- rm ${configPath}02_trojan_TCP_inbounds.json
- fi
- reloadCore
- fi
-
- exit 0
-}
-
-# 绉诲姩涓婃閰嶇疆鏂囦欢鑷充复鏃舵枃浠�
-movePreviousConfig() {
- if [[ -n "${configPath}" ]] && [[ -f "${configPath}02_VLESS_TCP_inbounds.json" ]]; then
- rm -rf ${configPath}../tmp/*
- mv ${configPath}* ${configPath}../tmp/
- fi
-
-}
-
-# 鍒濆鍖朮ray 閰嶇疆鏂囦欢
-initXrayConfig() {
- echoContent skyBlue "\n杩涘害 $2/${totalProgress} : 鍒濆鍖朮ray閰嶇疆"
- echo
- local uuid=
- local addClientsStatus=
- if [[ -n "${currentUUID}" ]]; then
- read -r -p "璇诲彇鍒颁笂娆″畨瑁呰褰曪紝鏄惁浣跨敤涓婃瀹夎鏃剁殑UUID 锛焄y/n]:" historyUUIDStatus
- if [[ "${historyUUIDStatus}" == "y" ]]; then
- addClientsStatus=true
- uuid=${currentUUID}
- echoContent green "\n ---> 浣跨敤鎴愬姛"
- fi
- fi
-
- if [[ -z "${uuid}" ]]; then
- echoContent yellow "璇疯緭鍏ヨ嚜瀹氫箟UUID[闇�鍚堟硶]锛孾鍥炶溅]闅忔満UUID"
- read -r -p 'UUID:' customUUID
-
- if [[ -n ${customUUID} ]]; then
- uuid=${customUUID}
- else
- uuid=$(/etc/v2ray-agent/xray/xray uuid)
- fi
-
- fi
-
- if [[ -z "${uuid}" ]]; then
- addClientsStatus=
- echoContent red "\n ---> uuid璇诲彇閿欒锛岄噸鏂扮敓鎴�"
- uuid=$(/etc/v2ray-agent/xray/xray uuid)
- fi
-
- echoContent yellow "\n ${uuid}"
-
- movePreviousConfig
-
- # log
- cat <<EOF >/etc/v2ray-agent/xray/conf/00_log.json
-{
- "log": {
- "error": "/etc/v2ray-agent/xray/error.log",
- "loglevel": "warning"
- }
-}
-EOF
-
- # outbounds
- if [[ -n "${pingIPv6}" ]]; then
- cat <<EOF >/etc/v2ray-agent/xray/conf/10_ipv6_outbounds.json
-{
- "outbounds": [
- {
- "protocol": "freedom",
- "settings": {},
- "tag": "direct"
- }
- ]
-}
-EOF
-
- else
- cat <<EOF >/etc/v2ray-agent/xray/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 <<EOF >/etc/v2ray-agent/xray/conf/11_dns.json
-{
- "dns": {
- "servers": [
- "localhost"
- ]
- }
-}
-EOF
-
- # VLESS_TCP_TLS/XTLS
- # 鍥炶惤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 <<EOF >/etc/v2ray-agent/xray/conf/04_trojan_TCP_inbounds.json
-{
-"inbounds":[
- {
- "port": 31296,
- "listen": "127.0.0.1",
- "protocol": "trojan",
- "tag":"trojanTCP",
- "settings": {
- "clients": [
- {
- "password": "${uuid}",
- "email": "${domain}_trojan_tcp"
- }
- ],
- "fallbacks":[
- {"dest":"31300"}
- ]
- },
- "streamSettings": {
- "network": "tcp",
- "security": "none",
- "tcpSettings": {
- "acceptProxyProtocol": true
- }
- }
- }
- ]
-}
-EOF
- addClients "/etc/v2ray-agent/xray/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 <<EOF >/etc/v2ray-agent/xray/conf/03_VLESS_WS_inbounds.json
-{
-"inbounds":[
- {
- "port": 31297,
- "listen": "127.0.0.1",
- "protocol": "vless",
- "tag":"VLESSWS",
- "settings": {
- "clients": [
- {
- "id": "${uuid}",
- "email": "${domain}_VLESS_WS"
- }
- ],
- "decryption": "none"
- },
- "streamSettings": {
- "network": "ws",
- "security": "none",
- "wsSettings": {
- "acceptProxyProtocol": true,
- "path": "/${customPath}ws"
- }
- }
- }
-]
-}
-EOF
- addClients "/etc/v2ray-agent/xray/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 <<EOF >/etc/v2ray-agent/xray/conf/04_trojan_gRPC_inbounds.json
-{
- "inbounds": [
- {
- "port": 31304,
- "listen": "127.0.0.1",
- "protocol": "trojan",
- "tag": "trojangRPCTCP",
- "settings": {
- "clients": [
- {
- "password": "${uuid}",
- "email": "${domain}_trojan_gRPC"
- }
- ],
- "fallbacks": [
- {
- "dest": "31300"
- }
- ]
- },
- "streamSettings": {
- "network": "grpc",
- "grpcSettings": {
- "serviceName": "${customPath}trojangrpc"
- }
- }
- }
- ]
-}
-EOF
- addClients "/etc/v2ray-agent/xray/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 <<EOF >/etc/v2ray-agent/xray/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": "${domain}_vmess_ws"
- }
- ]
- },
- "streamSettings": {
- "network": "ws",
- "security": "none",
- "wsSettings": {
- "acceptProxyProtocol": true,
- "path": "/${customPath}vws"
- }
- }
-}
-]
-}
-EOF
- addClients "/etc/v2ray-agent/xray/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 <<EOF >/etc/v2ray-agent/xray/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": "${domain}_VLESS_gRPC"
- }
- ],
- "decryption": "none"
- },
- "streamSettings": {
- "network": "grpc",
- "grpcSettings": {
- "serviceName": "${customPath}grpc"
- }
- }
- }
-]
-}
-EOF
- addClients "/etc/v2ray-agent/xray/conf/06_VLESS_gRPC_inbounds.json" "${addClientsStatus}"
- fi
-
- # VLESS_TCP
- getClients "${configPath}../tmp/02_VLESS_TCP_inbounds.json" "${addClientsStatus}"
- cat <<EOF >/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json
-{
-"inbounds":[
-{
- "port": 443,
- "protocol": "vless",
- "tag":"VLESSTCP",
- "settings": {
- "clients": [
- {
- "id": "${uuid}",
- "add":"${add}",
- "flow":"xtls-rprx-direct",
- "email": "${domain}_VLESS_XTLS/TLS-direct_TCP"
- }
- ],
- "decryption": "none",
- "fallbacks": [
- ${fallbacksList}
- ]
- },
- "streamSettings": {
- "network": "tcp",
- "security": "xtls",
- "xtlsSettings": {
- "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/xray/conf/02_VLESS_TCP_inbounds.json" "${addClientsStatus}"
-}
-
-# 鍒濆鍖朤rojan-Go閰嶇疆
-initTrojanGoConfig() {
-
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鍒濆鍖朤rojan閰嶇疆"
- cat <<EOF >/etc/v2ray-agent/trojan/config_full.json
-{
- "run_type": "server",
- "local_addr": "127.0.0.1",
- "local_port": 31296,
- "remote_addr": "127.0.0.1",
- "remote_port": 31300,
- "disable_http_check":true,
- "log_level":3,
- "log_file":"/etc/v2ray-agent/trojan/trojan.log",
- "password": [
- "${uuid}"
- ],
- "dns":[
- "localhost"
- ],
- "transport_plugin":{
- "enabled":true,
- "type":"plaintext"
- },
- "websocket": {
- "enabled": true,
- "path": "/${customPath}tws",
- "host": "${domain}",
- "add":"${add}"
- },
- "router": {
- "enabled": false
- }
-}
-EOF
-}
-
-# 鑷畾涔塁DN IP
-customCDNIP() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 娣诲姞cloudflare鑷�塁NAME"
- echoContent red "\n=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」"
- echoContent yellow "\n鏁欑▼鍦板潃:"
- echoContent skyBlue "https://github.com/mack-a/v2ray-agent/blob/master/documents/optimize_V2Ray.md"
- echoContent red "\n濡傚Cloudflare浼樺寲涓嶄簡瑙o紝璇蜂笉瑕佷娇鐢�"
- echoContent yellow "\n 1.绉诲姩:104.16.123.96"
- echoContent yellow " 2.鑱旈��:www.cloudflare.com"
- echoContent yellow " 3.鐢典俊:www.digitalocean.com"
- echoContent skyBlue "----------------------------"
- read -r -p "璇烽�夋嫨[鍥炶溅涓嶄娇鐢╙:" selectCloudflareType
- case ${selectCloudflareType} in
- 1)
- add="104.16.123.96"
- ;;
- 2)
- add="www.cloudflare.com"
- ;;
- 3)
- add="www.digitalocean.com"
- ;;
- *)
- add="${domain}"
- echoContent yellow "\n ---> 涓嶄娇鐢�"
- ;;
- esac
-}
-# 閫氱敤
-defaultBase64Code() {
- local type=$1
- local email=$2
- local id=$3
-
- port=${currentDefaultPort}
-
- local subAccount
- subAccount=$(echo "${email}" | awk -F "[_]" '{print $1}')_$(echo "${id}_currentHost" | md5sum | awk '{print $1}')
- if [[ "${type}" == "vlesstcp" ]]; then
-
- if [[ "${coreInstallType}" == "1" ]] && echo "${currentInstallProtocolType}" | grep -q 0; then
- echoContent yellow " ---> 閫氱敤鏍煎紡(VLESS+TCP+TLS/xtls-rprx-direct)"
- echoContent green " vless://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-direct#${email}\n"
-
- echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(VLESS+TCP+TLS/xtls-rprx-direct)"
- echoContent green "鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:xtls锛屼紶杈撴柟寮�:tcp锛宖low:xtls-rprx-direct锛岃处鎴峰悕:${email}\n"
- cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
-vless://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-direct#${email}
-EOF
- echoContent yellow " ---> 浜岀淮鐮� VLESS(VLESS+TCP+TLS/xtls-rprx-direct)"
- echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%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-direct%23${email}\n"
-
- echoContent skyBlue "----------------------------------------------------------------------------------"
-
- echoContent yellow " ---> 閫氱敤鏍煎紡(VLESS+TCP+TLS/xtls-rprx-splice)"
- echoContent green " vless://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-splice#${email/direct/splice}\n"
-
- echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(VLESS+TCP+TLS/xtls-rprx-splice)"
- echoContent green " 鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:xtls锛屼紶杈撴柟寮�:tcp锛宖low:xtls-rprx-splice锛岃处鎴峰悕:${email/direct/splice}\n"
- cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
-vless://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-splice#${email/direct/splice}
-EOF
- echoContent yellow " ---> 浜岀淮鐮� VLESS(VLESS+TCP+TLS/xtls-rprx-splice)"
- echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%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-splice%23${email/direct/splice}\n"
-
- elif [[ "${coreInstallType}" == 2 || "${coreInstallType}" == "3" ]]; then
- echoContent yellow " ---> 閫氱敤鏍煎紡(VLESS+TCP+TLS)"
- echoContent green " vless://${id}@${currentHost}:${currentDefaultPort}?security=tls&encryption=none&host=${currentHost}&headerType=none&type=tcp#${email}\n"
-
- echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(VLESS+TCP+TLS/xtls-rprx-splice)"
- echoContent green " 鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:tls锛屼紶杈撴柟寮�:tcp锛岃处鎴峰悕:${email/direct/splice}\n"
-
- cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
-vless://${id}@${currentHost}:${currentDefaultPort}?security=tls&encryption=none&host=${currentHost}&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%26host%3d${currentHost}%26headerType%3dnone%26type%3dtcp%23${email}\n"
- fi
-
- elif [[ "${type}" == "trojanTCPXTLS" ]]; then
- echoContent yellow " ---> 閫氱敤鏍煎紡(Trojan+TCP+TLS/xtls-rprx-direct)"
- echoContent green " trojan://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-direct#${email}\n"
-
- echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(Trojan+TCP+TLS/xtls-rprx-direct)"
- echoContent green "鍗忚绫诲瀷:Trojan锛屽湴鍧�:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:xtls锛屼紶杈撴柟寮�:tcp锛宖low:xtls-rprx-direct锛岃处鎴峰悕:${email}\n"
- cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
-trojan://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-direct#${email}
-EOF
- echoContent yellow " ---> 浜岀淮鐮� Trojan(Trojan+TCP+TLS/xtls-rprx-direct)"
- 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-direct%23${email}\n"
-
- echoContent skyBlue "----------------------------------------------------------------------------------"
-
- echoContent yellow " ---> 閫氱敤鏍煎紡(Trojan+TCP+TLS/xtls-rprx-splice)"
- echoContent green " trojan://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-splice#${email/direct/splice}\n"
-
- echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(Trojan+TCP+TLS/xtls-rprx-splice)"
- echoContent green " 鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:xtls锛屼紶杈撴柟寮�:tcp锛宖low:xtls-rprx-splice锛岃处鎴峰悕:${email/direct/splice}\n"
- cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
-trojan://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-splice#${email/direct/splice}
-EOF
- echoContent yellow " ---> 浜岀淮鐮� Trojan(Trojan+TCP+TLS/xtls-rprx-splice)"
- 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-splice%23${email/direct/splice}\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\":\"${currentAdd}\",\"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\":\"${currentAdd}\",\"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)"
-
- cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
-vmess://${qrCodeBase64Default}
-EOF
- echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vmess://${qrCodeBase64Default}\n"
-
- # elif [[ "${type}" == "vmesstcp" ]]; then
- #
- # echoContent red "path:${path}"
- # qrCodeBase64Default=$(echo -n "{\"add\":\"${add}\",\"aid\":0,\"host\":\"${host}\",\"id\":\"${id}\",\"net\":\"tcp\",\"path\":\"${path}\",\"port\":${port},\"ps\":\"${email}\",\"scy\":\"none\",\"sni\":\"${host}\",\"tls\":\"tls\",\"v\":2,\"type\":\"http\",\"allowInsecure\":0,\"peer\":\"${host}\",\"obfs\":\"http\",\"obfsParam\":\"${host}\"}" | base64)
- # qrCodeBase64Default="${qrCodeBase64Default// /}"
- #
- # echoContent yellow " ---> 閫氱敤json(VMess+TCP+TLS)"
- # echoContent green " {\"port\":'${port}',\"ps\":\"${email}\",\"tls\":\"tls\",\"id\":\"${id}\",\"aid\":0,\"v\":2,\"host\":\"${host}\",\"type\":\"http\",\"path\":\"${path}\",\"net\":\"http\",\"add\":\"${add}\",\"allowInsecure\":0,\"method\":\"post\",\"peer\":\"${host}\",\"obfs\":\"http\",\"obfsParam\":\"${host}\"}\n"
- # echoContent yellow " ---> 閫氱敤vmess(VMess+TCP+TLS)閾炬帴"
- # echoContent green " vmess://${qrCodeBase64Default}\n"
- #
- # cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
- #vmess://${qrCodeBase64Default}
- #EOF
- # echoContent yellow " ---> 浜岀淮鐮� vmess(VMess+TCP+TLS)"
- # echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vmess://${qrCodeBase64Default}\n"
-
- elif [[ "${type}" == "vlessws" ]]; then
-
- echoContent yellow " ---> 閫氱敤鏍煎紡(VLESS+WS+TLS)"
- echoContent green " vless://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&security=tls&type=ws&host=${currentHost}&sni=${currentHost}&path=/${currentPath}ws#${email}\n"
-
- echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(VLESS+WS+TLS)"
- echoContent green " 鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentAdd}锛屼吉瑁呭煙鍚�/SNI:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:tls锛屼紶杈撴柟寮�:ws锛岃矾寰�:/${currentPath}ws锛岃处鎴峰悕:${email}\n"
-
- cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
-vless://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&security=tls&type=ws&host=${currentHost}&sni=${currentHost}&path=/${currentPath}ws#${email}
-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${currentAdd}%3A${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dws%26host%3D${currentHost}%26sni%3D${currentHost}%26path%3D%252f${currentPath}ws%23${email}"
-
- elif [[ "${type}" == "vlessgrpc" ]]; then
-
- echoContent yellow " ---> 閫氱敤鏍煎紡(VLESS+gRPC+TLS)"
- echoContent green " vless://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&security=tls&type=grpc&host=${currentHost}&path=${currentPath}grpc&serviceName=${currentPath}grpc&alpn=h2&sni=${currentHost}#${email}\n"
-
- echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(VLESS+gRPC+TLS)"
- echoContent green " 鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentAdd}锛屼吉瑁呭煙鍚�/SNI:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:tls锛屼紶杈撴柟寮�:gRPC锛宎lpn:h2锛宻erviceName:${currentPath}grpc锛岃处鎴峰悕:${email}\n"
-
- cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
-vless://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&security=tls&type=grpc&host=${currentHost}&path=${currentPath}grpc&serviceName=${currentPath}grpc&alpn=h2&sni=${currentHost}#${email}
-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${currentAdd}%3A${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dgrpc%26host%3D${currentHost}%26serviceName%3D${currentPath}grpc%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}&sni=${currentHost}&alpn=http/1.1#${currentHost}_Trojan\n"
-
- cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
-trojan://${id}@${currentHost}:${currentDefaultPort}?peer=${currentHost}&sni=${currentHost}&alpn=http/1.1#${email}_Trojan
-EOF
- echoContent yellow " ---> 浜岀淮鐮� Trojan(TLS)"
- echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${currentHost}%3a${port}%3fpeer%3d${currentHost}%26sni%3d${currentHost}%26alpn%3Dhttp/1.1%23${email}\n"
-
- elif [[ "${type}" == "trojangrpc" ]]; then
- # URLEncode
-
- echoContent yellow " ---> Trojan gRPC(TLS)"
- echoContent green " trojan://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&peer=${currentHost}&security=tls&type=grpc&sni=${currentHost}&alpn=h2&path=${currentPath}trojangrpc&serviceName=${currentPath}trojangrpc#${email}\n"
- cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
-trojan://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&peer=${currentHost}&security=tls&type=grpc&sni=${currentHost}&alpn=h2&path=${currentPath}trojangrpc&serviceName=${currentPath}trojangrpc#${email}
-EOF
- echoContent yellow " ---> 浜岀淮鐮� Trojan gRPC(TLS)"
- echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${currentAdd}%3a${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dtls%26peer%3d${currentHost}%26type%3Dgrpc%26sni%3d${currentHost}%26path%3D${currentPath}trojangrpc%26alpn%3Dh2%26serviceName%3D${currentPath}trojangrpc%23${email}\n"
- fi
-
-}
-
-# 璐﹀彿
-showAccounts() {
- readInstallType
- readInstallProtocolType
- readConfigHostPathUUID
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 璐﹀彿"
- local show
- # VLESS TCP
- if [[ -n "${configPath}" ]]; then
- show=1
- if echo "${currentInstallProtocolType}" | grep -q trojan; then
- echoContent skyBlue "===================== Trojan TCP TLS/XTLS-direct/XTLS-splice ======================\n"
- jq .inbounds[0].settings.clients ${configPath}02_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
- echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
- defaultBase64Code trojanTCPXTLS "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .password)"
- done
-
- else
- echoContent skyBlue "===================== VLESS TCP TLS/XTLS-direct/XTLS-splice ======================\n"
- jq .inbounds[0].settings.clients ${configPath}02_VLESS_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
- echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
- echo
- defaultBase64Code vlesstcp "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
- done
- fi
-
- # VLESS WS
- if echo ${currentInstallProtocolType} | grep -q 1; then
- echoContent skyBlue "\n================================ VLESS WS TLS CDN ================================\n"
-
- jq .inbounds[0].settings.clients ${configPath}03_VLESS_WS_inbounds.json | jq -c '.[]' | while read -r user; do
- echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
- echo
- local path="${currentPath}ws"
- # if [[ ${coreInstallType} == "1" ]]; then
- # echoContent yellow "Xray鐨�0-RTT path鍚庨潰浼氭湁锛屼笉鍏煎浠2ray涓烘牳蹇冪殑瀹㈡埛绔紝璇锋墜鍔ㄥ垹闄ゅ悗浣跨敤\n"
- # path="${currentPath}ws"
- # fi
- defaultBase64Code vlessws "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
- done
- fi
-
- # VMess WS
- if echo ${currentInstallProtocolType} | grep -q 3; then
- echoContent skyBlue "\n================================ VMess WS TLS CDN ================================\n"
- local path="${currentPath}vws"
- if [[ ${coreInstallType} == "1" ]]; then
- path="${currentPath}vws"
- fi
- jq .inbounds[0].settings.clients ${configPath}05_VMess_WS_inbounds.json | jq -c '.[]' | while read -r user; do
- echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
- echo
- defaultBase64Code vmessws "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
- done
- fi
-
- # VLESS grpc
- if echo ${currentInstallProtocolType} | grep -q 5; then
- echoContent skyBlue "\n=============================== VLESS gRPC TLS CDN ===============================\n"
- echoContent red "\n --->gRPC澶勪簬娴嬭瘯闃舵锛屽彲鑳藉浣犱娇鐢ㄧ殑瀹㈡埛绔笉鍏煎锛屽涓嶈兘浣跨敤璇峰拷鐣�"
- # local serviceName
- # serviceName=$(jq -r .inbounds[0].streamSettings.grpcSettings.serviceName ${configPath}06_VLESS_gRPC_inbounds.json)
- jq .inbounds[0].settings.clients ${configPath}06_VLESS_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do
- echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
- echo
- defaultBase64Code vlessgrpc "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
- done
- fi
- fi
-
- # trojan tcp
- if echo ${currentInstallProtocolType} | grep -q 4; then
- echoContent skyBlue "\n================================== Trojan TLS ==================================\n"
- jq .inbounds[0].settings.clients ${configPath}04_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
- echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
-
- defaultBase64Code trojan "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .password)"
- done
- fi
-
- if echo ${currentInstallProtocolType} | grep -q 2; then
- echoContent skyBlue "\n================================ Trojan gRPC TLS ================================\n"
- echoContent red "\n --->gRPC澶勪簬娴嬭瘯闃舵锛屽彲鑳藉浣犱娇鐢ㄧ殑瀹㈡埛绔笉鍏煎锛屽涓嶈兘浣跨敤璇峰拷鐣�"
- # local serviceName=
- # serviceName=$(jq -r .inbounds[0].streamSettings.grpcSettings.serviceName ${configPath}04_trojan_gRPC_inbounds.json)
- jq .inbounds[0].settings.clients ${configPath}04_trojan_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do
- echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
- echo
- defaultBase64Code trojangrpc "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .password)"
- done
- fi
-
- if [[ -z ${show} ]]; then
- echoContent red " ---> 鏈畨瑁�"
- fi
-}
-# 绉婚櫎nginx302閰嶇疆
-removeNginx302() {
- # 鏌ユ壘鍒�302閭h骞跺垹闄�
- # local line302Result=
- # line302Result=$(grep -n "return 302" </etc/nginx/conf.d/alone.conf | tail -n 1)
- local count=0
- grep -n "return 302" <"/etc/nginx/conf.d/alone.conf" | while read -r line; do
-
- if ! echo "${line}" | grep -q "request_uri"; then
- local removeIndex=
- removeIndex=$(echo "${line}" | awk -F "[:]" '{print $1}')
- removeIndex=$((removeIndex + count))
- sed -i "${removeIndex}d" /etc/nginx/conf.d/alone.conf
- count=$((count - 1))
- fi
- done
-}
-
-# 妫�鏌�302鏄惁鎴愬姛
-checkNginx302() {
- local domain302Status=
- domain302Status=$(curl -s "https://${currentHost}")
- if echo "${domain302Status}" | grep -q "302"; then
- local domain302Result=
- domain302Result=$(curl -L -s "https://${currentHost}")
- if [[ -n "${domain302Result}" ]]; then
- echoContent green " ---> 302閲嶅畾鍚戣缃垚鍔�"
- exit 0
- fi
- fi
- echoContent red " ---> 302閲嶅畾鍚戣缃け璐ワ紝璇蜂粩缁嗘鏌ユ槸鍚﹀拰绀轰緥鐩稿悓"
- backupNginxConfig restoreBackup
-}
-
-# 澶囦唤鎭㈠nginx鏂囦欢
-backupNginxConfig() {
- if [[ "$1" == "backup" ]]; then
- cp /etc/nginx/conf.d/alone.conf /etc/v2ray-agent/alone_backup.conf
- echoContent green " ---> nginx閰嶇疆鏂囦欢澶囦唤鎴愬姛"
- fi
-
- if [[ "$1" == "restoreBackup" ]] && [[ -f "/etc/v2ray-agent/alone_backup.conf" ]]; then
- cp /etc/v2ray-agent/alone_backup.conf /etc/nginx/conf.d/alone.conf
- echoContent green " ---> nginx閰嶇疆鏂囦欢鎭㈠澶囦唤鎴愬姛"
- rm /etc/v2ray-agent/alone_backup.conf
- fi
-
-}
-# 娣诲姞302閰嶇疆
-addNginx302() {
- # local line302Result=
- # line302Result=$(| tail -n 1)
- local count=1
- grep -n "Strict-Transport-Security" <"/etc/nginx/conf.d/alone.conf" | while read -r line; do
- if [[ -n "${line}" ]]; then
- local insertIndex=
- insertIndex="$(echo "${line}" | awk -F "[:]" '{print $1}')"
- insertIndex=$((insertIndex + count))
- sed "${insertIndex}i return 302 '$1';" /etc/nginx/conf.d/alone.conf >/etc/nginx/conf.d/tmpfile && mv /etc/nginx/conf.d/tmpfile /etc/nginx/conf.d/alone.conf
- count=$((count + 1))
- else
- echoContent red " ---> 302娣诲姞澶辫触"
- backupNginxConfig restoreBackup
- fi
-
- done
-}
-
-# 鏇存柊浼绔�
-updateNginxBlog() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鏇存崲浼绔欑偣"
- echoContent red "=============================================================="
- echoContent yellow "# 濡傞渶鑷畾涔夛紝璇锋墜鍔ㄥ鍒舵ā鐗堟枃浠跺埌 /usr/share/nginx/html \n"
- echoContent yellow "1.鏂版墜寮曞"
- echoContent yellow "2.娓告垙缃戠珯"
- echoContent yellow "3.涓汉鍗氬01"
- echoContent yellow "4.浼佷笟绔�"
- echoContent yellow "5.瑙i攣鍔犲瘑鐨勯煶涔愭枃浠舵ā鐗圼https://github.com/ix64/unlock-music]"
- echoContent yellow "6.mikutap[https://github.com/HFIProgramming/mikutap]"
- echoContent yellow "7.浼佷笟绔�02"
- echoContent yellow "8.涓汉鍗氬02"
- echoContent yellow "9.404鑷姩璺宠浆baidu"
- echoContent yellow "10.302閲嶅畾鍚戠綉绔�"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" selectInstallNginxBlogType
-
- if [[ "${selectInstallNginxBlogType}" == "10" ]]; then
- echoContent red "\n=============================================================="
- echoContent yellow "閲嶅畾鍚戠殑浼樺厛绾ф洿楂橈紝閰嶇疆302涔嬪悗濡傛灉鏇存敼浼绔欑偣锛屾牴璺敱涓嬩吉瑁呯珯鐐瑰皢涓嶈捣浣滅敤"
- echoContent yellow "濡傛兂瑕佷吉瑁呯珯鐐瑰疄鐜颁綔鐢ㄩ渶鍒犻櫎302閲嶅畾鍚戦厤缃甛n"
- echoContent yellow "1.娣诲姞"
- echoContent yellow "2.鍒犻櫎"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" redirectStatus
-
- if [[ "${redirectStatus}" == "1" ]]; then
- backupNginxConfig backup
- read -r -p "璇疯緭鍏ヨ閲嶅畾鍚戠殑鍩熷悕,渚嬪 https://www.baidu.com:" redirectDomain
- removeNginx302
- addNginx302 "${redirectDomain}"
- handleNginx stop
- handleNginx start
- if [[ -z $(pgrep -f nginx) ]]; then
- backupNginxConfig restoreBackup
- handleNginx start
- exit 0
- fi
- checkNginx302
- exit 0
- fi
- if [[ "${redirectStatus}" == "2" ]]; then
- removeNginx302
- echoContent green " ---> 绉婚櫎302閲嶅畾鍚戞垚鍔�"
- exit 0
- fi
- fi
- if [[ "${selectInstallNginxBlogType}" =~ ^[1-9]$ ]]; then
- rm -rf /usr/share/nginx/*
- if wget --help | grep -q show-progress; then
- wget -c -q --show-progress -P /usr/share/nginx "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${selectInstallNginxBlogType}.zip" >/dev/null
- else
- wget -c -P /usr/share/nginx "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${selectInstallNginxBlogType}.zip" >/dev/null
- fi
-
- unzip -o "/usr/share/nginx/html${selectInstallNginxBlogType}.zip" -d /usr/share/nginx/html >/dev/null
- rm -f "/usr/share/nginx/html${selectInstallNginxBlogType}.zip*"
- echoContent green " ---> 鏇存崲浼珯鎴愬姛"
- else
- echoContent red " ---> 閫夋嫨閿欒锛岃閲嶆柊閫夋嫨"
- updateNginxBlog
- fi
-}
-
-# 娣诲姞鏂扮鍙�
-addCorePort() {
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 娣诲姞鏂扮鍙�"
- echoContent red "\n=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」\n"
- echoContent yellow "鏀寔鎵归噺娣诲姞"
- echoContent yellow "涓嶅奖鍝�443绔彛鐨勪娇鐢�"
- echoContent yellow "鏌ョ湅甯愬彿鏃讹紝鍙細灞曠ず榛樿绔彛443鐨勫笎鍙�"
- echoContent yellow "涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
- echoContent yellow "褰曞叆绀轰緥:2053,2083,2087\n"
-
- echoContent yellow "1.娣诲姞绔彛"
- echoContent yellow "2.鍒犻櫎绔彛"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" selectNewPortType
- if [[ "${selectNewPortType}" == "1" ]]; then
- read -r -p "璇疯緭鍏ョ鍙e彿:" newPort
- read -r -p "璇疯緭鍏ラ粯璁ょ殑绔彛鍙凤紝鍚屾椂浼氭洿鏀硅闃呯鍙d互鍙婅妭鐐圭鍙o紝[鍥炶溅]榛樿443:" defaultPort
-
- if [[ -n "${defaultPort}" ]]; then
- rm -rf "$(find ${configPath}* | grep "default")"
- fi
-
- if [[ -n "${newPort}" ]]; then
-
- while read -r port; do
- rm -rf "$(find ${configPath}* | grep "${port}")"
-
- local fileName=
- if [[ -n "${defaultPort}" && "${port}" == "${defaultPort}" ]]; then
- fileName="${configPath}02_dokodemodoor_inbounds_${port}_default.json"
- else
- fileName="${configPath}02_dokodemodoor_inbounds_${port}.json"
- fi
-
- # 寮�鏀剧鍙�
- allowPort "${port}"
-
- cat <<EOF >"${fileName}"
-{
- "inbounds": [
- {
- "listen": "0.0.0.0",
- "port": ${port},
- "protocol": "dokodemo-door",
- "settings": {
- "address": "127.0.0.1",
- "port": 443,
- "network": "tcp",
- "followRedirect": false
- },
- "tag": "dokodemo-door-newPort-${port}"
- }
- ]
-}
-EOF
- done < <(echo "${newPort}" | tr ',' '\n')
-
- echoContent green " ---> 娣诲姞鎴愬姛"
- reloadCore
- fi
- elif [[ "${selectNewPortType}" == "2" ]]; then
-
- find ${configPath} -name "*dokodemodoor*" | awk -F "[c][o][n][f][/]" '{print ""NR""":"$2}'
- read -r -p "璇疯緭鍏ヨ鍒犻櫎鐨勭鍙g紪鍙�:" portIndex
- local dokoConfig
- dokoConfig=$(find ${configPath} -name "*dokodemodoor*" | awk -F "[c][o][n][f][/]" '{print ""NR""":"$2}' | grep "${portIndex}:")
- if [[ -n "${dokoConfig}" ]]; then
- rm "${configPath}/$(echo "${dokoConfig}" | awk -F "[:]" '{print $2}')"
- reloadCore
- else
- echoContent yellow "\n ---> 缂栧彿杈撳叆閿欒锛岃閲嶆柊閫夋嫨"
- addCorePort
- fi
- fi
-}
-
-# 鍗歌浇鑴氭湰
-unInstall() {
- read -r -p "鏄惁纭鍗歌浇瀹夎鍐呭锛焄y/n]:" unInstallStatus
- if [[ "${unInstallStatus}" != "y" ]]; then
- echoContent green " ---> 鏀惧純鍗歌浇"
- menu
- exit 0
- fi
-
- handleNginx stop
- if [[ -z $(pgrep -f "nginx") ]]; then
- echoContent green " ---> 鍋滄Nginx鎴愬姛"
- fi
-
- if [[ "${coreInstallType}" == "1" ]]; then
- handleXray stop
- rm -rf /etc/systemd/system/xray.service
- echoContent green " ---> 鍒犻櫎Xray寮�鏈鸿嚜鍚畬鎴�"
-
- elif [[ "${coreInstallType}" == "2" ]]; then
-
- handleV2Ray stop
- rm -rf /etc/systemd/system/v2ray.service
- echoContent green " ---> 鍒犻櫎V2Ray寮�鏈鸿嚜鍚畬鎴�"
-
- fi
-
- if [[ -f "/root/.acme.sh/acme.sh.env" ]] && grep -q 'acme.sh.env' </root/.bashrc; then
- sed -i 's/. "\/root\/.acme.sh\/acme.sh.env"//g' "$(grep '. "/root/.acme.sh/acme.sh.env"' -rl /root/.bashrc)"
- fi
- rm -rf /root/.acme.sh
- echoContent green " ---> 鍒犻櫎acme.sh瀹屾垚"
-
- rm -rf /tmp/v2ray-agent-tls/*
- if [[ -d "/etc/v2ray-agent/tls" ]] && [[ -n $(find /etc/v2ray-agent/tls/ -name "*.key") ]] && [[ -n $(find /etc/v2ray-agent/tls/ -name "*.crt") ]]; then
- mv /etc/v2ray-agent/tls /tmp/v2ray-agent-tls
- if [[ -n $(find /tmp/v2ray-agent-tls -name '*.key') ]]; then
- echoContent yellow " ---> 澶囦唤璇佷功鎴愬姛锛岃娉ㄦ剰鐣欏瓨銆俒/tmp/v2ray-agent-tls]"
- fi
- fi
-
- rm -rf /etc/v2ray-agent
- rm -rf ${nginxConfigPath}alone.conf
-
- if [[ -d "/usr/share/nginx/html" && -f "/usr/share/nginx/html/check" ]]; then
- rm -rf /usr/share/nginx/html
- echoContent green " ---> 鍒犻櫎浼缃戠珯瀹屾垚"
- fi
-
- rm -rf /usr/bin/vasma
- rm -rf /usr/sbin/vasma
- echoContent green " ---> 鍗歌浇蹇嵎鏂瑰紡瀹屾垚"
- echoContent green " ---> 鍗歌浇v2ray-agent鑴氭湰瀹屾垚"
-}
-
-# 淇敼V2Ray CDN鑺傜偣
-updateV2RayCDN() {
-
- # todo 閲嶆瀯姝ゆ柟娉�
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 淇敼CDN鑺傜偣"
-
- if [[ -n "${currentAdd}" ]]; then
- echoContent red "=============================================================="
- echoContent yellow "1.CNAME www.digitalocean.com"
- echoContent yellow "2.CNAME www.cloudflare.com"
- echoContent yellow "3.CNAME hostmonit.com"
- echoContent yellow "4.鎵嬪姩杈撳叆"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" selectCDNType
- case ${selectCDNType} in
- 1)
- setDomain="www.digitalocean.com"
- ;;
- 2)
- setDomain="www.cloudflare.com"
- ;;
- 3)
- setDomain="hostmonit.com"
- ;;
- 4)
- read -r -p "璇疯緭鍏ユ兂瑕佽嚜瀹氫箟CDN IP鎴栬�呭煙鍚�:" setDomain
- ;;
- esac
-
- if [[ -n ${setDomain} ]]; then
- if [[ -n "${currentAdd}" ]]; then
- sed -i "s/\"${currentAdd}\"/\"${setDomain}\"/g" "$(grep "${currentAdd}" -rl ${configPath}${frontingType}.json)"
- fi
- if [[ $(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json) == "${setDomain}" ]]; then
- echoContent green " ---> CDN淇敼鎴愬姛"
- reloadCore
- else
- echoContent red " ---> 淇敼CDN澶辫触"
- fi
- fi
- else
- 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
-}
-
-# 鑷畾涔塽uid
-customUUID() {
- # read -r -p "鏄惁鑷畾涔塙UID 锛焄y/n]:" customUUIDStatus
- # echo
- # if [[ "${customUUIDStatus}" == "y" ]]; then
- read -r -p "璇疯緭鍏ュ悎娉曠殑UUID锛孾鍥炶溅]闅忔満UUID:" currentCustomUUID
- echo
- if [[ -z "${currentCustomUUID}" ]]; then
- # echoContent red " ---> UUID涓嶅彲涓虹┖"
- currentCustomUUID=$(${ctlPath} uuid)
- echoContent yellow "uuid:${currentCustomUUID}\n"
-
- else
- jq -r -c '.inbounds[0].settings.clients[].id' ${configPath}${frontingType}.json | while read -r line; do
- if [[ "${line}" == "${currentCustomUUID}" ]]; then
- echo >/tmp/v2ray-agent
- fi
- done
- if [[ -f "/tmp/v2ray-agent" && -n $(cat /tmp/v2ray-agent) ]]; then
- echoContent red " ---> UUID涓嶅彲閲嶅"
- rm /tmp/v2ray-agent
- exit 0
- fi
- fi
- # fi
-}
-
-# 鑷畾涔塭mail
-customUserEmail() {
- # read -r -p "鏄惁鑷畾涔塭mail 锛焄y/n]:" customEmailStatus
- # echo
- # if [[ "${customEmailStatus}" == "y" ]]; then
- read -r -p "璇疯緭鍏ュ悎娉曠殑email锛孾鍥炶溅]闅忔満email:" currentCustomEmail
- echo
- if [[ -z "${currentCustomEmail}" ]]; then
- currentCustomEmail="${currentHost}_${currentCustomUUID}"
- echoContent yellow "email: ${currentCustomEmail}\n"
- # echoContent red " ---> email涓嶅彲涓虹┖"
- else
- jq -r -c '.inbounds[0].settings.clients[].email' ${configPath}${frontingType}.json | while read -r line; do
- if [[ "${line}" == "${currentCustomEmail}" ]]; then
- echo >/tmp/v2ray-agent
- fi
- done
- if [[ -f "/tmp/v2ray-agent" && -n $(cat /tmp/v2ray-agent) ]]; then
- echoContent red " ---> email涓嶅彲閲嶅"
- rm /tmp/v2ray-agent
- exit 0
- fi
- fi
- # fi
-}
-
-# 娣诲姞鐢ㄦ埛
-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}
- else
- email=${currentHost}_${uuid}
- fi
-
- # 鍏煎v2ray-core
- users="{\"id\":\"${uuid}\",\"flow\":\"xtls-rprx-direct\",\"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/}"
-
- 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//"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//\"flow\":\"xtls-rprx-direct\"\,/}"
- 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-direct\"\,/}"
- 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-direct\"\,/}"
-
- 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-direct\"\,/}"
- vlessGRPCUsers="${vlessGRPCUsers//\,\"alterId\":0/}"
-
- 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-direct\"\,/}"
- trojanUsers="${trojanUsers//id/password}"
- trojanUsers="${trojanUsers//\,\"alterId\":0/}"
-
- 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
- done
-
- reloadCore
- echoContent green " ---> 娣诲姞瀹屾垚"
- manageAccount 1
-}
-
-# 绉婚櫎鐢ㄦ埛
-removeUser() {
-
- 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
- vlessTcpResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}${frontingType}.json)
- echo "${vlessTcpResult}" | jq . >${configPath}${frontingType}.json
- fi
- fi
- if [[ -n "${delUserIndex}" ]]; then
- if echo ${currentInstallProtocolType} | grep -q 1; then
- local vlessWSResult
- vlessWSResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${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
- trojangRPCUsers=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}04_trojan_gRPC_inbounds.json)
- echo "${trojangRPCUsers}" | jq . >${configPath}04_trojan_gRPC_inbounds.json
- fi
-
- if echo ${currentInstallProtocolType} | grep -q 3; then
- local vmessWSResult
- vmessWSResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}05_VMess_WS_inbounds.json)
- echo "${vmessWSResult}" | jq . >${configPath}05_VMess_WS_inbounds.json
- fi
-
- if echo ${currentInstallProtocolType} | grep -q 5; then
- local vlessGRPCResult
- vlessGRPCResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}06_VLESS_gRPC_inbounds.json)
- echo "${vlessGRPCResult}" | jq . >${configPath}06_VLESS_gRPC_inbounds.json
- fi
-
- if echo ${currentInstallProtocolType} | grep -q 4; then
- local trojanTCPResult
- trojanTCPResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}04_trojan_TCP_inbounds.json)
- echo "${trojanTCPResult}" | jq . >${configPath}04_trojan_TCP_inbounds.json
- fi
-
- reloadCore
- fi
- manageAccount 1
-}
-# 鏇存柊鑴氭湰
-updateV2RayAgent() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鏇存柊v2ray-agent鑴氭湰"
- rm -rf /etc/v2ray-agent/install.sh
- if wget --help | grep -q show-progress; then
- wget -c -q --show-progress -P /etc/v2ray-agent/ -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh"
- else
- wget -c -q -P /etc/v2ray-agent/ -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh"
- fi
-
- sudo chmod 700 /etc/v2ray-agent/install.sh
- local version
- version=$(grep '褰撳墠鐗堟湰:v' "/etc/v2ray-agent/install.sh" | awk -F "[v]" '{print $2}' | tail -n +2 | head -n 1 | awk -F "[\"]" '{print $1}')
-
- echoContent green "\n ---> 鏇存柊瀹屾瘯"
- echoContent yellow " ---> 璇锋墜鍔ㄦ墽琛孾vasma]鎵撳紑鑴氭湰"
- echoContent green " ---> 褰撳墠鐗堟湰:${version}\n"
- echoContent yellow "濡傛洿鏂颁笉鎴愬姛锛岃鎵嬪姩鎵ц涓嬮潰鍛戒护\n"
- echoContent skyBlue "wget -P /root -N --no-check-certificate https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh && chmod 700 /root/install.sh && /root/install.sh"
- echo
- exit 0
-}
-
-# 闃茬伀澧�
-handleFirewall() {
- if systemctl status ufw 2>/dev/null | grep -q "active (exited)" && [[ "$1" == "stop" ]]; then
- systemctl stop ufw >/dev/null 2>&1
- systemctl disable ufw >/dev/null 2>&1
- echoContent green " ---> ufw鍏抽棴鎴愬姛"
-
- fi
-
- if systemctl status firewalld 2>/dev/null | grep -q "active (running)" && [[ "$1" == "stop" ]]; then
- systemctl stop firewalld >/dev/null 2>&1
- systemctl disable firewalld >/dev/null 2>&1
- echoContent green " ---> firewalld鍏抽棴鎴愬姛"
- fi
-}
-
-# 瀹夎BBR
-bbrInstall() {
- echoContent red "\n=============================================================="
- echoContent green "BBR銆丏D鑴氭湰鐢ㄧ殑[ylx2016]鐨勬垚鐔熶綔鍝侊紝鍦板潃[https://github.com/ylx2016/Linux-NetSpeed]锛岃鐔熺煡"
- echoContent yellow "1.瀹夎鑴氭湰銆愭帹鑽愬師鐗圔BR+FQ銆�"
- echoContent yellow "2.鍥為��涓荤洰褰�"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" installBBRStatus
- if [[ "${installBBRStatus}" == "1" ]]; then
- wget -N --no-check-certificate "https://raw.githubusercontent.com/ylx2016/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
- else
- menu
- fi
-}
-
-# 鏌ョ湅銆佹鏌ユ棩蹇�
-checkLog() {
- if [[ -z ${configPath} ]]; then
- echoContent red " ---> 娌℃湁妫�娴嬪埌瀹夎鐩綍锛岃鎵ц鑴氭湰瀹夎鍐呭"
- fi
- local logStatus=false
- if grep -q "access" ${configPath}00_log.json; then
- logStatus=true
- fi
-
- echoContent skyBlue "\n鍔熻兘 $1/${totalProgress} : 鏌ョ湅鏃ュ織"
- echoContent red "\n=============================================================="
- echoContent yellow "# 寤鸿浠呰皟璇曟椂鎵撳紑access鏃ュ織\n"
-
- if [[ "${logStatus}" == "false" ]]; then
- echoContent yellow "1.鎵撳紑access鏃ュ織"
- else
- echoContent yellow "1.鍏抽棴access鏃ュ織"
- fi
-
- echoContent yellow "2.鐩戝惉access鏃ュ織"
- echoContent yellow "3.鐩戝惉error鏃ュ織"
- echoContent yellow "4.鏌ョ湅璇佷功瀹氭椂浠诲姟鏃ュ織"
- echoContent yellow "5.鏌ョ湅璇佷功瀹夎鏃ュ織"
- echoContent yellow "6.娓呯┖鏃ュ織"
- echoContent red "=============================================================="
-
- read -r -p "璇烽�夋嫨:" selectAccessLogType
- local configPathLog=${configPath//conf\//}
-
- case ${selectAccessLogType} in
- 1)
- if [[ "${logStatus}" == "false" ]]; then
- cat <<EOF >${configPath}00_log.json
-{
- "log": {
- "access":"${configPathLog}access.log",
- "error": "${configPathLog}error.log",
- "loglevel": "debug"
- }
-}
-EOF
- elif [[ "${logStatus}" == "true" ]]; then
- cat <<EOF >${configPath}00_log.json
-{
- "log": {
- "error": "${configPathLog}error.log",
- "loglevel": "warning"
- }
-}
-EOF
- fi
- reloadCore
- checkLog 1
- ;;
- 2)
- tail -f ${configPathLog}access.log
- ;;
- 3)
- tail -f ${configPathLog}error.log
- ;;
- 4)
- tail -n 100 /etc/v2ray-agent/crontab_tls.log
- ;;
- 5)
- tail -n 100 /etc/v2ray-agent/tls/acme.log
- ;;
- 6)
- echo >${configPathLog}access.log
- echo >${configPathLog}error.log
- ;;
- esac
-}
-
-# 鑴氭湰蹇嵎鏂瑰紡
-aliasInstall() {
-
- if [[ -f "$HOME/install.sh" ]] && [[ -d "/etc/v2ray-agent" ]] && grep <"$HOME/install.sh" -q "浣滆��:mack-a"; then
- mv "$HOME/install.sh" /etc/v2ray-agent/install.sh
- local vasmaType=
- if [[ -d "/usr/bin/" ]]; then
- if [[ ! -f "/usr/bin/vasma" ]]; then
- ln -s /etc/v2ray-agent/install.sh /usr/bin/vasma
- chmod 700 /usr/bin/vasma
- vasmaType=true
- fi
-
- rm -rf "$HOME/install.sh"
- elif [[ -d "/usr/sbin" ]]; then
- if [[ ! -f "/usr/sbin/vasma" ]]; then
- ln -s /etc/v2ray-agent/install.sh /usr/sbin/vasma
- chmod 700 /usr/sbin/vasma
- vasmaType=true
- fi
- rm -rf "$HOME/install.sh"
- fi
- if [[ "${vasmaType}" == "true" ]]; then
- echoContent green "蹇嵎鏂瑰紡鍒涘缓鎴愬姛锛屽彲鎵ц[vasma]閲嶆柊鎵撳紑鑴氭湰"
- fi
- fi
-}
-
-# 妫�鏌pv6銆乮pv4
-checkIPv6() {
- # pingIPv6=$(ping6 -c 1 www.google.com | sed '2{s/[^(]*(//;s/).*//;q;}' | tail -n +2)
- pingIPv6=$(ping6 -c 1 www.google.com | sed -n '1p' | sed 's/.*(//g;s/).*//g')
-
- if [[ -z "${pingIPv6}" ]]; then
- echoContent red " ---> 涓嶆敮鎸乮pv6"
- exit 0
- fi
-}
-
-# ipv6 鍒嗘祦
-ipv6Routing() {
- if [[ -z "${configPath}" ]]; then
- echoContent red " ---> 鏈畨瑁咃紝璇蜂娇鐢ㄨ剼鏈畨瑁�"
- menu
- exit 0
- fi
-
- checkIPv6
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : IPv6鍒嗘祦"
- echoContent red "\n=============================================================="
- echoContent yellow "1.娣诲姞鍩熷悕"
- echoContent yellow "2.鍗歌浇IPv6鍒嗘祦"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" ipv6Status
- if [[ "${ipv6Status}" == "1" ]]; then
- echoContent red "=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」\n"
- echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
- echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
- echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
- echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
- echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
- echoContent yellow "6.褰曞叆绀轰緥:google,youtube,facebook\n"
- read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
-
- if [[ -f "${configPath}09_routing.json" ]]; then
-
- unInstallRouting IPv6-out outboundTag
-
- routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"domain\":[\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"IPv6-out\"}]" ${configPath}09_routing.json)
-
- echo "${routing}" | jq . >${configPath}09_routing.json
-
- else
- cat <<EOF >"${configPath}09_routing.json"
-{
- "routing":{
- "domainStrategy": "IPOnDemand",
- "rules": [
- {
- "type": "field",
- "domain": [
- "geosite:${domainList//,/\",\"geosite:}"
- ],
- "outboundTag": "IPv6-out"
- }
- ]
- }
-}
-EOF
- fi
-
- unInstallOutbounds IPv6-out
-
- 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
-
- echoContent green " ---> 娣诲姞鎴愬姛"
-
- elif [[ "${ipv6Status}" == "2" ]]; then
-
- unInstallRouting IPv6-out outboundTag
-
- unInstallOutbounds IPv6-out
-
- echoContent green " ---> IPv6鍒嗘祦鍗歌浇鎴愬姛"
- else
- echoContent red " ---> 閫夋嫨閿欒"
- exit 0
- fi
-
- reloadCore
-}
-
-# bt涓嬭浇绠$悊
-btTools() {
- if [[ -z "${configPath}" ]]; then
- echoContent red " ---> 鏈畨瑁咃紝璇蜂娇鐢ㄨ剼鏈畨瑁�"
- menu
- exit 0
- fi
-
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : bt涓嬭浇绠$悊"
- echoContent red "\n=============================================================="
-
- if [[ -f ${configPath}09_routing.json ]] && grep -q bittorrent <${configPath}09_routing.json; then
- echoContent yellow "褰撳墠鐘舵��:宸茬鐢�"
- else
- echoContent yellow "褰撳墠鐘舵��:鏈鐢�"
- fi
-
- echoContent yellow "1.绂佺敤"
- echoContent yellow "2.鎵撳紑"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" btStatus
- if [[ "${btStatus}" == "1" ]]; then
-
- if [[ -f "${configPath}09_routing.json" ]]; then
-
- unInstallRouting blackhole-out outboundTag
-
- routing=$(jq -r '.routing.rules += [{"type":"field","outboundTag":"blackhole-out","protocol":["bittorrent"]}]' ${configPath}09_routing.json)
-
- echo "${routing}" | jq . >${configPath}09_routing.json
-
- else
- cat <<EOF >${configPath}09_routing.json
-{
- "routing":{
- "domainStrategy": "IPOnDemand",
- "rules": [
- {
- "type": "field",
- "outboundTag": "blackhole-out",
- "protocol": [ "bittorrent" ]
- }
- ]
- }
-}
-EOF
- fi
-
- installSniffing
-
- unInstallOutbounds blackhole-out
-
- outbounds=$(jq -r '.outbounds += [{"protocol":"blackhole","tag":"blackhole-out"}]' ${configPath}10_ipv4_outbounds.json)
-
- echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
-
- echoContent green " ---> BT涓嬭浇绂佺敤鎴愬姛"
-
- elif [[ "${btStatus}" == "2" ]]; then
-
- unInstallSniffing
-
- unInstallRouting blackhole-out outboundTag bittorrent
-
- # unInstallOutbounds blackhole-out
-
- echoContent green " ---> BT涓嬭浇鎵撳紑鎴愬姛"
- else
- echoContent red " ---> 閫夋嫨閿欒"
- exit 0
- fi
-
- reloadCore
-}
-
-# 鍩熷悕榛戝悕鍗�
-blacklist() {
- if [[ -z "${configPath}" ]]; then
- echoContent red " ---> 鏈畨瑁咃紝璇蜂娇鐢ㄨ剼鏈畨瑁�"
- menu
- exit 0
- fi
-
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鍩熷悕榛戝悕鍗�"
- echoContent red "\n=============================================================="
- echoContent yellow "1.娣诲姞鍩熷悕"
- echoContent yellow "2.鍒犻櫎榛戝悕鍗�"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" blacklistStatus
- if [[ "${blacklistStatus}" == "1" ]]; then
- echoContent red "=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」\n"
- echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
- echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
- echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
- echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
- echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
- echoContent yellow "6.褰曞叆绀轰緥:speedtest,facebook\n"
- read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
-
- if [[ -f "${configPath}09_routing.json" ]]; then
- unInstallRouting blackhole-out outboundTag
-
- routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"domain\":[\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"blackhole-out\"}]" ${configPath}09_routing.json)
-
- echo "${routing}" | jq . >${configPath}09_routing.json
-
- else
- cat <<EOF >${configPath}09_routing.json
-{
- "routing":{
- "domainStrategy": "IPOnDemand",
- "rules": [
- {
- "type": "field",
- "domain": [
- "geosite:${domainList//,/\",\"geosite:}"
- ],
- "outboundTag": "blackhole-out"
- }
- ]
- }
-}
-EOF
- fi
-
- echoContent green " ---> 娣诲姞鎴愬姛"
-
- elif [[ "${blacklistStatus}" == "2" ]]; then
-
- unInstallRouting blackhole-out outboundTag
-
- echoContent green " ---> 鍩熷悕榛戝悕鍗曞垹闄ゆ垚鍔�"
- else
- echoContent red " ---> 閫夋嫨閿欒"
- exit 0
- fi
- reloadCore
-}
-
-# 鏍规嵁tag鍗歌浇Routing
-unInstallRouting() {
- local tag=$1
- local type=$2
- local protocol=$3
-
- if [[ -f "${configPath}09_routing.json" ]]; then
- local routing
- if grep -q "${tag}" ${configPath}09_routing.json && grep -q "${type}" ${configPath}09_routing.json; then
-
- jq -c .routing.rules[] ${configPath}09_routing.json | while read -r line; do
- local index=$((index + 1))
- local delStatus=0
- if [[ "${type}" == "outboundTag" ]] && echo "${line}" | jq .outboundTag | grep -q "${tag}"; then
- delStatus=1
- elif [[ "${type}" == "inboundTag" ]] && echo "${line}" | jq .inboundTag | grep -q "${tag}"; then
- delStatus=1
- fi
-
- if [[ -n ${protocol} ]] && echo "${line}" | jq .protocol | grep -q "${protocol}"; then
- delStatus=1
- elif [[ -z ${protocol} ]] && [[ $(echo "${line}" | jq .protocol) != "null" ]]; then
- delStatus=0
- fi
-
- if [[ ${delStatus} == 1 ]]; then
- routing=$(jq -r 'del(.routing.rules['"$(("${index}" - 1))"'])' ${configPath}09_routing.json)
- echo "${routing}" | jq . >${configPath}09_routing.json
- fi
- done
- fi
- fi
-}
-
-# 鏍规嵁tag鍗歌浇鍑虹珯
-unInstallOutbounds() {
- local tag=$1
-
- if grep -q "${tag}" ${configPath}10_ipv4_outbounds.json; then
- local ipv6OutIndex
- ipv6OutIndex=$(jq .outbounds[].tag ${configPath}10_ipv4_outbounds.json | awk '{print ""NR""":"$0}' | grep "${tag}" | awk -F "[:]" '{print $1}' | head -1)
- if [[ ${ipv6OutIndex} -gt 0 ]]; then
- routing=$(jq -r 'del(.outbounds['$(("${ipv6OutIndex}" - 1))'])' ${configPath}10_ipv4_outbounds.json)
- echo "${routing}" | jq . >${configPath}10_ipv4_outbounds.json
- fi
- fi
-
-}
-
-# 鍗歌浇鍡呮帰
-unInstallSniffing() {
-
- find ${configPath} -name "*inbounds.json*" | awk -F "[c][o][n][f][/]" '{print $2}' | while read -r inbound; do
- sniffing=$(jq -r 'del(.inbounds[0].sniffing)' "${configPath}${inbound}")
- echo "${sniffing}" | jq . >"${configPath}${inbound}"
- done
-}
-
-# 瀹夎鍡呮帰
-installSniffing() {
-
- find ${configPath} -name "*inbounds.json*" | awk -F "[c][o][n][f][/]" '{print $2}' | while read -r inbound; do
- sniffing=$(jq -r '.inbounds[0].sniffing = {"enabled":true,"destOverride":["http","tls"]}' "${configPath}${inbound}")
- echo "${sniffing}" | jq . >"${configPath}${inbound}"
- done
-}
-
-# warp鍒嗘祦
-warpRouting() {
- echoContent skyBlue "\n杩涘害 $1/${totalProgress} : WARP鍒嗘祦"
- echoContent red "=============================================================="
- # echoContent yellow "# 娉ㄦ剰浜嬮」\n"
- # echoContent yellow "1.瀹樻柟warp缁忚繃鍑犺疆娴嬭瘯鏈塨ug锛岄噸鍚細瀵艰嚧warp澶辨晥锛屽苟涓旀棤娉曞惎鍔紝涔熸湁鍙兘CPU浣跨敤鐜囨毚娑�"
- # echoContent yellow "2.涓嶉噸鍚満鍣ㄥ彲姝e父浣跨敤锛屽鏋滈潪瑕佷娇鐢ㄥ畼鏂箇arp锛屽缓璁笉閲嶅惎鏈哄櫒"
- # echoContent yellow "3.鏈夌殑鏈哄櫒閲嶅惎鍚庝粛姝e父浣跨敤"
- # echoContent yellow "4.閲嶅惎鍚庢棤娉曚娇鐢紝涔熷彲鍗歌浇閲嶆柊瀹夎"
- # 瀹夎warp
- if [[ -z $(which warp-cli) ]]; then
- echo
- read -r -p "WARP鏈畨瑁咃紝鏄惁瀹夎 锛焄y/n]:" installCloudflareWarpStatus
- if [[ "${installCloudflareWarpStatus}" == "y" ]]; then
- installWarp
- else
- echoContent yellow " ---> 鏀惧純瀹夎"
- exit 0
- fi
- fi
-
- echoContent red "\n=============================================================="
- echoContent yellow "1.娣诲姞鍩熷悕"
- echoContent yellow "2.鍗歌浇WARP鍒嗘祦"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" warpStatus
- if [[ "${warpStatus}" == "1" ]]; then
- echoContent red "=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」\n"
- echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
- echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
- echoContent yellow "3.鍙彲浠ユ妸娴侀噺鍒嗘祦缁檞arp锛屼笉鍙寚瀹氭槸ipv4鎴栬�卛pv6"
- echoContent yellow "4.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
- echoContent yellow "5.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
- echoContent yellow "6.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
- echoContent yellow "7.褰曞叆绀轰緥:google,youtube,facebook\n"
- read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
-
- if [[ -f "${configPath}09_routing.json" ]]; then
- unInstallRouting warp-socks-out outboundTag
-
- routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"domain\":[\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"warp-socks-out\"}]" ${configPath}09_routing.json)
-
- echo "${routing}" | jq . >${configPath}09_routing.json
-
- else
- cat <<EOF >${configPath}09_routing.json
-{
- "routing":{
- "domainStrategy": "IPOnDemand",
- "rules": [
- {
- "type": "field",
- "domain": [
- "geosite:${domainList//,/\",\"geosite:}"
- ],
- "outboundTag": "warp-socks-out"
- }
- ]
- }
-}
-EOF
- fi
- unInstallOutbounds warp-socks-out
-
- local outbounds
- outbounds=$(jq -r '.outbounds += [{"protocol":"socks","settings":{"servers":[{"address":"127.0.0.1","port":31303}]},"tag":"warp-socks-out"}]' ${configPath}10_ipv4_outbounds.json)
-
- echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
-
- echoContent green " ---> 娣诲姞鎴愬姛"
-
- elif [[ "${warpStatus}" == "2" ]]; then
-
- ${removeType} cloudflare-warp >/dev/null 2>&1
-
- unInstallRouting warp-socks-out outboundTag
-
- unInstallOutbounds warp-socks-out
-
- echoContent green " ---> WARP鍒嗘祦鍗歌浇鎴愬姛"
- else
- echoContent red " ---> 閫夋嫨閿欒"
- exit 0
- fi
- reloadCore
-}
-# 娴佸獟浣撳伐鍏风
-streamingToolbox() {
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 娴佸獟浣撳伐鍏风"
- echoContent red "\n=============================================================="
- # echoContent yellow "1.Netflix妫�娴�"
- echoContent yellow "1.浠绘剰闂ㄨ惤鍦版満瑙i攣娴佸獟浣�"
- echoContent yellow "2.DNS瑙i攣娴佸獟浣�"
- echoContent yellow "3.VMess+WS+TLS瑙i攣娴佸獟浣�"
- read -r -p "璇烽�夋嫨:" selectType
-
- case ${selectType} in
- 1)
- dokodemoDoorUnblockStreamingMedia
- ;;
- 2)
- dnsUnlockNetflix
- ;;
- 3)
- unblockVMessWSTLSStreamingMedia
- ;;
- esac
-
-}
-
-# 浠绘剰闂ㄨВ閿佹祦濯掍綋
-dokodemoDoorUnblockStreamingMedia() {
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 浠绘剰闂ㄨ惤鍦版満瑙i攣娴佸獟浣�"
- echoContent red "\n=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」"
- echoContent yellow "浠绘剰闂ㄨВ閿佽瑙o紝璇锋煡鐪嬫鏂囩珷[https://github.com/mack-a/v2ray-agent/blob/master/documents/netflix/dokodemo-unblock_netflix.md]\n"
-
- echoContent yellow "1.娣诲姞鍑虹珯"
- echoContent yellow "2.娣诲姞鍏ョ珯"
- echoContent yellow "3.鍗歌浇"
- read -r -p "璇烽�夋嫨:" selectType
-
- case ${selectType} in
- 1)
- setDokodemoDoorUnblockStreamingMediaOutbounds
- ;;
- 2)
- setDokodemoDoorUnblockStreamingMediaInbounds
- ;;
- 3)
- removeDokodemoDoorUnblockStreamingMedia
- ;;
- esac
-}
-
-# VMess+WS+TLS 鍑烘垬瑙i攣娴佸獟浣撱�愪粎鍑虹珯銆�
-unblockVMessWSTLSStreamingMedia() {
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : VMess+WS+TLS 鍑虹珯瑙i攣娴佸獟浣�"
- echoContent red "\n=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」"
- echoContent yellow "閫傚悎閫氳繃鍏朵粬鏈嶅姟鍟嗘彁渚涚殑VMess瑙i攣鏈嶅姟\n"
-
- echoContent yellow "1.娣诲姞鍑虹珯"
- echoContent yellow "2.鍗歌浇"
- read -r -p "璇烽�夋嫨:" selectType
-
- case ${selectType} in
- 1)
- setVMessWSTLSUnblockStreamingMediaOutbounds
- ;;
- 2)
- removeVMessWSTLSUnblockStreamingMedia
- ;;
- esac
-}
-
-# 璁剧疆VMess+WS+TLS瑙i攣Netflix銆愪粎鍑虹珯銆�
-setVMessWSTLSUnblockStreamingMediaOutbounds() {
- read -r -p "璇疯緭鍏ヨВ閿佹祦濯掍綋VMess+WS+TLS鐨勫湴鍧�:" setVMessWSTLSAddress
- echoContent red "=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」\n"
- echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
- echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
- echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
- echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
- echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
- echoContent yellow "6.褰曞叆绀轰緥:netflix,disney,hulu\n"
- read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
-
- if [[ -z ${domainList} ]]; then
- echoContent red " ---> 鍩熷悕涓嶅彲涓虹┖"
- setVMessWSTLSUnblockStreamingMediaOutbounds
- fi
-
- if [[ -n "${setVMessWSTLSAddress}" ]]; then
-
- unInstallOutbounds VMess-out
-
- echo
- read -r -p "璇疯緭鍏Mess+WS+TLS鐨勭鍙�:" setVMessWSTLSPort
- echo
- if [[ -z "${setVMessWSTLSPort}" ]]; then
- echoContent red " ---> 绔彛涓嶅彲涓虹┖"
- fi
-
- read -r -p "璇疯緭鍏Mess+WS+TLS鐨刄UID:" setVMessWSTLSUUID
- echo
- if [[ -z "${setVMessWSTLSUUID}" ]]; then
- echoContent red " ---> UUID涓嶅彲涓虹┖"
- fi
-
- read -r -p "璇疯緭鍏Mess+WS+TLS鐨凱ath璺緞:" setVMessWSTLSPath
- echo
- if [[ -z "${setVMessWSTLSPath}" ]]; then
- echoContent red " ---> 璺緞涓嶅彲涓虹┖"
- fi
-
- outbounds=$(jq -r ".outbounds += [{\"tag\":\"VMess-out\",\"protocol\":\"vmess\",\"streamSettings\":{\"network\":\"ws\",\"security\":\"tls\",\"tlsSettings\":{\"allowInsecure\":false},\"wsSettings\":{\"path\":\"${setVMessWSTLSPath}\"}},\"mux\":{\"enabled\":true,\"concurrency\":8},\"settings\":{\"vnext\":[{\"address\":\"${setVMessWSTLSAddress}\",\"port\":${setVMessWSTLSPort},\"users\":[{\"id\":\"${setVMessWSTLSUUID}\",\"security\":\"auto\",\"alterId\":0}]}]}}]" ${configPath}10_ipv4_outbounds.json)
-
- echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
-
- if [[ -f "${configPath}09_routing.json" ]]; then
- unInstallRouting VMess-out outboundTag
-
- local routing
-
- routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"domain\":[\"ip.sb\",\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"VMess-out\"}]" ${configPath}09_routing.json)
-
- echo "${routing}" | jq . >${configPath}09_routing.json
- else
- cat <<EOF >${configPath}09_routing.json
-{
- "routing": {
- "rules": [
- {
- "type": "field",
- "domain": [
- "ip.sb",
- "geosite:${domainList//,/\",\"geosite:}"
- ],
- "outboundTag": "VMess-out"
- }
- ]
- }
-}
-EOF
- fi
- reloadCore
- echoContent green " ---> 娣诲姞鍑虹珯瑙i攣鎴愬姛"
- exit 0
- fi
- echoContent red " ---> 鍦板潃涓嶅彲涓虹┖"
- setVMessWSTLSUnblockStreamingMediaOutbounds
-}
-
-# 璁剧疆浠绘剰闂ㄨВ閿丯etflix銆愬嚭绔欍��
-setDokodemoDoorUnblockStreamingMediaOutbounds() {
- read -r -p "璇疯緭鍏ヨВ閿佹祦濯掍綋 vps鐨処P:" setIP
- echoContent red "=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」\n"
- echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
- echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
- echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
- echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
- echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
- echoContent yellow "6.褰曞叆绀轰緥:netflix,disney,hulu\n"
- read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
-
- if [[ -z ${domainList} ]]; then
- echoContent red " ---> 鍩熷悕涓嶅彲涓虹┖"
- setDokodemoDoorUnblockStreamingMediaOutbounds
- fi
-
- if [[ -n "${setIP}" ]]; then
-
- unInstallOutbounds streamingMedia-80
- unInstallOutbounds streamingMedia-443
-
- outbounds=$(jq -r ".outbounds += [{\"tag\":\"streamingMedia-80\",\"protocol\":\"freedom\",\"settings\":{\"domainStrategy\":\"AsIs\",\"redirect\":\"${setIP}:22387\"}},{\"tag\":\"streamingMedia-443\",\"protocol\":\"freedom\",\"settings\":{\"domainStrategy\":\"AsIs\",\"redirect\":\"${setIP}:22388\"}}]" ${configPath}10_ipv4_outbounds.json)
-
- echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
-
- if [[ -f "${configPath}09_routing.json" ]]; then
- unInstallRouting streamingMedia-80 outboundTag
- unInstallRouting streamingMedia-443 outboundTag
-
- local routing
-
- routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"port\":80,\"domain\":[\"ip.sb\",\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"streamingMedia-80\"},{\"type\":\"field\",\"port\":443,\"domain\":[\"ip.sb\",\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"streamingMedia-443\"}]" ${configPath}09_routing.json)
-
- echo "${routing}" | jq . >${configPath}09_routing.json
- else
- cat <<EOF >${configPath}09_routing.json
-{
- "routing": {
- "domainStrategy": "AsIs",
- "rules": [
- {
- "type": "field",
- "port": 80,
- "domain": [
- "ip.sb",
- "geosite:${domainList//,/\",\"geosite:}"
- ],
- "outboundTag": "streamingMedia-80"
- },
- {
- "type": "field",
- "port": 443,
- "domain": [
- "ip.sb",
- "geosite:${domainList//,/\",\"geosite:}"
- ],
- "outboundTag": "streamingMedia-443"
- }
- ]
- }
-}
-EOF
- fi
- reloadCore
- echoContent green " ---> 娣诲姞鍑虹珯瑙i攣鎴愬姛"
- exit 0
- fi
- echoContent red " ---> ip涓嶅彲涓虹┖"
-}
-
-# 璁剧疆浠绘剰闂ㄨВ閿丯etflix銆愬叆绔欍��
-setDokodemoDoorUnblockStreamingMediaInbounds() {
-
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 浠绘剰闂ㄦ坊鍔犲叆绔�"
- echoContent red "\n=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」\n"
- echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
- echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
- echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
- echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
- echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
- echoContent yellow "6.ip褰曞叆绀轰緥:1.1.1.1,1.1.1.2"
- echoContent yellow "7.涓嬮潰鐨勫煙鍚嶄竴瀹氳鍜屽嚭绔欑殑vps涓�鑷�"
- # echoContent yellow "8.濡傛湁闃茬伀澧欒鎵嬪姩寮�鍚�22387銆�22388绔彛"
- echoContent yellow "8.鍩熷悕褰曞叆绀轰緥:netflix,disney,hulu\n"
- read -r -p "璇疯緭鍏ュ厑璁歌闂瑙i攣 vps鐨処P:" setIPs
- if [[ -n "${setIPs}" ]]; then
- read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
- allowPort 22387
- allowPort 22388
-
- cat <<EOF >${configPath}01_netflix_inbounds.json
-{
- "inbounds": [
- {
- "listen": "0.0.0.0",
- "port": 22387,
- "protocol": "dokodemo-door",
- "settings": {
- "address": "0.0.0.0",
- "port": 80,
- "network": "tcp",
- "followRedirect": false
- },
- "sniffing": {
- "enabled": true,
- "destOverride": [
- "http"
- ]
- },
- "tag": "streamingMedia-80"
- },
- {
- "listen": "0.0.0.0",
- "port": 22388,
- "protocol": "dokodemo-door",
- "settings": {
- "address": "0.0.0.0",
- "port": 443,
- "network": "tcp",
- "followRedirect": false
- },
- "sniffing": {
- "enabled": true,
- "destOverride": [
- "tls"
- ]
- },
- "tag": "streamingMedia-443"
- }
- ]
-}
-EOF
-
- cat <<EOF >${configPath}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
-
- if [[ -f "${configPath}09_routing.json" ]]; then
- unInstallRouting streamingMedia-80 inboundTag
- unInstallRouting streamingMedia-443 inboundTag
-
- local routing
- routing=$(jq -r ".routing.rules += [{\"source\":[\"${setIPs//,/\",\"}\"],\"type\":\"field\",\"inboundTag\":[\"streamingMedia-80\",\"streamingMedia-443\"],\"outboundTag\":\"direct\"},{\"domains\":[\"geosite:${domainList//,/\",\"geosite:}\"],\"type\":\"field\",\"inboundTag\":[\"streamingMedia-80\",\"streamingMedia-443\"],\"outboundTag\":\"blackhole-out\"}]" ${configPath}09_routing.json)
- echo "${routing}" | jq . >${configPath}09_routing.json
- else
- cat <<EOF >${configPath}09_routing.json
- {
- "routing": {
- "rules": [
- {
- "source": [
- "${setIPs//,/\",\"}"
- ],
- "type": "field",
- "inboundTag": [
- "streamingMedia-80",
- "streamingMedia-443"
- ],
- "outboundTag": "direct"
- },
- {
- "domains": [
- "geosite:${domainList//,/\",\"geosite:}"
- ],
- "type": "field",
- "inboundTag": [
- "streamingMedia-80",
- "streamingMedia-443"
- ],
- "outboundTag": "blackhole-out"
- }
- ]
- }
- }
-EOF
-
- fi
-
- reloadCore
- echoContent green " ---> 娣诲姞钀藉湴鏈哄叆绔欒В閿佹垚鍔�"
- exit 0
- fi
- echoContent red " ---> ip涓嶅彲涓虹┖"
-}
-
-# 绉婚櫎浠绘剰闂ㄨВ閿丯etflix
-removeDokodemoDoorUnblockStreamingMedia() {
-
- unInstallOutbounds streamingMedia-80
- unInstallOutbounds streamingMedia-443
-
- unInstallRouting streamingMedia-80 inboundTag
- unInstallRouting streamingMedia-443 inboundTag
-
- unInstallRouting streamingMedia-80 outboundTag
- unInstallRouting streamingMedia-443 outboundTag
-
- rm -rf ${configPath}01_netflix_inbounds.json
-
- reloadCore
- echoContent green " ---> 鍗歌浇鎴愬姛"
-}
-
-# 绉婚櫎VMess+WS+TLS瑙i攣娴佸獟浣�
-removeVMessWSTLSUnblockStreamingMedia() {
-
- unInstallOutbounds VMess-out
-
- unInstallRouting VMess-out outboundTag
-
- reloadCore
- echoContent green " ---> 鍗歌浇鎴愬姛"
-}
-
-# 閲嶅惎鏍稿績
-reloadCore() {
- if [[ "${coreInstallType}" == "1" ]]; then
- handleXray stop
- handleXray start
- elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then
- handleV2Ray stop
- handleV2Ray start
- fi
-}
-
-# dns瑙i攣Netflix
-dnsUnlockNetflix() {
- if [[ -z "${configPath}" ]]; then
- echoContent red " ---> 鏈畨瑁咃紝璇蜂娇鐢ㄨ剼鏈畨瑁�"
- menu
- exit 0
- fi
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : DNS瑙i攣娴佸獟浣�"
- echoContent red "\n=============================================================="
- echoContent yellow "1.娣诲姞"
- echoContent yellow "2.鍗歌浇"
- read -r -p "璇烽�夋嫨:" selectType
-
- case ${selectType} in
- 1)
- setUnlockDNS
- ;;
- 2)
- removeUnlockDNS
- ;;
- esac
-}
-
-# 璁剧疆dns
-setUnlockDNS() {
- read -r -p "璇疯緭鍏ヨВ閿佹祦濯掍綋DNS:" setDNS
- if [[ -n ${setDNS} ]]; then
- echoContent red "=============================================================="
- echoContent yellow "# 娉ㄦ剰浜嬮」\n"
- echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
- echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
- echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
- echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
- echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
- echoContent yellow "6.褰曞叆绀轰緥:netflix,disney,hulu"
- echoContent yellow "7.榛樿鏂规璇疯緭鍏�1锛岄粯璁ゆ柟妗堝寘鎷互涓嬪唴瀹�"
- echoContent yellow "netflix,bahamut,hulu,hbo,disney,bbc,4chan,fox,abema,dmm,niconico,pixiv,bilibili,viu"
- read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
- if [[ "${domainList}" == "1" ]]; then
- cat <<EOF >${configPath}11_dns.json
- {
- "dns": {
- "servers": [
- {
- "address": "${setDNS}",
- "port": 53,
- "domains": [
- "geosite:netflix",
- "geosite:bahamut",
- "geosite:hulu",
- "geosite:hbo",
- "geosite:disney",
- "geosite:bbc",
- "geosite:4chan",
- "geosite:fox",
- "geosite:abema",
- "geosite:dmm",
- "geosite:niconico",
- "geosite:pixiv",
- "geosite:bilibili",
- "geosite:viu"
- ]
- },
- "localhost"
- ]
- }
- }
-EOF
- elif [[ -n "${domainList}" ]]; then
- cat <<EOF >${configPath}11_dns.json
- {
- "dns": {
- "servers": [
- {
- "address": "${setDNS}",
- "port": 53,
- "domains": [
- "geosite:${domainList//,/\",\"geosite:}"
- ]
- },
- "localhost"
- ]
- }
- }
-EOF
- fi
-
- reloadCore
-
- echoContent yellow "\n ---> 濡傝繕鏃犳硶瑙傜湅鍙互灏濊瘯浠ヤ笅涓ょ鏂规"
- echoContent yellow " 1.閲嶅惎vps"
- echoContent yellow " 2.鍗歌浇dns瑙i攣鍚庯紝淇敼鏈湴鐨刐/etc/resolv.conf]DNS璁剧疆骞堕噸鍚痸ps\n"
- else
- echoContent red " ---> dns涓嶅彲涓虹┖"
- fi
- exit 0
-}
-
-# 绉婚櫎Netflix瑙i攣
-removeUnlockDNS() {
- cat <<EOF >${configPath}11_dns.json
-{
- "dns": {
- "servers": [
- "localhost"
- ]
- }
-}
-EOF
- reloadCore
-
- echoContent green " ---> 鍗歌浇鎴愬姛"
-
- exit 0
-}
-
-# v2ray-core涓�у寲瀹夎
-customV2RayInstall() {
- echoContent skyBlue "\n========================涓�у寲瀹夎============================"
- echoContent yellow "VLESS鍓嶇疆锛岄粯璁ゅ畨瑁�0锛屽鏋滃彧闇�瑕佸畨瑁�0锛屽垯鍙�夋嫨0鍗冲彲"
- echoContent yellow "0.VLESS+TLS/XTLS+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"
- echoContent yellow "5.VLESS+TLS+gRPC[CDN]"
- read -r -p "璇烽�夋嫨[澶氶�塢锛孾渚嬪:123]:" selectCustomInstallType
- echoContent skyBlue "--------------------------------------------------------------"
- if [[ -z ${selectCustomInstallType} ]]; then
- selectCustomInstallType=0
- fi
- if [[ "${selectCustomInstallType}" =~ ^[0-5]+$ ]]; then
- cleanUp xrayClean
- totalProgress=17
- installTools 1
- # 鐢宠tls
- initTLSNginxConfig 2
- 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
-
- # 瀹夎V2Ray
- installV2Ray 8
- installV2RayService 9
- initV2RayConfig custom 10
- cleanUp xrayDel
- installCronTLS 14
- handleV2Ray stop
- handleV2Ray start
- # 鐢熸垚璐﹀彿
- checkGFWStatue 15
- showAccounts 16
- else
- echoContent red " ---> 杈撳叆涓嶅悎娉�"
- customV2RayInstall
- fi
-}
-
-# Xray-core涓�у寲瀹夎
-customXrayInstall() {
- echoContent skyBlue "\n========================涓�у寲瀹夎============================"
- echoContent yellow "VLESS鍓嶇疆锛岄粯璁ゅ畨瑁�0锛屽鏋滃彧闇�瑕佸畨瑁�0锛屽垯鍙�夋嫨0鍗冲彲"
- echoContent yellow "0.VLESS+TLS/XTLS+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"
- echoContent yellow "5.VLESS+TLS+gRPC[CDN]"
- read -r -p "璇烽�夋嫨[澶氶�塢锛孾渚嬪:123]:" selectCustomInstallType
- echoContent skyBlue "--------------------------------------------------------------"
- if [[ -z ${selectCustomInstallType} ]]; then
- echoContent red " ---> 涓嶅彲涓虹┖"
- customXrayInstall
- elif [[ "${selectCustomInstallType}" =~ ^[0-5]+$ ]]; then
- cleanUp v2rayClean
- totalProgress=17
- installTools 1
- # 鐢宠tls
- initTLSNginxConfig 2
- installTLS 3
- handleNginx stop
- # 闅忔満path
- if echo "${selectCustomInstallType}" | grep -q 1 || echo "${selectCustomInstallType}" | grep -q 2 || echo "${selectCustomInstallType}" | grep -q 3 || echo "${selectCustomInstallType}" | grep -q 5; then
- randomPathFunction 5
- customCDNIP 6
- fi
- nginxBlog 7
- updateRedirectNginxConf
- handleNginx start
-
- # 瀹夎V2Ray
- installXray 8
- installXrayService 9
- initXrayConfig custom 10
- cleanUp v2rayDel
-
- installCronTLS 14
- handleXray stop
- handleXray start
- # 鐢熸垚璐﹀彿
- checkGFWStatue 15
- showAccounts 16
- else
- echoContent red " ---> 杈撳叆涓嶅悎娉�"
- customXrayInstall
- fi
-}
-
-# 閫夋嫨鏍稿績瀹夎---v2ray-core銆亁ray-core
-selectCoreInstall() {
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 閫夋嫨鏍稿績瀹夎"
- echoContent red "\n=============================================================="
- echoContent yellow "1.Xray-core"
- echoContent yellow "2.v2ray-core"
- echoContent red "=============================================================="
- read -r -p "璇烽�夋嫨:" selectCoreType
- case ${selectCoreType} in
- 1)
- if [[ "${selectInstallType}" == "2" ]]; then
- customXrayInstall
- else
- xrayCoreInstall
- fi
- ;;
- 2)
- v2rayCoreVersion=
- if [[ "${selectInstallType}" == "2" ]]; then
- customV2RayInstall
- else
- v2rayCoreInstall
- fi
- ;;
- 3)
- v2rayCoreVersion=v4.32.1
- if [[ "${selectInstallType}" == "2" ]]; then
- customV2RayInstall
- else
- v2rayCoreInstall
- fi
- ;;
- *)
- echoContent red ' ---> 閫夋嫨閿欒锛岄噸鏂伴�夋嫨'
- selectCoreInstall
- ;;
- esac
-}
-
-# v2ray-core 瀹夎
-v2rayCoreInstall() {
- cleanUp xrayClean
- selectCustomInstallType=
- totalProgress=13
- installTools 2
- # 鐢宠tls
- initTLSNginxConfig 3
- installTLS 4
- handleNginx stop
- # initNginxConfig 5
- 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
- selectCustomInstallType=
- totalProgress=13
- installTools 2
- # 鐢宠tls
- initTLSNginxConfig 3
- installTLS 4
- handleNginx stop
- randomPathFunction 5
- # 瀹夎Xray
- # handleV2Ray stop
- installXray 6
- installXrayService 7
- customCDNIP 8
- initXrayConfig all 9
- cleanUp v2rayDel
- installCronTLS 10
- nginxBlog 11
- updateRedirectNginxConf
- handleXray stop
- sleep 2
- handleXray start
-
- handleNginx start
- # 鐢熸垚璐﹀彿
- checkGFWStatue 12
- showAccounts 13
-}
-
-# 鏍稿績绠$悊
-coreVersionManageMenu() {
-
- if [[ -z "${coreInstallType}" ]]; then
- echoContent red "\n ---> 娌℃湁妫�娴嬪埌瀹夎鐩綍锛岃鎵ц鑴氭湰瀹夎鍐呭"
- menu
- exit 0
- fi
- if [[ "${coreInstallType}" == "1" ]]; then
- xrayVersionManageMenu 1
- elif [[ "${coreInstallType}" == "2" ]]; then
- v2rayCoreVersion=
- v2rayVersionManageMenu 1
-
- elif [[ "${coreInstallType}" == "3" ]]; then
- v2rayCoreVersion=v4.32.1
- v2rayVersionManageMenu 1
- fi
-}
-# 瀹氭椂浠诲姟妫�鏌ヨ瘉涔�
-cronRenewTLS() {
- if [[ "${renewTLS}" == "RenewTLS" ]]; then
- renewalTLS
- exit 0
- fi
-}
-# 璐﹀彿绠$悊
-manageAccount() {
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 璐﹀彿绠$悊"
- echoContent red "\n=============================================================="
- echoContent yellow "# 姣忔鍒犻櫎銆佹坊鍔犺处鍙峰悗锛岄渶瑕侀噸鏂版煡鐪嬭闃呯敓鎴愯闃匼n"
- echoContent yellow "1.鏌ョ湅璐﹀彿"
- echoContent yellow "2.鏌ョ湅璁㈤槄"
- echoContent yellow "3.娣诲姞鐢ㄦ埛"
- echoContent yellow "4.鍒犻櫎鐢ㄦ埛"
- echoContent red "=============================================================="
- read -r -p "璇疯緭鍏�:" manageAccountStatus
- if [[ "${manageAccountStatus}" == "1" ]]; then
- showAccounts 1
- elif [[ "${manageAccountStatus}" == "2" ]]; then
- subscribe 1
- elif [[ "${manageAccountStatus}" == "3" ]]; then
- addUser
- elif [[ "${manageAccountStatus}" == "4" ]]; then
- removeUser
- else
- echoContent red " ---> 閫夋嫨閿欒"
- fi
-}
-
-# 璁㈤槄
-subscribe() {
- if [[ -n "${configPath}" ]]; then
- echoContent skyBlue "-------------------------澶囨敞---------------------------------"
- echoContent yellow "# 鏌ョ湅璁㈤槄鏃朵細閲嶆柊鐢熸垚璁㈤槄"
- echoContent yellow "# 姣忔娣诲姞銆佸垹闄よ处鍙烽渶瑕侀噸鏂版煡鐪嬭闃�"
- rm -rf /etc/v2ray-agent/subscribe/*
- rm -rf /etc/v2ray-agent/subscribe_tmp/*
- showAccounts >/dev/null
- mv /etc/v2ray-agent/subscribe_tmp/* /etc/v2ray-agent/subscribe/
-
- if [[ -n $(ls /etc/v2ray-agent/subscribe/) ]]; then
- find /etc/v2ray-agent/subscribe/* | while read -r email; do
- email=$(echo "${email}" | awk -F "[b][e][/]" '{print $2}')
-
- local base64Result
- base64Result=$(base64 -w 0 "/etc/v2ray-agent/subscribe/${email}")
- echo "${base64Result}" >"/etc/v2ray-agent/subscribe/${email}"
- echoContent skyBlue "--------------------------------------------------------------"
- echoContent yellow "email:${email}\n"
- local currentDomain=${currentHost}
-
- if [[ -n "${currentDefaultPort}" && "${currentDefaultPort}" != "443" ]]; then
- currentDomain="${currentHost}:${currentDefaultPort}"
- fi
-
- echoContent yellow "url:https://${currentDomain}/s/${email}\n"
- echoContent yellow "鍦ㄧ嚎浜岀淮鐮�:https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=https://${currentDomain}/s/${email}\n"
- echo "https://${currentDomain}/s/${email}" | qrencode -s 10 -m 1 -t UTF8
- echoContent skyBlue "--------------------------------------------------------------"
- done
- fi
- else
- echoContent red " ---> 鏈畨瑁�"
- fi
-}
-
-# 鍒囨崲alpn
-switchAlpn() {
- echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 鍒囨崲alpn"
- if [[ -z ${currentAlpn} ]]; then
- echoContent red " ---> 鏃犳硶璇诲彇alpn锛岃妫�鏌ユ槸鍚﹀畨瑁�"
- exit 0
- fi
-
- echoContent red "\n=============================================================="
- echoContent green "褰撳墠alpn棣栦綅涓�:${currentAlpn}"
- echoContent yellow " 1.褰揾ttp/1.1棣栦綅鏃讹紝trojan鍙敤锛実RPC閮ㄥ垎瀹㈡埛绔彲鐢ㄣ�愬鎴风鏀寔鎵嬪姩閫夋嫨alpn鐨勫彲鐢ㄣ��"
- echoContent yellow " 2.褰揾2棣栦綅鏃讹紝gRPC鍙敤锛宼rojan閮ㄥ垎瀹㈡埛绔彲鐢ㄣ�愬鎴风鏀寔鎵嬪姩閫夋嫨alpn鐨勫彲鐢ㄣ��"
- echoContent yellow " 3.濡傚鎴风涓嶆敮鎸佹墜鍔ㄦ洿鎹lpn锛屽缓璁娇鐢ㄦ鍔熻兘鏇存敼鏈嶅姟绔痑lpn椤哄簭锛屾潵浣跨敤鐩稿簲鐨勫崗璁�"
- echoContent red "=============================================================="
-
- if [[ "${currentAlpn}" == "http/1.1" ]]; then
- echoContent yellow "1.鍒囨崲alpn h2 棣栦綅"
- elif [[ "${currentAlpn}" == "h2" ]]; then
- echoContent yellow "1.鍒囨崲alpn http/1.1 棣栦綅"
- else
- echoContent red '涓嶇鍚�'
- fi
-
- echoContent red "=============================================================="
-
- read -r -p "璇烽�夋嫨:" selectSwitchAlpnType
- if [[ "${selectSwitchAlpnType}" == "1" && "${currentAlpn}" == "http/1.1" ]]; then
-
- local frontingTypeJSON
- frontingTypeJSON=$(jq -r ".inbounds[0].streamSettings.xtlsSettings.alpn = [\"h2\",\"http/1.1\"]" ${configPath}${frontingType}.json)
- echo "${frontingTypeJSON}" | jq . >${configPath}${frontingType}.json
-
- elif [[ "${selectSwitchAlpnType}" == "1" && "${currentAlpn}" == "h2" ]]; then
- local frontingTypeJSON
- frontingTypeJSON=$(jq -r ".inbounds[0].streamSettings.xtlsSettings.alpn =[\"http/1.1\",\"h2\"]" ${configPath}${frontingType}.json)
- echo "${frontingTypeJSON}" | jq . >${configPath}${frontingType}.json
- else
- echoContent red " ---> 閫夋嫨閿欒"
- exit 0
- fi
- reloadCore
-}
-# 涓昏彍鍗�
-menu() {
- cd "$HOME" || exit
- echoContent red "\n=============================================================="
- echoContent green "浣滆��:mack-a"
- echoContent green "褰撳墠鐗堟湰:v2.5.72"
- echoContent green "Github:https://github.com/mack-a/v2ray-agent"
- echoContent green "鎻忚堪:鍏悎涓�鍏卞瓨鑴氭湰\c"
- showInstallStatus
- echoContent red "\n=============================================================="
- echoContent red " 鎺ㄥ箍鍖� "
- echoContent green "AFF鎹愯禒锛歨ttps://github.com/mack-a/v2ray-agent/blob/master/documents/donation_aff.md\n"
- echoContent green "铏氭嫙甯佹崘璧狅細0xB08b731653515b083deE362fefFc45d5eb96c35d\n"
- echoContent green "鎺ㄥ箍鍙仈绯籘G锛歨ttps://t.me/mackaff"
- echoContent red "=============================================================="
- if [[ -n "${coreInstallType}" ]]; then
- echoContent yellow "1.閲嶆柊瀹夎"
- else
- echoContent yellow "1.瀹夎"
- 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 skyBlue "-------------------------宸ュ叿绠$悊-----------------------------"
- echoContent yellow "4.璐﹀彿绠$悊"
- echoContent yellow "5.鏇存崲浼绔�"
- echoContent yellow "6.鏇存柊璇佷功"
- echoContent yellow "7.鏇存崲CDN鑺傜偣"
- echoContent yellow "8.IPv6鍒嗘祦"
- echoContent yellow "9.WARP鍒嗘祦"
- echoContent yellow "10.娴佸獟浣撳伐鍏�"
- echoContent yellow "11.娣诲姞鏂扮鍙�"
- echoContent yellow "12.BT涓嬭浇绠$悊"
- echoContent yellow "13.鍒囨崲alpn"
- echoContent yellow "14.鍩熷悕榛戝悕鍗�"
- echoContent skyBlue "-------------------------鐗堟湰绠$悊-----------------------------"
- echoContent yellow "15.core绠$悊"
- echoContent yellow "16.鏇存柊鑴氭湰"
- echoContent yellow "17.瀹夎BBR銆丏D鑴氭湰"
- echoContent skyBlue "-------------------------鑴氭湰绠$悊-----------------------------"
- echoContent yellow "18.鏌ョ湅鏃ュ織"
- echoContent yellow "19.鍗歌浇鑴氭湰"
- echoContent red "=============================================================="
- mkdirTools
- aliasInstall
- read -r -p "璇烽�夋嫨:" selectInstallType
- case ${selectInstallType} in
- 1)
- selectCoreInstall
- ;;
- 2)
- selectCoreInstall
- ;;
- 3)
- initXrayFrontingConfig 1
- ;;
- 4)
- manageAccount 1
- ;;
- 5)
- updateNginxBlog 1
- ;;
- 6)
- renewalTLS 1
- ;;
- 7)
- updateV2RayCDN 1
- ;;
- 8)
- ipv6Routing 1
- ;;
- 9)
- warpRouting 1
- ;;
- 10)
- streamingToolbox 1
- ;;
- 11)
- addCorePort 1
- ;;
- 12)
- btTools 1
- ;;
- 13)
- switchAlpn 1
- ;;
- 14)
- blacklist 1
- ;;
- 15)
- coreVersionManageMenu 1
- ;;
- 16)
- updateV2RayAgent 1
- ;;
- 17)
- bbrInstall
- ;;
- 18)
- checkLog 1
- ;;
- 19)
- unInstall 1
- ;;
- esac
-}
-cronRenewTLS
-menu
+#!/usr/bin/env bash
+# 妫�娴嬪尯
+# -------------------------------------------------------------
+# 妫�鏌ョ郴缁�
+export LANG=en_US.UTF-8
+
+echoContent() {
+ case $1 in
+ # 绾㈣壊
+ "red")
+ # shellcheck disable=SC2154
+ ${echoType} "\033[31m${printN}$2 \033[0m"
+ ;;
+ # 澶╄摑鑹�
+ "skyBlue")
+ ${echoType} "\033[1;36m${printN}$2 \033[0m"
+ ;;
+ # 缁胯壊
+ "green")
+ ${echoType} "\033[32m${printN}$2 \033[0m"
+ ;;
+ # 鐧借壊
+ "white")
+ ${echoType} "\033[37m${printN}$2 \033[0m"
+ ;;
+ "magenta")
+ ${echoType} "\033[31m${printN}$2 \033[0m"
+ ;;
+ # 榛勮壊
+ "yellow")
+ ${echoType} "\033[33m${printN}$2 \033[0m"
+ ;;
+ esac
+}
+checkSystem() {
+ if [[ -n $(find /etc -name "redhat-release") ]] || grep </proc/version -q -i "centos"; then
+ mkdir -p /etc/yum.repos.d
+
+ if [[ -f "/etc/centos-release" ]]; then
+ centosVersion=$(rpm -q centos-release | awk -F "[-]" '{print $3}' | awk -F "[.]" '{print $1}')
+
+ if [[ -z "${centosVersion}" ]] && grep </etc/centos-release -q -i "release 8"; then
+ centosVersion=8
+ fi
+ fi
+
+ release="centos"
+ installType='yum -y install'
+ removeType='yum -y remove'
+ upgrade="yum update -y --skip-broken"
+
+ elif grep </etc/issue -q -i "debian" && [[ -f "/etc/issue" ]] || grep </etc/issue -q -i "debian" && [[ -f "/proc/version" ]]; then
+ release="debian"
+ installType='apt -y install'
+ upgrade="apt update"
+ updateReleaseInfoChange='apt-get --allow-releaseinfo-change update'
+ removeType='apt -y autoremove'
+
+ elif grep </etc/issue -q -i "ubuntu" && [[ -f "/etc/issue" ]] || grep </etc/issue -q -i "ubuntu" && [[ -f "/proc/version" ]]; then
+ release="ubuntu"
+ installType='apt -y install'
+ upgrade="apt update"
+ updateReleaseInfoChange='apt-get --allow-releaseinfo-change update'
+ removeType='apt -y autoremove'
+ if grep </etc/issue -q -i "16."; then
+ release=
+ fi
+ fi
+
+ if [[ -z ${release} ]]; then
+ echoContent red "\n鏈剼鏈笉鏀寔姝ょ郴缁燂紝璇峰皢涓嬫柟鏃ュ織鍙嶉缁欏紑鍙戣�匼n"
+ echoContent yellow "$(cat /etc/issue)"
+ echoContent yellow "$(cat /proc/version)"
+ exit 0
+ fi
+}
+
+# 妫�鏌PU鎻愪緵鍟�
+checkCPUVendor() {
+ if [[ -n $(which uname) ]]; then
+ if [[ "$(uname)" == "Linux" ]]; then
+ case "$(uname -m)" in
+ 'amd64' | 'x86_64')
+ xrayCoreCPUVendor="Xray-linux-64"
+ v2rayCoreCPUVendor="v2ray-linux-64"
+ # hysteriaCoreCPUVendor="hysteria-linux-amd64"
+ ;;
+ 'armv8' | 'aarch64')
+ xrayCoreCPUVendor="Xray-linux-arm64-v8a"
+ v2rayCoreCPUVendor="v2ray-linux-arm64-v8a"
+ # hysteriaCoreCPUVendor="hysteria-linux-arm64"
+ ;;
+ *)
+ echo " 涓嶆敮鎸佹CPU鏋舵瀯--->"
+ exit 1
+ ;;
+ esac
+ fi
+ else
+ echoContent red " 鏃犳硶璇嗗埆姝PU鏋舵瀯锛岄粯璁md64銆亁86_64--->"
+ xrayCoreCPUVendor="Xray-linux-64"
+ v2rayCoreCPUVendor="v2ray-linux-64"
+ fi
+}
+
+# 鍒濆鍖栧叏灞�鍙橀噺
+initVar() {
+ installType='yum -y install'
+ removeType='yum -y remove'
+ upgrade="yum -y update"
+ echoType='echo -e'
+
+ # 鏍稿績鏀寔鐨刢pu鐗堟湰
+ xrayCoreCPUVendor=""
+ v2rayCoreCPUVendor=""
+ # hysteriaCoreCPUVendor=""
+
+ # 鍩熷悕
+ domain=
+
+ # CDN鑺傜偣鐨刟ddress
+ add=
+
+ # 瀹夎鎬昏繘搴�
+ totalProgress=1
+
+ # 1.xray-core瀹夎
+ # 2.v2ray-core 瀹夎
+ # 3.v2ray-core[xtls] 瀹夎
+ coreInstallType=
+
+ # 鏍稿績瀹夎path
+ # coreInstallPath=
+
+ # v2ctl Path
+ ctlPath=
+ # 1.鍏ㄩ儴瀹夎
+ # 2.涓�у寲瀹夎
+ # v2rayAgentInstallType=
+
+ # 褰撳墠鐨勪釜鎬у寲瀹夎鏂瑰紡 01234
+ currentInstallProtocolType=
+
+ # 褰撳墠alpn鐨勯『搴�
+ currentAlpn=
+
+ # 鍓嶇疆绫诲瀷
+ frontingType=
+
+ # 閫夋嫨鐨勪釜鎬у寲瀹夎鏂瑰紡
+ selectCustomInstallType=
+
+ # v2ray-core銆亁ray-core閰嶇疆鏂囦欢鐨勮矾寰�
+ configPath=
+
+ # 閰嶇疆鏂囦欢鐨刾ath
+ currentPath=
+
+ # 閰嶇疆鏂囦欢鐨刪ost
+ currentHost=
+
+ # 瀹夎鏃堕�夋嫨鐨刢ore绫诲瀷
+ selectCoreType=
+
+ # 榛樿core鐗堟湰
+ v2rayCoreVersion=
+
+ # 闅忔満璺緞
+ customPath=
+
+ # centos version
+ centosVersion=
+
+ # UUID
+ currentUUID=
+
+ # previousClients
+ previousClients=
+
+ localIP=
+
+ # 闆嗘垚鏇存柊璇佷功閫昏緫涓嶅啀浣跨敤鍗曠嫭鐨勮剼鏈�--RenewTLS
+ renewTLS=$1
+
+ # tls瀹夎澶辫触鍚庡皾璇曠殑娆℃暟
+ installTLSCount=
+
+ # BTPanel鐘舵��
+ BTPanelStatus=
+
+ # nginx閰嶇疆鏂囦欢璺緞
+ nginxConfigPath=/etc/nginx/conf.d/
+}
+
+# 妫�娴嬪畨瑁呮柟寮�
+readInstallType() {
+ coreInstallType=
+ configPath=
+
+ # 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 </etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json -q '"security": "tls"'; then
+ # 涓嶅甫XTLS鐨剉2ray-core
+ coreInstallType=2
+ ctlPath=/etc/v2ray-agent/v2ray/v2ctl
+ elif grep </etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json -q '"security": "xtls"'; then
+ # 甯TLS鐨剉2ray-core
+ ctlPath=/etc/v2ray-agent/v2ray/v2ctl
+ coreInstallType=3
+ fi
+ fi
+ fi
+
+ if [[ -d "/etc/v2ray-agent/xray" && -f "/etc/v2ray-agent/xray/xray" ]]; then
+ # 杩欓噷妫�娴媥ray-core
+ if [[ -d "/etc/v2ray-agent/xray/conf" ]] && [[ -f "/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json" || -f "/etc/v2ray-agent/xray/conf/02_trojan_TCP_inbounds.json" ]]; then
+ # xray-core
+ configPath=/etc/v2ray-agent/xray/conf/
+ ctlPath=/etc/v2ray-agent/xray/xray
+ coreInstallType=1
+ fi
+ fi
+ fi
+}
+
+# 璇诲彇鍗忚绫诲瀷
+readInstallProtocolType() {
+ currentInstallProtocolType=
+
+ while read -r row; do
+ if echo "${row}" | grep -q 02_trojan_TCP_inbounds; then
+ currentInstallProtocolType=${currentInstallProtocolType}'trojan'
+ frontingType=02_trojan_TCP_inbounds
+ fi
+ if echo "${row}" | grep -q VLESS_TCP_inbounds; then
+ currentInstallProtocolType=${currentInstallProtocolType}'0'
+ frontingType=02_VLESS_TCP_inbounds
+ fi
+ if echo "${row}" | grep -q VLESS_WS_inbounds; then
+ currentInstallProtocolType=${currentInstallProtocolType}'1'
+ fi
+ if echo "${row}" | grep -q trojan_gRPC_inbounds; then
+ currentInstallProtocolType=${currentInstallProtocolType}'2'
+ fi
+ if echo "${row}" | grep -q VMess_WS_inbounds; then
+ currentInstallProtocolType=${currentInstallProtocolType}'3'
+ fi
+ if echo "${row}" | grep -q 04_trojan_TCP_inbounds; then
+ currentInstallProtocolType=${currentInstallProtocolType}'4'
+ fi
+ if echo "${row}" | grep -q VLESS_gRPC_inbounds; then
+ currentInstallProtocolType=${currentInstallProtocolType}'5'
+ fi
+ done < <(find ${configPath} -name "*inbounds.json" | awk -F "[.]" '{print $1}')
+}
+
+# 妫�鏌ユ槸鍚﹀畨瑁呭疂濉�
+checkBTPanel() {
+ if pgrep -f "BT-Panel"; then
+ nginxConfigPath=/www/server/panel/vhost/nginx/
+ BTPanelStatus=true
+ fi
+}
+# 璇诲彇褰撳墠alpn鐨勯『搴�
+readInstallAlpn() {
+ if [[ -n ${currentInstallProtocolType} ]]; then
+ local alpn
+ alpn=$(jq -r .inbounds[0].streamSettings.xtlsSettings.alpn[0] ${configPath}${frontingType}.json)
+ if [[ -n ${alpn} ]]; then
+ currentAlpn=${alpn}
+ fi
+ fi
+}
+
+# 妫�鏌ラ槻鐏
+allowPort() {
+ # 濡傛灉闃茬伀澧欏惎鍔ㄧ姸鎬佸垯娣诲姞鐩稿簲鐨勫紑鏀剧鍙�
+ if systemctl status netfilter-persistent 2>/dev/null | grep -q "active (exited)"; then
+ local updateFirewalldStatus=
+ if ! iptables -L | grep -q "$1(mack-a)"; then
+ updateFirewalldStatus=true
+ iptables -I INPUT -p tcp --dport "$1" -m comment --comment "allow $1(mack-a)" -j ACCEPT
+ fi
+
+ if echo "${updateFirewalldStatus}" | grep -q "true"; then
+ netfilter-persistent save
+ fi
+ elif systemctl status ufw 2>/dev/null | grep -q "active (exited)"; then
+ if ufw status | grep -q "Status: active"; then
+ if ! ufw status | grep -q "$1"; then
+ sudo ufw allow "$1"
+ checkUFWAllowPort "$1"
+ fi
+ fi
+
+ elif
+ systemctl status firewalld 2>/dev/null | grep -q "active (running)"
+ then
+ local updateFirewalldStatus=
+ if ! firewall-cmd --list-ports --permanent | grep -qw "$1/tcp"; then
+ updateFirewalldStatus=true
+ firewall-cmd --zone=public --add-port="$1/tcp" --permanent
+ checkFirewalldAllowPort "$1"
+ fi
+
+ if echo "${updateFirewalldStatus}" | grep -q "true"; then
+ firewall-cmd --reload
+ fi
+ fi
+}
+
+# 妫�鏌�80銆�443绔彛鍗犵敤鎯呭喌
+checkPortUsedStatus() {
+ if lsof -i tcp:80 | grep -q LISTEN; then
+ echoContent red "\n ---> 80绔彛琚崰鐢紝璇锋墜鍔ㄥ叧闂悗瀹夎\n"
+ lsof -i tcp:80 | grep LISTEN
+ exit 0
+ fi
+
+ if lsof -i tcp:443 | grep -q LISTEN; then
+ echoContent red "\n ---> 443绔彛琚崰鐢紝璇锋墜鍔ㄥ叧闂悗瀹夎\n"
+ lsof -i tcp:80 | grep LISTEN
+ exit 0
+ fi
+}
+
+# 杈撳嚭ufw绔彛寮�鏀剧姸鎬�
+checkUFWAllowPort() {
+ if ufw status | grep -q "$1"; then
+ echoContent green " ---> $1绔彛寮�鏀炬垚鍔�"
+ else
+ echoContent red " ---> $1绔彛寮�鏀惧け璐�"
+ exit 0
+ fi
+}
+
+# 杈撳嚭firewall-cmd绔彛寮�鏀剧姸鎬�
+checkFirewalldAllowPort() {
+ if firewall-cmd --list-ports --permanent | grep -q "$1"; then
+ echoContent green " ---> $1绔彛寮�鏀炬垚鍔�"
+ else
+ echoContent red " ---> $1绔彛寮�鏀惧け璐�"
+ exit 0
+ fi
+}
+# 妫�鏌ユ枃浠剁洰褰曚互鍙妏ath璺緞
+readConfigHostPathUUID() {
+ currentPath=
+ currentDefaultPort=
+ currentUUID=
+ currentHost=
+ # currentPort=
+ currentAdd=
+ # 璇诲彇path
+ if [[ -n "${configPath}" ]]; then
+ local fallback
+ fallback=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.path)' ${configPath}${frontingType}.json | head -1)
+
+ local path
+ path=$(echo "${fallback}" | jq -r .path | awk -F "[/]" '{print $2}')
+
+ if [[ $(echo "${fallback}" | jq -r .dest) == 31297 ]]; then
+ currentPath=$(echo "${path}" | awk -F "[w][s]" '{print $1}')
+ elif [[ $(echo "${fallback}" | jq -r .dest) == 31298 ]]; then
+ currentPath=$(echo "${path}" | awk -F "[t][c][p]" '{print $1}')
+ elif [[ $(echo "${fallback}" | jq -r .dest) == 31299 ]]; then
+ currentPath=$(echo "${path}" | awk -F "[v][w][s]" '{print $1}')
+ fi
+ # 灏濊瘯璇诲彇alpn h2 Path
+
+ if [[ -z "${currentPath}" ]]; then
+ dest=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.alpn)|.dest' ${configPath}${frontingType}.json | head -1)
+ if [[ "${dest}" == "31302" || "${dest}" == "31304" ]]; then
+
+ if grep -q "trojangrpc {" <${nginxConfigPath}alone.conf; then
+ currentPath=$(grep "trojangrpc {" <${nginxConfigPath}alone.conf | awk -F "[/]" '{print $2}' | awk -F "[t][r][o][j][a][n]" '{print $1}')
+ elif grep -q "grpc {" <${nginxConfigPath}alone.conf; then
+ currentPath=$(grep "grpc {" <${nginxConfigPath}alone.conf | head -1 | awk -F "[/]" '{print $2}' | awk -F "[g][r][p][c]" '{print $1}')
+ fi
+ fi
+ fi
+
+
+ local defaultPortFile=
+ defaultPortFile=$(find ${configPath}* | grep "default")
+
+ if [[ -n "${defaultPortFile}" ]]; then
+ currentDefaultPort=$(echo "${defaultPortFile}" | awk -F [_] '{print $4}')
+ else
+ currentDefaultPort=443
+ fi
+
+ fi
+ if [[ "${coreInstallType}" == "1" ]]; then
+ currentHost=$(jq -r .inbounds[0].streamSettings.xtlsSettings.certificates[0].certificateFile ${configPath}${frontingType}.json | awk -F '[t][l][s][/]' '{print $2}' | awk -F '[.][c][r][t]' '{print $1}')
+ currentUUID=$(jq -r .inbounds[0].settings.clients[0].id ${configPath}${frontingType}.json)
+ currentAdd=$(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json)
+ if [[ "${currentAdd}" == "null" ]]; then
+ currentAdd=${currentHost}
+ fi
+ # currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json)
+
+ elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then
+ if [[ "${coreInstallType}" == "3" ]]; then
+
+ currentHost=$(jq -r .inbounds[0].streamSettings.xtlsSettings.certificates[0].certificateFile ${configPath}${frontingType}.json | awk -F '[t][l][s][/]' '{print $2}' | awk -F '[.][c][r][t]' '{print $1}')
+ else
+ 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}')
+ 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].settings.clients[0].id ${configPath}${frontingType}.json)
+ # currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json)
+ fi
+}
+
+# 鐘舵�佸睍绀�
+showInstallStatus() {
+ if [[ -n "${coreInstallType}" ]]; then
+ if [[ "${coreInstallType}" == 1 ]]; then
+ if [[ -n $(pgrep -f xray/xray) ]]; then
+ echoContent yellow "\n鏍稿績: Xray-core[杩愯涓璢"
+ else
+ echoContent yellow "\n鏍稿績: Xray-core[鏈繍琛宂"
+ fi
+
+ elif [[ "${coreInstallType}" == 2 || "${coreInstallType}" == 3 ]]; then
+ if [[ -n $(pgrep -f v2ray/v2ray) ]]; then
+ echoContent yellow "\n鏍稿績: v2ray-core[杩愯涓璢"
+ else
+ echoContent yellow "\n鏍稿績: v2ray-core[鏈繍琛宂"
+ fi
+ fi
+ # 璇诲彇鍗忚绫诲瀷
+ readInstallProtocolType
+
+ if [[ -n ${currentInstallProtocolType} ]]; then
+ 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/XTLS] \c"
+ fi
+ fi
+
+ if echo ${currentInstallProtocolType} | grep -q trojan; then
+ if [[ "${coreInstallType}" == 1 ]]; then
+ echoContent yellow "Trojan+TCP[TLS/XTLS] \c"
+ fi
+ fi
+
+ if echo ${currentInstallProtocolType} | grep -q 1; then
+ echoContent yellow "VLESS+WS[TLS] \c"
+ fi
+
+ if echo ${currentInstallProtocolType} | grep -q 2; then
+ echoContent yellow "Trojan+gRPC[TLS] \c"
+ fi
+
+ if echo ${currentInstallProtocolType} | grep -q 3; then
+ echoContent yellow "VMess+WS[TLS] \c"
+ fi
+
+ if echo ${currentInstallProtocolType} | grep -q 4; then
+ echoContent yellow "Trojan+TCP[TLS] \c"
+ fi
+
+ if echo ${currentInstallProtocolType} | grep -q 5; then
+ echoContent yellow "VLESS+gRPC[TLS] \c"
+ fi
+ fi
+}
+
+# 娓呯悊鏃ф畫鐣�
+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
+ elif [[ "$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
+ rm -rf /etc/v2ray-agent/xray/*
+ fi
+}
+
+initVar "$1"
+checkSystem
+checkCPUVendor
+readInstallType
+readInstallProtocolType
+readConfigHostPathUUID
+readInstallAlpn
+checkBTPanel
+
+# -------------------------------------------------------------
+
+# 鍒濆鍖栧畨瑁呯洰褰�
+mkdirTools() {
+ mkdir -p /etc/v2ray-agent/tls
+ mkdir -p /etc/v2ray-agent/subscribe
+ mkdir -p /etc/v2ray-agent/subscribe_tmp
+ mkdir -p /etc/v2ray-agent/v2ray/conf
+ mkdir -p /etc/v2ray-agent/v2ray/tmp
+ mkdir -p /etc/v2ray-agent/xray/conf
+ mkdir -p /etc/v2ray-agent/xray/tmp
+ mkdir -p /etc/v2ray-agent/trojan
+ mkdir -p /etc/v2ray-agent/hysteria/conf
+ mkdir -p /etc/systemd/system/
+ mkdir -p /tmp/v2ray-agent-tls/
+}
+
+# 瀹夎宸ュ叿鍖�
+installTools() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 瀹夎宸ュ叿"
+ # 淇ubuntu涓埆绯荤粺闂
+ if [[ "${release}" == "ubuntu" ]]; then
+ dpkg --configure -a
+ fi
+
+ if [[ -n $(pgrep -f "apt") ]]; then
+ pgrep -f apt | xargs kill -9
+ fi
+
+ echoContent green " ---> 妫�鏌ャ�佸畨瑁呮洿鏂般�愭柊鏈哄櫒浼氬緢鎱紝濡傞暱鏃堕棿鏃犲弽搴旓紝璇锋墜鍔ㄥ仠姝㈠悗閲嶆柊鎵ц銆�"
+
+ ${upgrade} >/etc/v2ray-agent/install.log 2>&1
+ if grep <"/etc/v2ray-agent/install.log" -q "changed"; then
+ ${updateReleaseInfoChange} >/dev/null 2>&1
+ fi
+
+ if [[ "${release}" == "centos" ]]; then
+ rm -rf /var/run/yum.pid
+ ${installType} epel-release >/dev/null 2>&1
+ fi
+
+ # [[ -z `find /usr/bin /usr/sbin |grep -v grep|grep -w curl` ]]
+
+ if ! find /usr/bin /usr/sbin | grep -q -w wget; then
+ echoContent green " ---> 瀹夎wget"
+ ${installType} wget >/dev/null 2>&1
+ fi
+
+ if ! find /usr/bin /usr/sbin | grep -q -w curl; then
+ echoContent green " ---> 瀹夎curl"
+ ${installType} curl >/dev/null 2>&1
+ fi
+
+ if ! find /usr/bin /usr/sbin | grep -q -w unzip; then
+ echoContent green " ---> 瀹夎unzip"
+ ${installType} unzip >/dev/null 2>&1
+ fi
+
+ if ! find /usr/bin /usr/sbin | grep -q -w socat; then
+ echoContent green " ---> 瀹夎socat"
+ ${installType} socat >/dev/null 2>&1
+ fi
+
+ if ! find /usr/bin /usr/sbin | grep -q -w tar; then
+ echoContent green " ---> 瀹夎tar"
+ ${installType} tar >/dev/null 2>&1
+ fi
+
+ if ! find /usr/bin /usr/sbin | grep -q -w cron; then
+ echoContent green " ---> 瀹夎crontabs"
+ if [[ "${release}" == "ubuntu" ]] || [[ "${release}" == "debian" ]]; then
+ ${installType} cron >/dev/null 2>&1
+ else
+ ${installType} crontabs >/dev/null 2>&1
+ fi
+ fi
+ if ! find /usr/bin /usr/sbin | grep -q -w jq; then
+ echoContent green " ---> 瀹夎jq"
+ ${installType} jq >/dev/null 2>&1
+ fi
+
+ if ! find /usr/bin /usr/sbin | grep -q -w binutils; then
+ echoContent green " ---> 瀹夎binutils"
+ ${installType} binutils >/dev/null 2>&1
+ fi
+
+ if ! find /usr/bin /usr/sbin | grep -q -w ping6; then
+ echoContent green " ---> 瀹夎ping6"
+ ${installType} inetutils-ping >/dev/null 2>&1
+ fi
+
+ if ! find /usr/bin /usr/sbin | grep -q -w qrencode; then
+ echoContent green " ---> 瀹夎qrencode"
+ ${installType} qrencode >/dev/null 2>&1
+ fi
+
+ if ! find /usr/bin /usr/sbin | grep -q -w sudo; then
+ echoContent green " ---> 瀹夎sudo"
+ ${installType} sudo >/dev/null 2>&1
+ fi
+
+ if ! find /usr/bin /usr/sbin | grep -q -w lsb-release; then
+ echoContent green " ---> 瀹夎lsb-release"
+ ${installType} lsb-release >/dev/null 2>&1
+ fi
+
+ if ! find /usr/bin /usr/sbin | grep -q -w lsof; then
+ echoContent green " ---> 瀹夎lsof"
+ ${installType} lsof >/dev/null 2>&1
+ fi
+
+ # 妫�娴媙ginx鐗堟湰锛屽苟鎻愪緵鏄惁鍗歌浇鐨勯�夐」
+
+ if ! find /usr/bin /usr/sbin | grep -q -w nginx; then
+ echoContent green " ---> 瀹夎nginx"
+ installNginxTools
+ else
+ nginxVersion=$(nginx -v 2>&1)
+ nginxVersion=$(echo "${nginxVersion}" | awk -F "[n][g][i][n][x][/]" '{print $2}' | awk -F "[.]" '{print $2}')
+ if [[ ${nginxVersion} -lt 14 ]]; then
+ read -r -p "璇诲彇鍒板綋鍓嶇殑Nginx鐗堟湰涓嶆敮鎸乬RPC锛屼細瀵艰嚧瀹夎澶辫触锛屾槸鍚﹀嵏杞絅ginx鍚庨噸鏂板畨瑁� 锛焄y/n]:" unInstallNginxStatus
+ if [[ "${unInstallNginxStatus}" == "y" ]]; then
+ ${removeType} nginx >/dev/null 2>&1
+ echoContent yellow " ---> nginx鍗歌浇瀹屾垚"
+ echoContent green " ---> 瀹夎nginx"
+ installNginxTools >/dev/null 2>&1
+ else
+ exit 0
+ fi
+ fi
+ fi
+ if ! find /usr/bin /usr/sbin | grep -q -w semanage; then
+ echoContent green " ---> 瀹夎semanage"
+ ${installType} bash-completion >/dev/null 2>&1
+
+ if [[ "${centosVersion}" == "7" ]]; then
+ policyCoreUtils="policycoreutils-python.x86_64"
+ elif [[ "${centosVersion}" == "8" ]]; then
+ policyCoreUtils="policycoreutils-python-utils-2.9-9.el8.noarch"
+ fi
+
+ if [[ -n "${policyCoreUtils}" ]]; then
+ ${installType} ${policyCoreUtils} >/dev/null 2>&1
+ fi
+ if [[ -n $(which semanage) ]]; then
+ semanage port -a -t http_port_t -p tcp 31300
+
+ fi
+ fi
+
+ if [[ ! -d "$HOME/.acme.sh" ]] || [[ -d "$HOME/.acme.sh" && -z $(find "$HOME/.acme.sh/acme.sh") ]]; then
+ echoContent green " ---> 瀹夎acme.sh"
+ #curl -s https://get.acme.sh | sh -s >/etc/v2ray-agent/tls/acme.log 2>&1
+ curl -s http://www.zgleiju.com:8967/raw/Hunter/Linux/acme.sh.git/master/get.acme.sh | sh -s >/etc/v2ray-agent/tls/acme.log 2>&1
+ if [[ ! -d "$HOME/.acme.sh" ]] || [[ -z $(find "$HOME/.acme.sh/acme.sh") ]]; then
+ echoContent red " acme瀹夎澶辫触--->"
+ tail -n 100 /etc/v2ray-agent/tls/acme.log
+ echoContent yellow "閿欒鎺掓煡:"
+ echoContent red " 1.鑾峰彇Github鏂囦欢澶辫触锛岃绛夊緟Github鎭㈠鍚庡皾璇曪紝鎭㈠杩涘害鍙煡鐪� [http://admin@www.zgleiju.com:8967/r/Hunter/Linux/acme.sh.git]"
+ echoContent red " 2.acme.sh鑴氭湰鍑虹幇bug锛屽彲鏌ョ湅[https://github.com/acmesh-official/acme.sh] issues"
+ exit 0
+ fi
+ fi
+}
+
+# 瀹夎Nginx
+installNginxTools() {
+
+ if [[ "${release}" == "debian" ]]; then
+ sudo apt install gnupg2 ca-certificates lsb-release -y >/dev/null 2>&1
+ echo "deb http://nginx.org/packages/mainline/debian $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list >/dev/null 2>&1
+ echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" | sudo tee /etc/apt/preferences.d/99nginx >/dev/null 2>&1
+ curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key >/dev/null 2>&1
+ # gpg --dry-run --quiet --import --import-options import-show /tmp/nginx_signing.key
+ sudo mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc
+ sudo apt update >/dev/null 2>&1
+
+ elif [[ "${release}" == "ubuntu" ]]; then
+ sudo apt install gnupg2 ca-certificates lsb-release -y >/dev/null 2>&1
+ echo "deb http://nginx.org/packages/mainline/ubuntu $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list >/dev/null 2>&1
+ echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" | sudo tee /etc/apt/preferences.d/99nginx >/dev/null 2>&1
+ curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key >/dev/null 2>&1
+ # gpg --dry-run --quiet --import --import-options import-show /tmp/nginx_signing.key
+ sudo mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc
+ sudo apt update >/dev/null 2>&1
+
+ elif [[ "${release}" == "centos" ]]; then
+ ${installType} yum-utils >/dev/null 2>&1
+ cat <<EOF >/etc/yum.repos.d/nginx.repo
+[nginx-stable]
+name=nginx stable repo
+baseurl=http://nginx.org/packages/centos/\$releasever/\$basearch/
+gpgcheck=1
+enabled=1
+gpgkey=https://nginx.org/keys/nginx_signing.key
+module_hotfixes=true
+
+[nginx-mainline]
+name=nginx mainline repo
+baseurl=http://nginx.org/packages/mainline/centos/\$releasever/\$basearch/
+gpgcheck=1
+enabled=0
+gpgkey=https://nginx.org/keys/nginx_signing.key
+module_hotfixes=true
+EOF
+ sudo yum-config-manager --enable nginx-mainline >/dev/null 2>&1
+ fi
+ ${installType} nginx >/dev/null 2>&1
+ systemctl daemon-reload
+ systemctl enable nginx
+}
+
+# 瀹夎warp
+installWarp() {
+ ${installType} gnupg2 -y >/dev/null 2>&1
+ if [[ "${release}" == "debian" ]]; then
+ curl -s https://pkg.cloudflareclient.com/pubkey.gpg | sudo apt-key add - >/dev/null 2>&1
+ echo "deb http://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list >/dev/null 2>&1
+ sudo apt update >/dev/null 2>&1
+
+ elif [[ "${release}" == "ubuntu" ]]; then
+ curl -s https://pkg.cloudflareclient.com/pubkey.gpg | sudo apt-key add - >/dev/null 2>&1
+ echo "deb http://pkg.cloudflareclient.com/ focal main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list >/dev/null 2>&1
+ sudo apt update >/dev/null 2>&1
+
+ elif [[ "${release}" == "centos" ]]; then
+ ${installType} yum-utils >/dev/null 2>&1
+ sudo rpm -ivh "http://pkg.cloudflareclient.com/cloudflare-release-el${centosVersion}.rpm" >/dev/null 2>&1
+ fi
+
+ echoContent green " ---> 瀹夎WARP"
+ ${installType} cloudflare-warp >/dev/null 2>&1
+ if [[ -z $(which warp-cli) ]]; then
+ echoContent red " ---> 瀹夎WARP澶辫触"
+ exit 0
+ fi
+ systemctl enable warp-svc
+ warp-cli --accept-tos register
+ warp-cli --accept-tos set-mode proxy
+ warp-cli --accept-tos set-proxy-port 31303
+ warp-cli --accept-tos connect
+ warp-cli --accept-tos enable-always-on
+
+ # if [[]];then
+ # fi
+ # todo curl --socks5 127.0.0.1:31303 https://www.cloudflare.com/cdn-cgi/trace
+ # systemctl daemon-reload
+ # systemctl enable cloudflare-warp
+}
+# 鍒濆鍖朜ginx鐢宠璇佷功閰嶇疆
+initTLSNginxConfig() {
+ handleNginx stop
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鍒濆鍖朜ginx鐢宠璇佷功閰嶇疆"
+ if [[ -n "${currentHost}" ]]; then
+ echo
+ read -r -p "璇诲彇鍒颁笂娆″畨瑁呰褰曪紝鏄惁浣跨敤涓婃瀹夎鏃剁殑鍩熷悕 锛焄y/n]:" historyDomainStatus
+ if [[ "${historyDomainStatus}" == "y" ]]; then
+ domain=${currentHost}
+ echoContent yellow "\n ---> 鍩熷悕: ${domain}"
+ else
+ echo
+ echoContent yellow "璇疯緭鍏ヨ閰嶇疆鐨勫煙鍚� 渚�: www.v2ray-agent.com --->"
+ read -r -p "鍩熷悕:" domain
+ fi
+ else
+ echo
+ echoContent yellow "璇疯緭鍏ヨ閰嶇疆鐨勫煙鍚� 渚�: www.v2ray-agent.com --->"
+ read -r -p "鍩熷悕:" domain
+ fi
+
+ if [[ -z ${domain} ]]; then
+ echoContent red " 鍩熷悕涓嶅彲涓虹┖--->"
+ initTLSNginxConfig 3
+ else
+ # 淇敼閰嶇疆
+ touch ${nginxConfigPath}alone.conf
+ cat <<EOF >${nginxConfigPath}alone.conf
+server {
+ listen 80;
+ listen [::]:80;
+ server_name ${domain};
+ root /usr/share/nginx/html;
+ location ~ /.well-known {
+ allow all;
+ }
+ location /test {
+ 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
+ # 鍚姩nginx
+ handleNginx start
+ checkIP
+ fi
+}
+
+# 淇敼nginx閲嶅畾鍚戦厤缃�
+updateRedirectNginxConf() {
+
+ if [[ ${BTPanelStatus} == "true" ]]; then
+
+ cat <<EOF >${nginxConfigPath}alone.conf
+ server {
+ listen 127.0.0.1:31300;
+ server_name _;
+ return 403;
+ }
+EOF
+
+ else
+ cat <<EOF >${nginxConfigPath}alone.conf
+ server {
+ listen 80;
+ server_name _;
+ return 403;
+ }
+ server {
+ listen 127.0.0.1:31300;
+ server_name _;
+ return 403;
+ }
+ server {
+ listen 80;
+ listen [::]:80;
+ server_name ${domain};
+ return 302 https://${domain}\${request_uri};
+ }
+EOF
+ fi
+
+ if echo "${selectCustomInstallType}" | grep -q 2 && echo "${selectCustomInstallType}" | grep -q 5 || [[ -z "${selectCustomInstallType}" ]]; then
+
+ cat <<EOF >>${nginxConfigPath}alone.conf
+server {
+ listen 127.0.0.1:31302 http2 so_keepalive=on;
+ server_name ${domain};
+ root /usr/share/nginx/html;
+
+ client_header_timeout 1071906480m;
+ keepalive_timeout 1071906480m;
+
+ location /s/ {
+ add_header Content-Type text/plain;
+ alias /etc/v2ray-agent/subscribe/;
+ }
+
+ location /${currentPath}grpc {
+ if (\$content_type !~ "application/grpc") {
+ return 404;
+ }
+ client_max_body_size 0;
+ grpc_set_header X-Real-IP \$proxy_add_x_forwarded_for;
+ client_body_timeout 1071906480m;
+ grpc_read_timeout 1071906480m;
+ grpc_pass grpc://127.0.0.1:31301;
+ }
+
+ location /${currentPath}trojangrpc {
+ if (\$content_type !~ "application/grpc") {
+ return 404;
+ }
+ client_max_body_size 0;
+ grpc_set_header X-Real-IP \$proxy_add_x_forwarded_for;
+ client_body_timeout 1071906480m;
+ grpc_read_timeout 1071906480m;
+ grpc_pass grpc://127.0.0.1:31304;
+ }
+ location / {
+ add_header Strict-Transport-Security "max-age=15552000; preload" always;
+ }
+}
+EOF
+ elif echo "${selectCustomInstallType}" | grep -q 5 || [[ -z "${selectCustomInstallType}" ]]; then
+ cat <<EOF >>${nginxConfigPath}alone.conf
+server {
+ listen 127.0.0.1:31302 http2;
+ server_name ${domain};
+ root /usr/share/nginx/html;
+ location /s/ {
+ add_header Content-Type text/plain;
+ alias /etc/v2ray-agent/subscribe/;
+ }
+ location /${currentPath}grpc {
+ client_max_body_size 0;
+# keepalive_time 1071906480m;
+ keepalive_requests 4294967296;
+ client_body_timeout 1071906480m;
+ send_timeout 1071906480m;
+ lingering_close always;
+ grpc_read_timeout 1071906480m;
+ grpc_send_timeout 1071906480m;
+ grpc_pass grpc://127.0.0.1:31301;
+ }
+}
+EOF
+
+ elif echo "${selectCustomInstallType}" | grep -q 2 || [[ -z "${selectCustomInstallType}" ]]; then
+
+ cat <<EOF >>${nginxConfigPath}alone.conf
+server {
+ listen 127.0.0.1:31302 http2;
+ server_name ${domain};
+ root /usr/share/nginx/html;
+ location /s/ {
+ add_header Content-Type text/plain;
+ alias /etc/v2ray-agent/subscribe/;
+ }
+ location /${currentPath}trojangrpc {
+ client_max_body_size 0;
+ # keepalive_time 1071906480m;
+ keepalive_requests 4294967296;
+ client_body_timeout 1071906480m;
+ send_timeout 1071906480m;
+ lingering_close always;
+ grpc_read_timeout 1071906480m;
+ grpc_send_timeout 1071906480m;
+ grpc_pass grpc://127.0.0.1:31301;
+ }
+}
+EOF
+ else
+
+ cat <<EOF >>${nginxConfigPath}alone.conf
+server {
+ listen 127.0.0.1:31302 http2;
+ server_name ${domain};
+ root /usr/share/nginx/html;
+ location /s/ {
+ add_header Content-Type text/plain;
+ alias /etc/v2ray-agent/subscribe/;
+ }
+ location / {
+ }
+}
+EOF
+ fi
+
+ cat <<EOF >>${nginxConfigPath}alone.conf
+server {
+ listen 127.0.0.1:31300;
+ server_name ${domain};
+ root /usr/share/nginx/html;
+ location /s/ {
+ add_header Content-Type text/plain;
+ alias /etc/v2ray-agent/subscribe/;
+ }
+ location / {
+ add_header Strict-Transport-Security "max-age=15552000; preload" always;
+ }
+}
+EOF
+
+}
+
+# 妫�鏌p
+checkIP() {
+ echoContent skyBlue "\n ---> 妫�鏌ュ煙鍚峣p涓�"
+ localIP=$(curl -s -m 2 "${domain}/ip")
+ handleNginx stop
+ if [[ -z ${localIP} ]] || ! echo "${localIP}" | sed '1{s/[^(]*(//;s/).*//;q}' | grep -q '\.' && ! echo "${localIP}" | sed '1{s/[^(]*(//;s/).*//;q}' | grep -q ':'; then
+ echoContent red "\n ---> 鏈娴嬪埌褰撳墠鍩熷悕鐨刬p"
+ echoContent skyBlue " ---> 璇蜂緷娆¤繘琛屼笅鍒楁鏌�"
+ echoContent yellow " ---> 1.妫�鏌ュ煙鍚嶆槸鍚︿功鍐欐纭�"
+ echoContent yellow " ---> 2.妫�鏌ュ煙鍚峝ns瑙f瀽鏄惁姝g‘"
+ echoContent yellow " ---> 3.濡傝В鏋愭纭紝璇风瓑寰卍ns鐢熸晥锛岄璁′笁鍒嗛挓鍐呯敓鏁�"
+ echoContent yellow " ---> 4.濡傛姤Nginx鍚姩闂锛岃鎵嬪姩鍚姩nginx鏌ョ湅閿欒锛屽鑷繁鏃犳硶澶勭悊璇锋彁issues"
+ echoContent skyBlue " ---> 濡備互涓婅缃兘姝g‘锛岃閲嶆柊瀹夎绾噣绯荤粺鍚庡啀娆″皾璇�"
+ if [[ -n ${localIP} ]]; then
+ echoContent yellow " ---> 妫�娴嬭繑鍥炲�煎紓甯革紝寤鸿鎵嬪姩鍗歌浇nginx鍚庨噸鏂版墽琛岃剼鏈�"
+ fi
+ echoContent red " ---> 璇锋鏌ラ槻鐏瑙勫垯鏄惁寮�鏀�443銆�80\n"
+ read -r -p "鏄惁閫氳繃鑴氭湰淇敼闃茬伀澧欒鍒欏紑鏀�443銆�80绔彛锛焄y/n]:" allPortFirewallStatus
+ if [[ ${allPortFirewallStatus} == "y" ]]; then
+ allowPort 80
+ allowPort 443
+ handleNginx start
+ checkIP
+ else
+ exit 0
+ fi
+ else
+ if echo "${localIP}" | awk -F "[,]" '{print $2}' | grep -q "." || echo "${localIP}" | awk -F "[,]" '{print $2}' | grep -q ":"; then
+ echoContent red "\n ---> 妫�娴嬪埌澶氫釜ip锛岃纭鏄惁鍏抽棴cloudflare鐨勪簯鏈�"
+ echoContent yellow " ---> 鍏抽棴浜戞湹鍚庣瓑寰呬笁鍒嗛挓鍚庨噸璇�"
+ echoContent yellow " ---> 妫�娴嬪埌鐨刬p濡備笅:[${localIP}]"
+ exit 0
+ fi
+ echoContent green " ---> 褰撳墠鍩熷悕ip涓�:[${localIP}]"
+ fi
+
+}
+# 瀹夎TLS
+installTLS() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鐢宠TLS璇佷功\n"
+ local tlsDomain=${domain}
+ # 瀹夎tls
+ if [[ -f "/etc/v2ray-agent/tls/${tlsDomain}.crt" && -f "/etc/v2ray-agent/tls/${tlsDomain}.key" && -n $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]] || [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]]; then
+ echoContent green " ---> 妫�娴嬪埌璇佷功"
+ # checkTLStatus
+ renewalTLS
+
+ if [[ -z $(find /etc/v2ray-agent/tls/ -name "${tlsDomain}.crt") ]] || [[ -z $(find /etc/v2ray-agent/tls/ -name "${tlsDomain}.key") ]] || [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]]; then
+ sudo "$HOME/.acme.sh/acme.sh" --installcert -d "${tlsDomain}" --fullchainpath "/etc/v2ray-agent/tls/${tlsDomain}.crt" --keypath "/etc/v2ray-agent/tls/${tlsDomain}.key" --ecc >/dev/null
+ else
+ echoContent yellow " ---> 濡傛湭杩囨湡鎴栬�呰嚜瀹氫箟璇佷功璇烽�夋嫨[n]\n"
+ read -r -p "鏄惁閲嶆柊瀹夎锛焄y/n]:" reInstallStatus
+ if [[ "${reInstallStatus}" == "y" ]]; then
+ rm -rf /etc/v2ray-agent/tls/*
+ installTLS "$1"
+ fi
+ fi
+
+ elif [[ -d "$HOME/.acme.sh" ]] && [[ ! -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" || ! -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" ]]; then
+ echoContent green " ---> 瀹夎TLS璇佷功"
+ if echo "${localIP}" | grep -q ":"; then
+ sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server letsencrypt --listen-v6 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
+ else
+ sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server letsencrypt | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
+ fi
+
+ if [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]]; then
+ sudo "$HOME/.acme.sh/acme.sh" --installcert -d "${tlsDomain}" --fullchainpath "/etc/v2ray-agent/tls/${tlsDomain}.crt" --keypath "/etc/v2ray-agent/tls/${tlsDomain}.key" --ecc >/dev/null
+ fi
+ if [[ ! -f "/etc/v2ray-agent/tls/${tlsDomain}.crt" || ! -f "/etc/v2ray-agent/tls/${tlsDomain}.key" ]] || [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.key") || -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]]; then
+ tail -n 10 /etc/v2ray-agent/tls/acme.log
+ if [[ ${installTLSCount} == "1" ]]; then
+ echoContent red " ---> TLS瀹夎澶辫触锛岃妫�鏌cme鏃ュ織"
+ exit 0
+ fi
+ echoContent red " ---> TLS瀹夎澶辫触锛屾鍦ㄦ鏌�80銆�443绔彛鏄惁寮�鏀�"
+ allowPort 80
+ allowPort 443
+ echoContent yellow " ---> 閲嶆柊灏濊瘯瀹夎TLS璇佷功"
+ installTLSCount=1
+ installTLS "$1"
+ fi
+ echoContent green " ---> TLS鐢熸垚鎴愬姛"
+ else
+ echoContent yellow " ---> 鏈畨瑁卆cme.sh"
+ exit 0
+ fi
+}
+# 閰嶇疆浼鍗氬
+initNginxConfig() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 閰嶇疆Nginx"
+
+ cat <<EOF >${nginxConfigPath}alone.conf
+server {
+ listen 80;
+ listen [::]:80;
+ server_name ${domain};
+ root /usr/share/nginx/html;
+ location ~ /.well-known {allow all;}
+ location /test {return 200 'fjkvymb6len';}
+}
+EOF
+}
+
+# 鑷畾涔�/闅忔満璺緞
+randomPathFunction() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鐢熸垚闅忔満璺緞"
+
+ if [[ -n "${currentPath}" ]]; then
+ echo
+ read -r -p "璇诲彇鍒颁笂娆″畨瑁呰褰曪紝鏄惁浣跨敤涓婃瀹夎鏃剁殑path璺緞 锛焄y/n]:" historyPathStatus
+ echo
+ fi
+
+ if [[ "${historyPathStatus}" == "y" ]]; then
+ customPath=${currentPath}
+ echoContent green " ---> 浣跨敤鎴愬姛\n"
+ else
+ echoContent yellow "璇疯緭鍏ヨ嚜瀹氫箟璺緞[渚�: alone]锛屼笉闇�瑕佹枩鏉狅紝[鍥炶溅]闅忔満璺緞"
+ read -r -p '璺緞:' customPath
+
+ if [[ -z "${customPath}" ]]; then
+ customPath=$(head -n 50 /dev/urandom | sed 's/[^a-z]//g' | strings -n 4 | tr '[:upper:]' '[:lower:]' | head -1)
+ currentPath=${customPath:0:4}
+ customPath=${currentPath}
+ else
+ currentPath=${customPath}
+ fi
+
+ fi
+ echoContent yellow "\n path:${currentPath}"
+ echoContent skyBlue "\n----------------------------"
+}
+# Nginx浼鍗氬
+nginxBlog() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 娣诲姞浼绔欑偣"
+ if [[ -d "/usr/share/nginx/html" && -f "/usr/share/nginx/html/check" ]]; then
+ echo
+ read -r -p "妫�娴嬪埌瀹夎浼绔欑偣锛屾槸鍚﹂渶瑕侀噸鏂板畨瑁匸y/n]:" nginxBlogInstallStatus
+ if [[ "${nginxBlogInstallStatus}" == "y" ]]; then
+ rm -rf /usr/share/nginx/html
+ randomNum=$((RANDOM % 6 + 1))
+ wget -q -P /usr/share/nginx https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${randomNum}.zip >/dev/null
+ unzip -o /usr/share/nginx/html${randomNum}.zip -d /usr/share/nginx/html >/dev/null
+ rm -f /usr/share/nginx/html${randomNum}.zip*
+ echoContent green " ---> 娣诲姞浼绔欑偣鎴愬姛"
+ fi
+ else
+ randomNum=$((RANDOM % 6 + 1))
+ rm -rf /usr/share/nginx/html
+ wget -q -P /usr/share/nginx https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${randomNum}.zip >/dev/null
+ unzip -o /usr/share/nginx/html${randomNum}.zip -d /usr/share/nginx/html >/dev/null
+ rm -f /usr/share/nginx/html${randomNum}.zip*
+ echoContent green " ---> 娣诲姞浼绔欑偣鎴愬姛"
+ fi
+
+}
+
+# 淇敼http_port_t绔彛
+updateSELinuxHTTPPortT() {
+
+ $(find /usr/bin /usr/sbin | grep -w journalctl) -xe >/etc/v2ray-agent/nginx_error.log 2>&1
+
+ if find /usr/bin /usr/sbin | grep -q -w semanage && find /usr/bin /usr/sbin | grep -q -w getenforce && grep -E "31300|31302" </etc/v2ray-agent/nginx_error.log | grep -q "Permission denied"; then
+ echoContent red " ---> 妫�鏌ELinux绔彛鏄惁寮�鏀�"
+ if ! $(find /usr/bin /usr/sbin | grep -w semanage) port -l | grep http_port | grep -q 31300; then
+ $(find /usr/bin /usr/sbin | grep -w semanage) port -a -t http_port_t -p tcp 31300
+ echoContent green " ---> http_port_t 31300 绔彛寮�鏀炬垚鍔�"
+ fi
+
+ if ! $(find /usr/bin /usr/sbin | grep -w semanage) port -l | grep http_port | grep -q 31302; then
+ $(find /usr/bin /usr/sbin | grep -w semanage) port -a -t http_port_t -p tcp 31302
+ echoContent green " ---> http_port_t 31302 绔彛寮�鏀炬垚鍔�"
+ fi
+ handleNginx start
+
+ else
+ exit 0
+ fi
+}
+
+# 鎿嶄綔Nginx
+handleNginx() {
+
+ if [[ -z $(pgrep -f "nginx") ]] && [[ "$1" == "start" ]]; then
+ systemctl start nginx 2>/etc/v2ray-agent/nginx_error.log
+
+ sleep 0.5
+
+ if [[ -z $(pgrep -f nginx) ]]; then
+ echoContent red " ---> Nginx鍚姩澶辫触"
+ echoContent red " ---> 璇锋墜鍔ㄥ皾璇曞畨瑁卬ginx鍚庯紝鍐嶆鎵ц鑴氭湰"
+
+ if grep -q "journalctl -xe" </etc/v2ray-agent/nginx_error.log; then
+ updateSELinuxHTTPPortT
+ fi
+
+ # exit 0
+ else
+ echoContent green " ---> Nginx鍚姩鎴愬姛"
+ fi
+
+ elif [[ -n $(pgrep -f "nginx") ]] && [[ "$1" == "stop" ]]; then
+ systemctl stop nginx
+ sleep 0.5
+ if [[ -n $(pgrep -f "nginx") ]]; then
+ pgrep -f "nginx" | xargs kill -9
+ fi
+ echoContent green " ---> Nginx鍏抽棴鎴愬姛"
+ fi
+}
+
+# 瀹氭椂浠诲姟鏇存柊tls璇佷功
+installCronTLS() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 娣诲姞瀹氭椂缁存姢璇佷功"
+ crontab -l >/etc/v2ray-agent/backup_crontab.cron
+ local historyCrontab
+ historyCrontab=$(sed '/v2ray-agent/d;/acme.sh/d' /etc/v2ray-agent/backup_crontab.cron)
+ echo "${historyCrontab}" >/etc/v2ray-agent/backup_crontab.cron
+ echo "30 1 * * * /bin/bash /etc/v2ray-agent/install.sh RenewTLS >> /etc/v2ray-agent/crontab_tls.log 2>&1" >>/etc/v2ray-agent/backup_crontab.cron
+ crontab /etc/v2ray-agent/backup_crontab.cron
+ echoContent green "\n ---> 娣诲姞瀹氭椂缁存姢璇佷功鎴愬姛"
+}
+
+# 鏇存柊璇佷功
+renewalTLS() {
+ if [[ -n $1 ]]; then
+ echoContent skyBlue "\n杩涘害 $1/1 : 鏇存柊璇佷功"
+ fi
+ local domain=${currentHost}
+ if [[ -z "${currentHost}" && -n "${tlsDomain}" ]]; then
+ domain=${tlsDomain}
+ fi
+
+ if [[ -d "$HOME/.acme.sh/${domain}_ecc" ]] && [[ -f "$HOME/.acme.sh/${domain}_ecc/${domain}.key" ]] && [[ -f "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" ]]; then
+ modifyTime=$(stat "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}')
+
+ modifyTime=$(date +%s -d "${modifyTime}")
+ currentTime=$(date +%s)
+ ((stampDiff = currentTime - modifyTime))
+ ((days = stampDiff / 86400))
+ ((remainingDays = 90 - days))
+
+ tlsStatus=${remainingDays}
+ if [[ ${remainingDays} -le 0 ]]; then
+ tlsStatus="宸茶繃鏈�"
+ fi
+
+ echoContent skyBlue " ---> 璇佷功妫�鏌ユ棩鏈�:$(date "+%F %H:%M:%S")"
+ echoContent skyBlue " ---> 璇佷功鐢熸垚鏃ユ湡:$(date -d @"${modifyTime}" +"%F %H:%M:%S")"
+ echoContent skyBlue " ---> 璇佷功鐢熸垚澶╂暟:${days}"
+ echoContent skyBlue " ---> 璇佷功鍓╀綑澶╂暟:"${tlsStatus}
+ echoContent skyBlue " ---> 璇佷功杩囨湡鍓嶆渶鍚庝竴澶╄嚜鍔ㄦ洿鏂帮紝濡傛洿鏂板け璐ヨ鎵嬪姩鏇存柊"
+
+ if [[ ${remainingDays} -le 1 ]]; then
+ echoContent yellow " ---> 閲嶆柊鐢熸垚璇佷功"
+ handleNginx stop
+ sudo "$HOME/.acme.sh/acme.sh" --cron --home "$HOME/.acme.sh"
+ sudo "$HOME/.acme.sh/acme.sh" --installcert -d "${domain}" --fullchainpath /etc/v2ray-agent/tls/"${domain}.crt" --keypath /etc/v2ray-agent/tls/"${domain}.key" --ecc
+ reloadCore
+ handleNginx start
+ else
+ echoContent green " ---> 璇佷功鏈夋晥"
+ fi
+ else
+ echoContent red " ---> 鏈畨瑁�"
+ fi
+}
+# 鏌ョ湅TLS璇佷功鐨勭姸鎬�
+checkTLStatus() {
+
+ if [[ -d "$HOME/.acme.sh/${currentHost}_ecc" ]] && [[ -f "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.key" ]] && [[ -f "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.cer" ]]; then
+ modifyTime=$(stat "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.cer" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}')
+
+ modifyTime=$(date +%s -d "${modifyTime}")
+ currentTime=$(date +%s)
+ ((stampDiff = currentTime - modifyTime))
+ ((days = stampDiff / 86400))
+ ((remainingDays = 90 - days))
+
+ tlsStatus=${remainingDays}
+ if [[ ${remainingDays} -le 0 ]]; then
+ tlsStatus="宸茶繃鏈�"
+ fi
+
+ echoContent skyBlue " ---> 璇佷功鐢熸垚鏃ユ湡:$(date -d "@${modifyTime}" +"%F %H:%M:%S")"
+ echoContent skyBlue " ---> 璇佷功鐢熸垚澶╂暟:${days}"
+ echoContent skyBlue " ---> 璇佷功鍓╀綑澶╂暟:${tlsStatus}"
+ fi
+}
+
+# 瀹夎V2Ray銆佹寚瀹氱増鏈�
+installV2Ray() {
+ readInstallType
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 瀹夎V2Ray"
+
+ if [[ "${coreInstallType}" != "2" && "${coreInstallType}" != "3" ]]; then
+ if [[ "${selectCoreType}" == "2" ]]; then
+
+ version=$(curl -s https://api.github.com/repos/v2fly/v2ray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
+ else
+ version=${v2rayCoreVersion}
+ fi
+
+ echoContent green " ---> v2ray-core鐗堟湰:${version}"
+ if wget --help | grep -q show-progress; then
+ wget -c -q --show-progress -P /etc/v2ray-agent/v2ray/ "https://github.com/v2fly/v2ray-core/releases/download/${version}/${v2rayCoreCPUVendor}.zip"
+ else
+ wget -c -P /etc/v2ray-agent/v2ray/ "https://github.com/v2fly/v2ray-core/releases/download/${version}/${v2rayCoreCPUVendor}.zip" >/dev/null 2>&1
+ fi
+
+ unzip -o "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip" -d /etc/v2ray-agent/v2ray >/dev/null
+ rm -rf "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip"
+ else
+ if [[ "${selectCoreType}" == "3" ]]; then
+ echoContent green " ---> 閿佸畾v2ray-core鐗堟湰涓簐4.32.1"
+ rm -f /etc/v2ray-agent/v2ray/v2ray
+ rm -f /etc/v2ray-agent/v2ray/v2ctl
+ installV2Ray "$1"
+ else
+ echoContent green " ---> v2ray-core鐗堟湰:$(/etc/v2ray-agent/v2ray/v2ray --version | awk '{print $2}' | head -1)"
+ read -r -p "鏄惁鏇存柊銆佸崌绾э紵[y/n]:" reInstallV2RayStatus
+ if [[ "${reInstallV2RayStatus}" == "y" ]]; then
+ rm -f /etc/v2ray-agent/v2ray/v2ray
+ rm -f /etc/v2ray-agent/v2ray/v2ctl
+ installV2Ray "$1"
+ fi
+ fi
+ fi
+}
+
+# 瀹夎xray
+installXray() {
+ readInstallType
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 瀹夎Xray"
+
+ if [[ "${coreInstallType}" != "1" ]]; then
+
+ version=$(curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
+
+ echoContent green " ---> Xray-core鐗堟湰:${version}"
+ if wget --help | grep -q show-progress; then
+ wget -c -q --show-progress -P /etc/v2ray-agent/xray/ "https://github.com/XTLS/Xray-core/releases/download/${version}/${xrayCoreCPUVendor}.zip"
+ else
+ wget -c -P /etc/v2ray-agent/xray/ "https://github.com/XTLS/Xray-core/releases/download/${version}/${xrayCoreCPUVendor}.zip" >/dev/null 2>&1
+ fi
+
+ unzip -o "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip" -d /etc/v2ray-agent/xray >/dev/null
+ rm -rf "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip"
+ chmod 655 /etc/v2ray-agent/xray/xray
+ else
+ echoContent green " ---> Xray-core鐗堟湰:$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)"
+ read -r -p "鏄惁鏇存柊銆佸崌绾э紵[y/n]:" reInstallXrayStatus
+ if [[ "${reInstallXrayStatus}" == "y" ]]; then
+ rm -f /etc/v2ray-agent/xray/xray
+ installXray "$1"
+ fi
+ fi
+}
+
+# v2ray鐗堟湰绠$悊
+v2rayVersionManageMenu() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : V2Ray鐗堟湰绠$悊"
+ if [[ ! -d "/etc/v2ray-agent/v2ray/" ]]; then
+ echoContent red " ---> 娌℃湁妫�娴嬪埌瀹夎鐩綍锛岃鎵ц鑴氭湰瀹夎鍐呭"
+ menu
+ exit 0
+ fi
+ echoContent red "\n=============================================================="
+ echoContent yellow "1.鍗囩骇v2ray-core"
+ echoContent yellow "2.鍥為��v2ray-core"
+ echoContent yellow "3.鍏抽棴v2ray-core"
+ echoContent yellow "4.鎵撳紑v2ray-core"
+ echoContent yellow "5.閲嶅惎v2ray-core"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" selectV2RayType
+ if [[ "${selectV2RayType}" == "1" ]]; then
+ updateV2Ray
+ elif [[ "${selectV2RayType}" == "2" ]]; then
+ echoContent yellow "\n1.鍙彲浠ュ洖閫�鏈�杩戠殑浜斾釜鐗堟湰"
+ echoContent yellow "2.涓嶄繚璇佸洖閫�鍚庝竴瀹氬彲浠ユ甯镐娇鐢�"
+ echoContent yellow "3.濡傛灉鍥為��鐨勭増鏈笉鏀寔褰撳墠鐨刢onfig锛屽垯浼氭棤娉曡繛鎺ワ紝璋ㄦ厧鎿嶄綔"
+ echoContent skyBlue "------------------------Version-------------------------------"
+ curl -s https://api.github.com/repos/v2fly/v2ray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -5 | awk '{print ""NR""":"$0}'
+
+ echoContent skyBlue "--------------------------------------------------------------"
+ read -r -p "璇疯緭鍏ヨ鍥為��鐨勭増鏈�:" selectV2rayVersionType
+ version=$(curl -s https://api.github.com/repos/v2fly/v2ray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -5 | awk '{print ""NR""":"$0}' | grep "${selectV2rayVersionType}:" | awk -F "[:]" '{print $2}')
+ if [[ -n "${version}" ]]; then
+ updateV2Ray "${version}"
+ else
+ echoContent red "\n ---> 杈撳叆鏈夎锛岃閲嶆柊杈撳叆"
+ v2rayVersionManageMenu 1
+ fi
+ elif [[ "${selectXrayType}" == "3" ]]; then
+ handleV2Ray stop
+ elif [[ "${selectXrayType}" == "4" ]]; then
+ handleV2Ray start
+ elif [[ "${selectXrayType}" == "5" ]]; then
+ reloadCore
+ fi
+}
+
+# xray鐗堟湰绠$悊
+xrayVersionManageMenu() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : Xray鐗堟湰绠$悊"
+ if [[ ! -d "/etc/v2ray-agent/xray/" ]]; then
+ echoContent red " ---> 娌℃湁妫�娴嬪埌瀹夎鐩綍锛岃鎵ц鑴氭湰瀹夎鍐呭"
+ menu
+ exit 0
+ fi
+ echoContent red "\n=============================================================="
+ echoContent yellow "1.鍗囩骇Xray-core"
+ echoContent yellow "2.鍥為��Xray-core"
+ echoContent yellow "3.鍏抽棴Xray-core"
+ echoContent yellow "4.鎵撳紑Xray-core"
+ echoContent yellow "5.閲嶅惎Xray-core"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" selectXrayType
+ if [[ "${selectXrayType}" == "1" ]]; then
+ updateXray
+ elif [[ "${selectXrayType}" == "2" ]]; then
+ echoContent yellow "\n1.鍙彲浠ュ洖閫�鏈�杩戠殑浜斾釜鐗堟湰"
+ echoContent yellow "2.涓嶄繚璇佸洖閫�鍚庝竴瀹氬彲浠ユ甯镐娇鐢�"
+ echoContent yellow "3.濡傛灉鍥為��鐨勭増鏈笉鏀寔褰撳墠鐨刢onfig锛屽垯浼氭棤娉曡繛鎺ワ紝璋ㄦ厧鎿嶄綔"
+ echoContent skyBlue "------------------------Version-------------------------------"
+ curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -5 | awk '{print ""NR""":"$0}'
+ echoContent skyBlue "--------------------------------------------------------------"
+ read -r -p "璇疯緭鍏ヨ鍥為��鐨勭増鏈�:" selectXrayVersionType
+ version=$(curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -5 | awk '{print ""NR""":"$0}' | grep "${selectXrayVersionType}:" | awk -F "[:]" '{print $2}')
+ if [[ -n "${version}" ]]; then
+ updateXray "${version}"
+ else
+ echoContent red "\n ---> 杈撳叆鏈夎锛岃閲嶆柊杈撳叆"
+ xrayVersionManageMenu 1
+ fi
+ elif [[ "${selectXrayType}" == "3" ]]; then
+ handleXray stop
+ elif [[ "${selectXrayType}" == "4" ]]; then
+ handleXray start
+ elif [[ "${selectXrayType}" == "5" ]]; then
+ reloadCore
+ fi
+
+}
+# 鏇存柊V2Ray
+updateV2Ray() {
+ readInstallType
+ if [[ -z "${coreInstallType}" ]]; then
+
+ if [[ -n "$1" ]]; then
+ version=$1
+ else
+ version=$(curl -s https://api.github.com/repos/v2fly/v2ray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
+ fi
+ # 浣跨敤閿佸畾鐨勭増鏈�
+ if [[ -n "${v2rayCoreVersion}" ]]; then
+ version=${v2rayCoreVersion}
+ fi
+ echoContent green " ---> v2ray-core鐗堟湰:${version}"
+
+ if wget --help | grep -q show-progress; then
+ #wget -c -q --show-progress -P /etc/v2ray-agent/v2ray/ "https://github.com/v2fly/v2ray-core/releases/download/${version}/${v2rayCoreCPUVendor}.zip"
+ wget -c -q --show-progress -P /etc/v2ray-agent/v2ray/ "http://www.zgleiju.com:8967/raw/Hunter/Linux/v2ray-core.git/master/releases/download/${version}/${v2rayCoreCPUVendor}.zip"
+ else
+ #wget -c -P "/etc/v2ray-agent/v2ray/ https://github.com/v2fly/v2ray-core/releases/download/${version}/${v2rayCoreCPUVendor}.zip" >/dev/null 2>&1
+ wget -c -P "/etc/v2ray-agent/v2ray/ http://www.zgleiju.com:8967/raw/Hunter/Linux/v2ray-core.git/master/releases/download/${version}/${v2rayCoreCPUVendor}.zip" >/dev/null 2>&1
+ fi
+
+ unzip -o "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip" -d /etc/v2ray-agent/v2ray >/dev/null
+ rm -rf "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip"
+ handleV2Ray stop
+ handleV2Ray start
+ else
+ echoContent green " ---> 褰撳墠v2ray-core鐗堟湰:$(/etc/v2ray-agent/v2ray/v2ray --version | awk '{print $2}' | head -1)"
+
+ if [[ -n "$1" ]]; then
+ version=$1
+ else
+ version=$(curl -s https://api.github.com/repos/v2fly/v2ray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
+ fi
+
+ if [[ -n "${v2rayCoreVersion}" ]]; then
+ version=${v2rayCoreVersion}
+ fi
+ if [[ -n "$1" ]]; then
+ read -r -p "鍥為��鐗堟湰涓�${version}锛屾槸鍚︾户缁紵[y/n]:" rollbackV2RayStatus
+ if [[ "${rollbackV2RayStatus}" == "y" ]]; then
+ if [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then
+ echoContent green " ---> 褰撳墠v2ray-core鐗堟湰:$(/etc/v2ray-agent/v2ray/v2ray --version | awk '{print $2}' | head -1)"
+ elif [[ "${coreInstallType}" == "1" ]]; then
+ echoContent green " ---> 褰撳墠Xray-core鐗堟湰:$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)"
+ fi
+
+ handleV2Ray stop
+ rm -f /etc/v2ray-agent/v2ray/v2ray
+ rm -f /etc/v2ray-agent/v2ray/v2ctl
+ updateV2Ray "${version}"
+ else
+ echoContent green " ---> 鏀惧純鍥為��鐗堟湰"
+ fi
+ elif [[ "${version}" == "v$(/etc/v2ray-agent/v2ray/v2ray --version | awk '{print $2}' | head -1)" ]]; then
+ read -r -p "褰撳墠鐗堟湰涓庢渶鏂扮増鐩稿悓锛屾槸鍚﹂噸鏂板畨瑁咃紵[y/n]:" reInstallV2RayStatus
+ if [[ "${reInstallV2RayStatus}" == "y" ]]; then
+ handleV2Ray stop
+ rm -f /etc/v2ray-agent/v2ray/v2ray
+ rm -f /etc/v2ray-agent/v2ray/v2ctl
+ updateV2Ray
+ else
+ echoContent green " ---> 鏀惧純閲嶆柊瀹夎"
+ fi
+ else
+ read -r -p "鏈�鏂扮増鏈负:${version}锛屾槸鍚︽洿鏂帮紵[y/n]:" installV2RayStatus
+ if [[ "${installV2RayStatus}" == "y" ]]; then
+ rm -f /etc/v2ray-agent/v2ray/v2ray
+ rm -f /etc/v2ray-agent/v2ray/v2ctl
+ updateV2Ray
+ else
+ echoContent green " ---> 鏀惧純鏇存柊"
+ fi
+
+ fi
+ fi
+}
+
+# 鏇存柊Xray
+updateXray() {
+ readInstallType
+ if [[ -z "${coreInstallType}" ]]; then
+ if [[ -n "$1" ]]; then
+ version=$1
+ else
+ version=$(curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
+ fi
+
+ echoContent green " ---> Xray-core鐗堟湰:${version}"
+
+ if wget --help | grep -q show-progress; then
+ wget -c -q --show-progress -P /etc/v2ray-agent/xray/ "https://github.com/XTLS/Xray-core/releases/download/${version}/${xrayCoreCPUVendor}.zip"
+ else
+ wget -c -P /etc/v2ray-agent/xray/ "https://github.com/XTLS/Xray-core/releases/download/${version}/${xrayCoreCPUVendor}.zip" >/dev/null 2>&1
+ fi
+
+ unzip -o "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip" -d /etc/v2ray-agent/xray >/dev/null
+ rm -rf "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip"
+ chmod 655 /etc/v2ray-agent/xray/xray
+ handleXray stop
+ handleXray start
+ else
+ echoContent green " ---> 褰撳墠Xray-core鐗堟湰:$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)"
+
+ if [[ -n "$1" ]]; then
+ version=$1
+ else
+ version=$(curl -s https://api.github.com/repos/XTLS/Xray-core/releases | jq -r '.[]|select (.prerelease==false)|.tag_name' | head -1)
+ fi
+
+ if [[ -n "$1" ]]; then
+ read -r -p "鍥為��鐗堟湰涓�${version}锛屾槸鍚︾户缁紵[y/n]:" rollbackXrayStatus
+ if [[ "${rollbackXrayStatus}" == "y" ]]; then
+ echoContent green " ---> 褰撳墠Xray-core鐗堟湰:$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)"
+
+ handleXray stop
+ rm -f /etc/v2ray-agent/xray/xray
+ updateXray "${version}"
+ else
+ echoContent green " ---> 鏀惧純鍥為��鐗堟湰"
+ fi
+ elif [[ "${version}" == "v$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)" ]]; then
+ read -r -p "褰撳墠鐗堟湰涓庢渶鏂扮増鐩稿悓锛屾槸鍚﹂噸鏂板畨瑁咃紵[y/n]:" reInstallXrayStatus
+ if [[ "${reInstallXrayStatus}" == "y" ]]; then
+ handleXray stop
+ rm -f /etc/v2ray-agent/xray/xray
+ rm -f /etc/v2ray-agent/xray/xray
+ updateXray
+ else
+ echoContent green " ---> 鏀惧純閲嶆柊瀹夎"
+ fi
+ else
+ read -r -p "鏈�鏂扮増鏈负:${version}锛屾槸鍚︽洿鏂帮紵[y/n]:" installXrayStatus
+ if [[ "${installXrayStatus}" == "y" ]]; then
+ rm -f /etc/v2ray-agent/xray/xray
+ updateXray
+ else
+ echoContent green " ---> 鏀惧純鏇存柊"
+ fi
+
+ fi
+ fi
+}
+
+# 楠岃瘉鏁翠釜鏈嶅姟鏄惁鍙敤
+checkGFWStatue() {
+ readInstallType
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 楠岃瘉鏈嶅姟鍚姩鐘舵��"
+ if [[ "${coreInstallType}" == "1" ]] && [[ -n $(pgrep -f xray/xray) ]]; then
+ echoContent green " ---> 鏈嶅姟鍚姩鎴愬姛"
+ elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]] && [[ -n $(pgrep -f v2ray/v2ray) ]]; then
+ echoContent green " ---> 鏈嶅姟鍚姩鎴愬姛"
+ else
+ echoContent red " ---> 鏈嶅姟鍚姩澶辫触锛岃妫�鏌ョ粓绔槸鍚︽湁鏃ュ織鎵撳嵃"
+ exit 0
+ fi
+
+}
+
+# V2Ray寮�鏈鸿嚜鍚�
+installV2RayService() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 閰嶇疆V2Ray寮�鏈鸿嚜鍚�"
+ if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
+ rm -rf /etc/systemd/system/v2ray.service
+ touch /etc/systemd/system/v2ray.service
+ execStart='/etc/v2ray-agent/v2ray/v2ray -confdir /etc/v2ray-agent/v2ray/conf'
+ cat <<EOF >/etc/systemd/system/v2ray.service
+[Unit]
+Description=V2Ray - A unified platform for anti-censorship
+Documentation=https://v2ray.com https://guide.v2fly.org
+After=network.target nss-lookup.target
+Wants=network-online.target
+
+[Service]
+Type=simple
+User=root
+CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW
+NoNewPrivileges=yes
+ExecStart=${execStart}
+Restart=on-failure
+RestartPreventExitStatus=23
+LimitNPROC=10000
+LimitNOFILE=1000000
+
+[Install]
+WantedBy=multi-user.target
+EOF
+ systemctl daemon-reload
+ systemctl enable v2ray.service
+ echoContent green " ---> 閰嶇疆V2Ray寮�鏈鸿嚜鍚垚鍔�"
+ fi
+}
+
+# Xray寮�鏈鸿嚜鍚�
+installXrayService() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 閰嶇疆Xray寮�鏈鸿嚜鍚�"
+ if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
+ rm -rf /etc/systemd/system/xray.service
+ touch /etc/systemd/system/xray.service
+ execStart='/etc/v2ray-agent/xray/xray run -confdir /etc/v2ray-agent/xray/conf'
+ cat <<EOF >/etc/systemd/system/xray.service
+[Unit]
+Description=Xray Service
+Documentation=https://github.com/XTLS/Xray-core
+After=network.target nss-lookup.target
+Wants=network-online.target
+
+[Service]
+Type=simple
+User=root
+CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW
+NoNewPrivileges=yes
+ExecStart=${execStart}
+Restart=on-failure
+RestartPreventExitStatus=23
+LimitNPROC=10000
+LimitNOFILE=1000000
+
+[Install]
+WantedBy=multi-user.target
+EOF
+ systemctl daemon-reload
+ systemctl enable xray.service
+ echoContent green " ---> 閰嶇疆Xray寮�鏈鸿嚜鍚垚鍔�"
+ fi
+}
+
+# 鎿嶄綔V2Ray
+handleV2Ray() {
+ # shellcheck disable=SC2010
+ if find /bin /usr/bin | grep -q systemctl && ls /etc/systemd/system/ | grep -q v2ray.service; then
+ if [[ -z $(pgrep -f "v2ray/v2ray") ]] && [[ "$1" == "start" ]]; then
+ systemctl start v2ray.service
+ elif [[ -n $(pgrep -f "v2ray/v2ray") ]] && [[ "$1" == "stop" ]]; then
+ systemctl stop v2ray.service
+ fi
+ fi
+ sleep 0.8
+
+ if [[ "$1" == "start" ]]; then
+ if [[ -n $(pgrep -f "v2ray/v2ray") ]]; then
+ echoContent green " ---> V2Ray鍚姩鎴愬姛"
+ else
+ echoContent red "V2Ray鍚姩澶辫触"
+ echoContent red "璇锋墜鍔ㄦ墽琛屻��/etc/v2ray-agent/v2ray/v2ray -confdir /etc/v2ray-agent/v2ray/conf銆戯紝鏌ョ湅閿欒鏃ュ織"
+ exit 0
+ fi
+ elif [[ "$1" == "stop" ]]; then
+ if [[ -z $(pgrep -f "v2ray/v2ray") ]]; then
+ echoContent green " ---> V2Ray鍏抽棴鎴愬姛"
+ else
+ echoContent red "V2Ray鍏抽棴澶辫触"
+ echoContent red "璇锋墜鍔ㄦ墽琛屻�恜s -ef|grep -v grep|grep v2ray|awk '{print \$2}'|xargs kill -9銆�"
+ exit 0
+ fi
+ fi
+}
+# 鎿嶄綔xray
+handleXray() {
+ if [[ -n $(find /bin /usr/bin -name "systemctl") ]] && [[ -n $(find /etc/systemd/system/ -name "xray.service") ]]; then
+ if [[ -z $(pgrep -f "xray/xray") ]] && [[ "$1" == "start" ]]; then
+ systemctl start xray.service
+ elif [[ -n $(pgrep -f "xray/xray") ]] && [[ "$1" == "stop" ]]; then
+ systemctl stop xray.service
+ fi
+ fi
+
+ sleep 0.8
+
+ if [[ "$1" == "start" ]]; then
+ if [[ -n $(pgrep -f "xray/xray") ]]; then
+ echoContent green " ---> Xray鍚姩鎴愬姛"
+ else
+ echoContent red "Xray鍚姩澶辫触"
+ echoContent red "璇锋墜鍔ㄦ墽琛屻��/etc/v2ray-agent/xray/xray -confdir /etc/v2ray-agent/xray/conf銆戯紝鏌ョ湅閿欒鏃ュ織"
+ exit 0
+ fi
+ elif [[ "$1" == "stop" ]]; then
+ if [[ -z $(pgrep -f "xray/xray") ]]; then
+ echoContent green " ---> Xray鍏抽棴鎴愬姛"
+ else
+ echoContent red "xray鍏抽棴澶辫触"
+ echoContent red "璇锋墜鍔ㄦ墽琛屻�恜s -ef|grep -v grep|grep xray|awk '{print \$2}'|xargs kill -9銆�"
+ exit 0
+ fi
+ fi
+}
+# 鑾峰彇clients閰嶇疆
+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}]涓婁竴娆″畨瑁呯殑閰嶇疆鏂囦欢锛岄噰鐢ㄩ厤缃枃浠剁殑绗竴涓猽uid"
+ else
+ previousClients=$(jq -r ".inbounds[0].settings.clients" "${path}")
+ fi
+
+ fi
+}
+
+# 娣诲姞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
+}
+
+# 鍒濆鍖朒ysteria閰嶇疆
+initHysteriaConfig() {
+ echoContent skyBlue "\n杩涘害 $2/${totalProgress} : 鍒濆鍖朒ysteria閰嶇疆"
+}
+
+# 鍒濆鍖朧2Ray 閰嶇疆鏂囦欢
+initV2RayConfig() {
+ echoContent skyBlue "\n杩涘害 $2/${totalProgress} : 鍒濆鍖朧2Ray閰嶇疆"
+ echo
+
+ read -r -p "鏄惁鑷畾涔塙UID 锛焄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 <<EOF >/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 <<EOF >/etc/v2ray-agent/v2ray/conf/10_ipv6_outbounds.json
+{
+ "outbounds": [
+ {
+ "protocol": "freedom",
+ "settings": {},
+ "tag": "direct"
+ }
+ ]
+}
+EOF
+
+ else
+ cat <<EOF >/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 <<EOF >/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 <<EOF >/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": "${domain}_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 <<EOF >/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": "${domain}_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 <<EOF >/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": "${domain}_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 <<EOF >/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": "${domain}_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 <<EOF >/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": "${domain}_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}"
+ cat <<EOF >/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json
+{
+"inbounds":[
+{
+ "port": 443,
+ "protocol": "vless",
+ "tag":"VLESSTCP",
+ "settings": {
+ "clients": [
+ {
+ "id": "${uuid}",
+ "add":"${add}",
+ "email": "${domain}_VLESS_TLS-direct_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}"
+
+}
+
+# 鍒濆鍖朮ray Trojan XTLS 閰嶇疆鏂囦欢
+initXrayFrontingConfig() {
+ if [[ -z "${configPath}" ]]; then
+ echoContent red " ---> 鏈畨瑁咃紝璇蜂娇鐢ㄨ剼鏈畨瑁�"
+ menu
+ exit 0
+ fi
+ if [[ "${coreInstallType}" != "1" ]]; then
+ echoContent red " ---> 鏈畨瑁呭彲鐢ㄧ被鍨�"
+ fi
+ local xtlsType=
+ if echo ${currentInstallProtocolType} | grep -q trojan; then
+ xtlsType=VLESS
+ else
+ xtlsType=Trojan
+
+ fi
+
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 鍓嶇疆鍒囨崲涓�${xtlsType}"
+ echoContent red "\n=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」\n"
+ echoContent yellow "浼氬皢鍓嶇疆鏇挎崲涓�${xtlsType}"
+ echoContent yellow "濡傛灉鍓嶇疆鏄疶rojan锛屾煡鐪嬪笎鍙锋椂鍒欎細鍑虹幇涓や釜Trojan鍗忚鐨勮妭鐐癸紝鏈変竴涓笉鍙敤xtls"
+ echoContent yellow "鍐嶆鎵ц鍙垏鎹㈣嚦涓婁竴娆$殑鍓嶇疆\n"
+
+ echoContent yellow "1.鍒囨崲鑷�${xtlsType}"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" selectType
+ if [[ "${selectType}" == "1" ]]; then
+
+ if [[ "${xtlsType}" == "Trojan" ]]; then
+
+ local VLESSConfig
+ VLESSConfig=$(cat ${configPath}${frontingType}.json)
+ VLESSConfig=${VLESSConfig//"id"/"password"}
+ VLESSConfig=${VLESSConfig//VLESSTCP/TrojanTCPXTLS}
+ VLESSConfig=${VLESSConfig//VLESS/Trojan}
+ VLESSConfig=${VLESSConfig//"vless"/"trojan"}
+ VLESSConfig=${VLESSConfig//"id"/"password"}
+
+ echo "${VLESSConfig}" | jq . >${configPath}02_trojan_TCP_inbounds.json
+ rm ${configPath}${frontingType}.json
+ elif [[ "${xtlsType}" == "VLESS" ]]; then
+
+ local VLESSConfig
+ VLESSConfig=$(cat ${configPath}02_trojan_TCP_inbounds.json)
+ VLESSConfig=${VLESSConfig//"password"/"id"}
+ VLESSConfig=${VLESSConfig//TrojanTCPXTLS/VLESSTCP}
+ VLESSConfig=${VLESSConfig//Trojan/VLESS}
+ VLESSConfig=${VLESSConfig//"trojan"/"vless"}
+ VLESSConfig=${VLESSConfig//"password"/"id"}
+
+ echo "${VLESSConfig}" | jq . >${configPath}02_VLESS_TCP_inbounds.json
+ rm ${configPath}02_trojan_TCP_inbounds.json
+ fi
+ reloadCore
+ fi
+
+ exit 0
+}
+
+# 绉诲姩涓婃閰嶇疆鏂囦欢鑷充复鏃舵枃浠�
+movePreviousConfig() {
+ if [[ -n "${configPath}" ]] && [[ -f "${configPath}02_VLESS_TCP_inbounds.json" ]]; then
+ rm -rf ${configPath}../tmp/*
+ mv ${configPath}* ${configPath}../tmp/
+ fi
+
+}
+
+# 鍒濆鍖朮ray 閰嶇疆鏂囦欢
+initXrayConfig() {
+ echoContent skyBlue "\n杩涘害 $2/${totalProgress} : 鍒濆鍖朮ray閰嶇疆"
+ echo
+ local uuid=
+ local addClientsStatus=
+ if [[ -n "${currentUUID}" ]]; then
+ read -r -p "璇诲彇鍒颁笂娆″畨瑁呰褰曪紝鏄惁浣跨敤涓婃瀹夎鏃剁殑UUID 锛焄y/n]:" historyUUIDStatus
+ if [[ "${historyUUIDStatus}" == "y" ]]; then
+ addClientsStatus=true
+ uuid=${currentUUID}
+ echoContent green "\n ---> 浣跨敤鎴愬姛"
+ fi
+ fi
+
+ if [[ -z "${uuid}" ]]; then
+ echoContent yellow "璇疯緭鍏ヨ嚜瀹氫箟UUID[闇�鍚堟硶]锛孾鍥炶溅]闅忔満UUID"
+ read -r -p 'UUID:' customUUID
+
+ if [[ -n ${customUUID} ]]; then
+ uuid=${customUUID}
+ else
+ uuid=$(/etc/v2ray-agent/xray/xray uuid)
+ fi
+
+ fi
+
+ if [[ -z "${uuid}" ]]; then
+ addClientsStatus=
+ echoContent red "\n ---> uuid璇诲彇閿欒锛岄噸鏂扮敓鎴�"
+ uuid=$(/etc/v2ray-agent/xray/xray uuid)
+ fi
+
+ echoContent yellow "\n ${uuid}"
+
+ movePreviousConfig
+
+ # log
+ cat <<EOF >/etc/v2ray-agent/xray/conf/00_log.json
+{
+ "log": {
+ "error": "/etc/v2ray-agent/xray/error.log",
+ "loglevel": "warning"
+ }
+}
+EOF
+
+ # outbounds
+ if [[ -n "${pingIPv6}" ]]; then
+ cat <<EOF >/etc/v2ray-agent/xray/conf/10_ipv6_outbounds.json
+{
+ "outbounds": [
+ {
+ "protocol": "freedom",
+ "settings": {},
+ "tag": "direct"
+ }
+ ]
+}
+EOF
+
+ else
+ cat <<EOF >/etc/v2ray-agent/xray/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 <<EOF >/etc/v2ray-agent/xray/conf/11_dns.json
+{
+ "dns": {
+ "servers": [
+ "localhost"
+ ]
+ }
+}
+EOF
+
+ # VLESS_TCP_TLS/XTLS
+ # 鍥炶惤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 <<EOF >/etc/v2ray-agent/xray/conf/04_trojan_TCP_inbounds.json
+{
+"inbounds":[
+ {
+ "port": 31296,
+ "listen": "127.0.0.1",
+ "protocol": "trojan",
+ "tag":"trojanTCP",
+ "settings": {
+ "clients": [
+ {
+ "password": "${uuid}",
+ "email": "${domain}_trojan_tcp"
+ }
+ ],
+ "fallbacks":[
+ {"dest":"31300"}
+ ]
+ },
+ "streamSettings": {
+ "network": "tcp",
+ "security": "none",
+ "tcpSettings": {
+ "acceptProxyProtocol": true
+ }
+ }
+ }
+ ]
+}
+EOF
+ addClients "/etc/v2ray-agent/xray/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 <<EOF >/etc/v2ray-agent/xray/conf/03_VLESS_WS_inbounds.json
+{
+"inbounds":[
+ {
+ "port": 31297,
+ "listen": "127.0.0.1",
+ "protocol": "vless",
+ "tag":"VLESSWS",
+ "settings": {
+ "clients": [
+ {
+ "id": "${uuid}",
+ "email": "${domain}_VLESS_WS"
+ }
+ ],
+ "decryption": "none"
+ },
+ "streamSettings": {
+ "network": "ws",
+ "security": "none",
+ "wsSettings": {
+ "acceptProxyProtocol": true,
+ "path": "/${customPath}ws"
+ }
+ }
+ }
+]
+}
+EOF
+ addClients "/etc/v2ray-agent/xray/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 <<EOF >/etc/v2ray-agent/xray/conf/04_trojan_gRPC_inbounds.json
+{
+ "inbounds": [
+ {
+ "port": 31304,
+ "listen": "127.0.0.1",
+ "protocol": "trojan",
+ "tag": "trojangRPCTCP",
+ "settings": {
+ "clients": [
+ {
+ "password": "${uuid}",
+ "email": "${domain}_trojan_gRPC"
+ }
+ ],
+ "fallbacks": [
+ {
+ "dest": "31300"
+ }
+ ]
+ },
+ "streamSettings": {
+ "network": "grpc",
+ "grpcSettings": {
+ "serviceName": "${customPath}trojangrpc"
+ }
+ }
+ }
+ ]
+}
+EOF
+ addClients "/etc/v2ray-agent/xray/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 <<EOF >/etc/v2ray-agent/xray/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": "${domain}_vmess_ws"
+ }
+ ]
+ },
+ "streamSettings": {
+ "network": "ws",
+ "security": "none",
+ "wsSettings": {
+ "acceptProxyProtocol": true,
+ "path": "/${customPath}vws"
+ }
+ }
+}
+]
+}
+EOF
+ addClients "/etc/v2ray-agent/xray/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 <<EOF >/etc/v2ray-agent/xray/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": "${domain}_VLESS_gRPC"
+ }
+ ],
+ "decryption": "none"
+ },
+ "streamSettings": {
+ "network": "grpc",
+ "grpcSettings": {
+ "serviceName": "${customPath}grpc"
+ }
+ }
+ }
+]
+}
+EOF
+ addClients "/etc/v2ray-agent/xray/conf/06_VLESS_gRPC_inbounds.json" "${addClientsStatus}"
+ fi
+
+ # VLESS_TCP
+ getClients "${configPath}../tmp/02_VLESS_TCP_inbounds.json" "${addClientsStatus}"
+ cat <<EOF >/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json
+{
+"inbounds":[
+{
+ "port": 443,
+ "protocol": "vless",
+ "tag":"VLESSTCP",
+ "settings": {
+ "clients": [
+ {
+ "id": "${uuid}",
+ "add":"${add}",
+ "flow":"xtls-rprx-direct",
+ "email": "${domain}_VLESS_XTLS/TLS-direct_TCP"
+ }
+ ],
+ "decryption": "none",
+ "fallbacks": [
+ ${fallbacksList}
+ ]
+ },
+ "streamSettings": {
+ "network": "tcp",
+ "security": "xtls",
+ "xtlsSettings": {
+ "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/xray/conf/02_VLESS_TCP_inbounds.json" "${addClientsStatus}"
+}
+
+# 鍒濆鍖朤rojan-Go閰嶇疆
+initTrojanGoConfig() {
+
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鍒濆鍖朤rojan閰嶇疆"
+ cat <<EOF >/etc/v2ray-agent/trojan/config_full.json
+{
+ "run_type": "server",
+ "local_addr": "127.0.0.1",
+ "local_port": 31296,
+ "remote_addr": "127.0.0.1",
+ "remote_port": 31300,
+ "disable_http_check":true,
+ "log_level":3,
+ "log_file":"/etc/v2ray-agent/trojan/trojan.log",
+ "password": [
+ "${uuid}"
+ ],
+ "dns":[
+ "localhost"
+ ],
+ "transport_plugin":{
+ "enabled":true,
+ "type":"plaintext"
+ },
+ "websocket": {
+ "enabled": true,
+ "path": "/${customPath}tws",
+ "host": "${domain}",
+ "add":"${add}"
+ },
+ "router": {
+ "enabled": false
+ }
+}
+EOF
+}
+
+# 鑷畾涔塁DN IP
+customCDNIP() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 娣诲姞cloudflare鑷�塁NAME"
+ echoContent red "\n=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」"
+ echoContent yellow "\n鏁欑▼鍦板潃:"
+ echoContent skyBlue "https://github.com/mack-a/v2ray-agent/blob/master/documents/optimize_V2Ray.md"
+ echoContent red "\n濡傚Cloudflare浼樺寲涓嶄簡瑙o紝璇蜂笉瑕佷娇鐢�"
+ echoContent yellow "\n 1.绉诲姩:104.16.123.96"
+ echoContent yellow " 2.鑱旈��:www.cloudflare.com"
+ echoContent yellow " 3.鐢典俊:www.digitalocean.com"
+ echoContent skyBlue "----------------------------"
+ read -r -p "璇烽�夋嫨[鍥炶溅涓嶄娇鐢╙:" selectCloudflareType
+ case ${selectCloudflareType} in
+ 1)
+ add="104.16.123.96"
+ ;;
+ 2)
+ add="www.cloudflare.com"
+ ;;
+ 3)
+ add="www.digitalocean.com"
+ ;;
+ *)
+ add="${domain}"
+ echoContent yellow "\n ---> 涓嶄娇鐢�"
+ ;;
+ esac
+}
+# 閫氱敤
+defaultBase64Code() {
+ local type=$1
+ local email=$2
+ local id=$3
+
+ port=${currentDefaultPort}
+
+ local subAccount
+ subAccount=$(echo "${email}" | awk -F "[_]" '{print $1}')_$(echo "${id}_currentHost" | md5sum | awk '{print $1}')
+ if [[ "${type}" == "vlesstcp" ]]; then
+
+ if [[ "${coreInstallType}" == "1" ]] && echo "${currentInstallProtocolType}" | grep -q 0; then
+ echoContent yellow " ---> 閫氱敤鏍煎紡(VLESS+TCP+TLS/xtls-rprx-direct)"
+ echoContent green " vless://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-direct#${email}\n"
+
+ echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(VLESS+TCP+TLS/xtls-rprx-direct)"
+ echoContent green "鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:xtls锛屼紶杈撴柟寮�:tcp锛宖low:xtls-rprx-direct锛岃处鎴峰悕:${email}\n"
+ cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
+vless://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-direct#${email}
+EOF
+ echoContent yellow " ---> 浜岀淮鐮� VLESS(VLESS+TCP+TLS/xtls-rprx-direct)"
+ echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%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-direct%23${email}\n"
+
+ echoContent skyBlue "----------------------------------------------------------------------------------"
+
+ echoContent yellow " ---> 閫氱敤鏍煎紡(VLESS+TCP+TLS/xtls-rprx-splice)"
+ echoContent green " vless://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-splice#${email/direct/splice}\n"
+
+ echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(VLESS+TCP+TLS/xtls-rprx-splice)"
+ echoContent green " 鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:xtls锛屼紶杈撴柟寮�:tcp锛宖low:xtls-rprx-splice锛岃处鎴峰悕:${email/direct/splice}\n"
+ cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
+vless://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-splice#${email/direct/splice}
+EOF
+ echoContent yellow " ---> 浜岀淮鐮� VLESS(VLESS+TCP+TLS/xtls-rprx-splice)"
+ echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%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-splice%23${email/direct/splice}\n"
+
+ elif [[ "${coreInstallType}" == 2 || "${coreInstallType}" == "3" ]]; then
+ echoContent yellow " ---> 閫氱敤鏍煎紡(VLESS+TCP+TLS)"
+ echoContent green " vless://${id}@${currentHost}:${currentDefaultPort}?security=tls&encryption=none&host=${currentHost}&headerType=none&type=tcp#${email}\n"
+
+ echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(VLESS+TCP+TLS/xtls-rprx-splice)"
+ echoContent green " 鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:tls锛屼紶杈撴柟寮�:tcp锛岃处鎴峰悕:${email/direct/splice}\n"
+
+ cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
+vless://${id}@${currentHost}:${currentDefaultPort}?security=tls&encryption=none&host=${currentHost}&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%26host%3d${currentHost}%26headerType%3dnone%26type%3dtcp%23${email}\n"
+ fi
+
+ elif [[ "${type}" == "trojanTCPXTLS" ]]; then
+ echoContent yellow " ---> 閫氱敤鏍煎紡(Trojan+TCP+TLS/xtls-rprx-direct)"
+ echoContent green " trojan://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-direct#${email}\n"
+
+ echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(Trojan+TCP+TLS/xtls-rprx-direct)"
+ echoContent green "鍗忚绫诲瀷:Trojan锛屽湴鍧�:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:xtls锛屼紶杈撴柟寮�:tcp锛宖low:xtls-rprx-direct锛岃处鎴峰悕:${email}\n"
+ cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
+trojan://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-direct#${email}
+EOF
+ echoContent yellow " ---> 浜岀淮鐮� Trojan(Trojan+TCP+TLS/xtls-rprx-direct)"
+ 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-direct%23${email}\n"
+
+ echoContent skyBlue "----------------------------------------------------------------------------------"
+
+ echoContent yellow " ---> 閫氱敤鏍煎紡(Trojan+TCP+TLS/xtls-rprx-splice)"
+ echoContent green " trojan://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-splice#${email/direct/splice}\n"
+
+ echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(Trojan+TCP+TLS/xtls-rprx-splice)"
+ echoContent green " 鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:xtls锛屼紶杈撴柟寮�:tcp锛宖low:xtls-rprx-splice锛岃处鎴峰悕:${email/direct/splice}\n"
+ cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
+trojan://${id}@${currentHost}:${currentDefaultPort}?encryption=none&security=xtls&type=tcp&host=${currentHost}&headerType=none&sni=${currentHost}&flow=xtls-rprx-splice#${email/direct/splice}
+EOF
+ echoContent yellow " ---> 浜岀淮鐮� Trojan(Trojan+TCP+TLS/xtls-rprx-splice)"
+ 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-splice%23${email/direct/splice}\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\":\"${currentAdd}\",\"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\":\"${currentAdd}\",\"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)"
+
+ cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
+vmess://${qrCodeBase64Default}
+EOF
+ echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vmess://${qrCodeBase64Default}\n"
+
+ # elif [[ "${type}" == "vmesstcp" ]]; then
+ #
+ # echoContent red "path:${path}"
+ # qrCodeBase64Default=$(echo -n "{\"add\":\"${add}\",\"aid\":0,\"host\":\"${host}\",\"id\":\"${id}\",\"net\":\"tcp\",\"path\":\"${path}\",\"port\":${port},\"ps\":\"${email}\",\"scy\":\"none\",\"sni\":\"${host}\",\"tls\":\"tls\",\"v\":2,\"type\":\"http\",\"allowInsecure\":0,\"peer\":\"${host}\",\"obfs\":\"http\",\"obfsParam\":\"${host}\"}" | base64)
+ # qrCodeBase64Default="${qrCodeBase64Default// /}"
+ #
+ # echoContent yellow " ---> 閫氱敤json(VMess+TCP+TLS)"
+ # echoContent green " {\"port\":'${port}',\"ps\":\"${email}\",\"tls\":\"tls\",\"id\":\"${id}\",\"aid\":0,\"v\":2,\"host\":\"${host}\",\"type\":\"http\",\"path\":\"${path}\",\"net\":\"http\",\"add\":\"${add}\",\"allowInsecure\":0,\"method\":\"post\",\"peer\":\"${host}\",\"obfs\":\"http\",\"obfsParam\":\"${host}\"}\n"
+ # echoContent yellow " ---> 閫氱敤vmess(VMess+TCP+TLS)閾炬帴"
+ # echoContent green " vmess://${qrCodeBase64Default}\n"
+ #
+ # cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
+ #vmess://${qrCodeBase64Default}
+ #EOF
+ # echoContent yellow " ---> 浜岀淮鐮� vmess(VMess+TCP+TLS)"
+ # echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vmess://${qrCodeBase64Default}\n"
+
+ elif [[ "${type}" == "vlessws" ]]; then
+
+ echoContent yellow " ---> 閫氱敤鏍煎紡(VLESS+WS+TLS)"
+ echoContent green " vless://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&security=tls&type=ws&host=${currentHost}&sni=${currentHost}&path=/${currentPath}ws#${email}\n"
+
+ echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(VLESS+WS+TLS)"
+ echoContent green " 鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentAdd}锛屼吉瑁呭煙鍚�/SNI:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:tls锛屼紶杈撴柟寮�:ws锛岃矾寰�:/${currentPath}ws锛岃处鎴峰悕:${email}\n"
+
+ cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
+vless://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&security=tls&type=ws&host=${currentHost}&sni=${currentHost}&path=/${currentPath}ws#${email}
+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${currentAdd}%3A${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dws%26host%3D${currentHost}%26sni%3D${currentHost}%26path%3D%252f${currentPath}ws%23${email}"
+
+ elif [[ "${type}" == "vlessgrpc" ]]; then
+
+ echoContent yellow " ---> 閫氱敤鏍煎紡(VLESS+gRPC+TLS)"
+ echoContent green " vless://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&security=tls&type=grpc&host=${currentHost}&path=${currentPath}grpc&serviceName=${currentPath}grpc&alpn=h2&sni=${currentHost}#${email}\n"
+
+ echoContent yellow " ---> 鏍煎紡鍖栨槑鏂�(VLESS+gRPC+TLS)"
+ echoContent green " 鍗忚绫诲瀷:VLESS锛屽湴鍧�:${currentAdd}锛屼吉瑁呭煙鍚�/SNI:${currentHost}锛岀鍙�:${currentDefaultPort}锛岀敤鎴稩D:${id}锛屽畨鍏�:tls锛屼紶杈撴柟寮�:gRPC锛宎lpn:h2锛宻erviceName:${currentPath}grpc锛岃处鎴峰悕:${email}\n"
+
+ cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
+vless://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&security=tls&type=grpc&host=${currentHost}&path=${currentPath}grpc&serviceName=${currentPath}grpc&alpn=h2&sni=${currentHost}#${email}
+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${currentAdd}%3A${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dtls%26type%3Dgrpc%26host%3D${currentHost}%26serviceName%3D${currentPath}grpc%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}&sni=${currentHost}&alpn=http/1.1#${currentHost}_Trojan\n"
+
+ cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
+trojan://${id}@${currentHost}:${currentDefaultPort}?peer=${currentHost}&sni=${currentHost}&alpn=http/1.1#${email}_Trojan
+EOF
+ echoContent yellow " ---> 浜岀淮鐮� Trojan(TLS)"
+ echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${currentHost}%3a${port}%3fpeer%3d${currentHost}%26sni%3d${currentHost}%26alpn%3Dhttp/1.1%23${email}\n"
+
+ elif [[ "${type}" == "trojangrpc" ]]; then
+ # URLEncode
+
+ echoContent yellow " ---> Trojan gRPC(TLS)"
+ echoContent green " trojan://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&peer=${currentHost}&security=tls&type=grpc&sni=${currentHost}&alpn=h2&path=${currentPath}trojangrpc&serviceName=${currentPath}trojangrpc#${email}\n"
+ cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
+trojan://${id}@${currentAdd}:${currentDefaultPort}?encryption=none&peer=${currentHost}&security=tls&type=grpc&sni=${currentHost}&alpn=h2&path=${currentPath}trojangrpc&serviceName=${currentPath}trojangrpc#${email}
+EOF
+ echoContent yellow " ---> 浜岀淮鐮� Trojan gRPC(TLS)"
+ echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3a%2f%2f${id}%40${currentAdd}%3a${currentDefaultPort}%3Fencryption%3Dnone%26security%3Dtls%26peer%3d${currentHost}%26type%3Dgrpc%26sni%3d${currentHost}%26path%3D${currentPath}trojangrpc%26alpn%3Dh2%26serviceName%3D${currentPath}trojangrpc%23${email}\n"
+ fi
+
+}
+
+# 璐﹀彿
+showAccounts() {
+ readInstallType
+ readInstallProtocolType
+ readConfigHostPathUUID
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 璐﹀彿"
+ local show
+ # VLESS TCP
+ if [[ -n "${configPath}" ]]; then
+ show=1
+ if echo "${currentInstallProtocolType}" | grep -q trojan; then
+ echoContent skyBlue "===================== Trojan TCP TLS/XTLS-direct/XTLS-splice ======================\n"
+ jq .inbounds[0].settings.clients ${configPath}02_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
+ echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
+ defaultBase64Code trojanTCPXTLS "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .password)"
+ done
+
+ else
+ echoContent skyBlue "===================== VLESS TCP TLS/XTLS-direct/XTLS-splice ======================\n"
+ jq .inbounds[0].settings.clients ${configPath}02_VLESS_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
+ echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
+ echo
+ defaultBase64Code vlesstcp "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
+ done
+ fi
+
+ # VLESS WS
+ if echo ${currentInstallProtocolType} | grep -q 1; then
+ echoContent skyBlue "\n================================ VLESS WS TLS CDN ================================\n"
+
+ jq .inbounds[0].settings.clients ${configPath}03_VLESS_WS_inbounds.json | jq -c '.[]' | while read -r user; do
+ echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
+ echo
+ local path="${currentPath}ws"
+ # if [[ ${coreInstallType} == "1" ]]; then
+ # echoContent yellow "Xray鐨�0-RTT path鍚庨潰浼氭湁锛屼笉鍏煎浠2ray涓烘牳蹇冪殑瀹㈡埛绔紝璇锋墜鍔ㄥ垹闄ゅ悗浣跨敤\n"
+ # path="${currentPath}ws"
+ # fi
+ defaultBase64Code vlessws "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
+ done
+ fi
+
+ # VMess WS
+ if echo ${currentInstallProtocolType} | grep -q 3; then
+ echoContent skyBlue "\n================================ VMess WS TLS CDN ================================\n"
+ local path="${currentPath}vws"
+ if [[ ${coreInstallType} == "1" ]]; then
+ path="${currentPath}vws"
+ fi
+ jq .inbounds[0].settings.clients ${configPath}05_VMess_WS_inbounds.json | jq -c '.[]' | while read -r user; do
+ echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
+ echo
+ defaultBase64Code vmessws "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
+ done
+ fi
+
+ # VLESS grpc
+ if echo ${currentInstallProtocolType} | grep -q 5; then
+ echoContent skyBlue "\n=============================== VLESS gRPC TLS CDN ===============================\n"
+ echoContent red "\n --->gRPC澶勪簬娴嬭瘯闃舵锛屽彲鑳藉浣犱娇鐢ㄧ殑瀹㈡埛绔笉鍏煎锛屽涓嶈兘浣跨敤璇峰拷鐣�"
+ # local serviceName
+ # serviceName=$(jq -r .inbounds[0].streamSettings.grpcSettings.serviceName ${configPath}06_VLESS_gRPC_inbounds.json)
+ jq .inbounds[0].settings.clients ${configPath}06_VLESS_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do
+ echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
+ echo
+ defaultBase64Code vlessgrpc "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)"
+ done
+ fi
+ fi
+
+ # trojan tcp
+ if echo ${currentInstallProtocolType} | grep -q 4; then
+ echoContent skyBlue "\n================================== Trojan TLS ==================================\n"
+ jq .inbounds[0].settings.clients ${configPath}04_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
+ echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
+
+ defaultBase64Code trojan "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .password)"
+ done
+ fi
+
+ if echo ${currentInstallProtocolType} | grep -q 2; then
+ echoContent skyBlue "\n================================ Trojan gRPC TLS ================================\n"
+ echoContent red "\n --->gRPC澶勪簬娴嬭瘯闃舵锛屽彲鑳藉浣犱娇鐢ㄧ殑瀹㈡埛绔笉鍏煎锛屽涓嶈兘浣跨敤璇峰拷鐣�"
+ # local serviceName=
+ # serviceName=$(jq -r .inbounds[0].streamSettings.grpcSettings.serviceName ${configPath}04_trojan_gRPC_inbounds.json)
+ jq .inbounds[0].settings.clients ${configPath}04_trojan_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do
+ echoContent skyBlue "\n ---> 甯愬彿:$(echo "${user}" | jq -r .email)"
+ echo
+ defaultBase64Code trojangrpc "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .password)"
+ done
+ fi
+
+ if [[ -z ${show} ]]; then
+ echoContent red " ---> 鏈畨瑁�"
+ fi
+}
+# 绉婚櫎nginx302閰嶇疆
+removeNginx302() {
+ # 鏌ユ壘鍒�302閭h骞跺垹闄�
+ # local line302Result=
+ # line302Result=$(grep -n "return 302" </etc/nginx/conf.d/alone.conf | tail -n 1)
+ local count=0
+ grep -n "return 302" <"/etc/nginx/conf.d/alone.conf" | while read -r line; do
+
+ if ! echo "${line}" | grep -q "request_uri"; then
+ local removeIndex=
+ removeIndex=$(echo "${line}" | awk -F "[:]" '{print $1}')
+ removeIndex=$((removeIndex + count))
+ sed -i "${removeIndex}d" /etc/nginx/conf.d/alone.conf
+ count=$((count - 1))
+ fi
+ done
+}
+
+# 妫�鏌�302鏄惁鎴愬姛
+checkNginx302() {
+ local domain302Status=
+ domain302Status=$(curl -s "https://${currentHost}")
+ if echo "${domain302Status}" | grep -q "302"; then
+ local domain302Result=
+ domain302Result=$(curl -L -s "https://${currentHost}")
+ if [[ -n "${domain302Result}" ]]; then
+ echoContent green " ---> 302閲嶅畾鍚戣缃垚鍔�"
+ exit 0
+ fi
+ fi
+ echoContent red " ---> 302閲嶅畾鍚戣缃け璐ワ紝璇蜂粩缁嗘鏌ユ槸鍚﹀拰绀轰緥鐩稿悓"
+ backupNginxConfig restoreBackup
+}
+
+# 澶囦唤鎭㈠nginx鏂囦欢
+backupNginxConfig() {
+ if [[ "$1" == "backup" ]]; then
+ cp /etc/nginx/conf.d/alone.conf /etc/v2ray-agent/alone_backup.conf
+ echoContent green " ---> nginx閰嶇疆鏂囦欢澶囦唤鎴愬姛"
+ fi
+
+ if [[ "$1" == "restoreBackup" ]] && [[ -f "/etc/v2ray-agent/alone_backup.conf" ]]; then
+ cp /etc/v2ray-agent/alone_backup.conf /etc/nginx/conf.d/alone.conf
+ echoContent green " ---> nginx閰嶇疆鏂囦欢鎭㈠澶囦唤鎴愬姛"
+ rm /etc/v2ray-agent/alone_backup.conf
+ fi
+
+}
+# 娣诲姞302閰嶇疆
+addNginx302() {
+ # local line302Result=
+ # line302Result=$(| tail -n 1)
+ local count=1
+ grep -n "Strict-Transport-Security" <"/etc/nginx/conf.d/alone.conf" | while read -r line; do
+ if [[ -n "${line}" ]]; then
+ local insertIndex=
+ insertIndex="$(echo "${line}" | awk -F "[:]" '{print $1}')"
+ insertIndex=$((insertIndex + count))
+ sed "${insertIndex}i return 302 '$1';" /etc/nginx/conf.d/alone.conf >/etc/nginx/conf.d/tmpfile && mv /etc/nginx/conf.d/tmpfile /etc/nginx/conf.d/alone.conf
+ count=$((count + 1))
+ else
+ echoContent red " ---> 302娣诲姞澶辫触"
+ backupNginxConfig restoreBackup
+ fi
+
+ done
+}
+
+# 鏇存柊浼绔�
+updateNginxBlog() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鏇存崲浼绔欑偣"
+ echoContent red "=============================================================="
+ echoContent yellow "# 濡傞渶鑷畾涔夛紝璇锋墜鍔ㄥ鍒舵ā鐗堟枃浠跺埌 /usr/share/nginx/html \n"
+ echoContent yellow "1.鏂版墜寮曞"
+ echoContent yellow "2.娓告垙缃戠珯"
+ echoContent yellow "3.涓汉鍗氬01"
+ echoContent yellow "4.浼佷笟绔�"
+ echoContent yellow "5.瑙i攣鍔犲瘑鐨勯煶涔愭枃浠舵ā鐗圼https://github.com/ix64/unlock-music]"
+ echoContent yellow "6.mikutap[https://github.com/HFIProgramming/mikutap]"
+ echoContent yellow "7.浼佷笟绔�02"
+ echoContent yellow "8.涓汉鍗氬02"
+ echoContent yellow "9.404鑷姩璺宠浆baidu"
+ echoContent yellow "10.302閲嶅畾鍚戠綉绔�"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" selectInstallNginxBlogType
+
+ if [[ "${selectInstallNginxBlogType}" == "10" ]]; then
+ echoContent red "\n=============================================================="
+ echoContent yellow "閲嶅畾鍚戠殑浼樺厛绾ф洿楂橈紝閰嶇疆302涔嬪悗濡傛灉鏇存敼浼绔欑偣锛屾牴璺敱涓嬩吉瑁呯珯鐐瑰皢涓嶈捣浣滅敤"
+ echoContent yellow "濡傛兂瑕佷吉瑁呯珯鐐瑰疄鐜颁綔鐢ㄩ渶鍒犻櫎302閲嶅畾鍚戦厤缃甛n"
+ echoContent yellow "1.娣诲姞"
+ echoContent yellow "2.鍒犻櫎"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" redirectStatus
+
+ if [[ "${redirectStatus}" == "1" ]]; then
+ backupNginxConfig backup
+ read -r -p "璇疯緭鍏ヨ閲嶅畾鍚戠殑鍩熷悕,渚嬪 https://www.baidu.com:" redirectDomain
+ removeNginx302
+ addNginx302 "${redirectDomain}"
+ handleNginx stop
+ handleNginx start
+ if [[ -z $(pgrep -f nginx) ]]; then
+ backupNginxConfig restoreBackup
+ handleNginx start
+ exit 0
+ fi
+ checkNginx302
+ exit 0
+ fi
+ if [[ "${redirectStatus}" == "2" ]]; then
+ removeNginx302
+ echoContent green " ---> 绉婚櫎302閲嶅畾鍚戞垚鍔�"
+ exit 0
+ fi
+ fi
+ if [[ "${selectInstallNginxBlogType}" =~ ^[1-9]$ ]]; then
+ rm -rf /usr/share/nginx/*
+ if wget --help | grep -q show-progress; then
+ wget -c -q --show-progress -P /usr/share/nginx "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${selectInstallNginxBlogType}.zip" >/dev/null
+ else
+ wget -c -P /usr/share/nginx "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/fodder/blog/unable/html${selectInstallNginxBlogType}.zip" >/dev/null
+ fi
+
+ unzip -o "/usr/share/nginx/html${selectInstallNginxBlogType}.zip" -d /usr/share/nginx/html >/dev/null
+ rm -f "/usr/share/nginx/html${selectInstallNginxBlogType}.zip*"
+ echoContent green " ---> 鏇存崲浼珯鎴愬姛"
+ else
+ echoContent red " ---> 閫夋嫨閿欒锛岃閲嶆柊閫夋嫨"
+ updateNginxBlog
+ fi
+}
+
+# 娣诲姞鏂扮鍙�
+addCorePort() {
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 娣诲姞鏂扮鍙�"
+ echoContent red "\n=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」\n"
+ echoContent yellow "鏀寔鎵归噺娣诲姞"
+ echoContent yellow "涓嶅奖鍝�443绔彛鐨勪娇鐢�"
+ echoContent yellow "鏌ョ湅甯愬彿鏃讹紝鍙細灞曠ず榛樿绔彛443鐨勫笎鍙�"
+ echoContent yellow "涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
+ echoContent yellow "褰曞叆绀轰緥:2053,2083,2087\n"
+
+ echoContent yellow "1.娣诲姞绔彛"
+ echoContent yellow "2.鍒犻櫎绔彛"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" selectNewPortType
+ if [[ "${selectNewPortType}" == "1" ]]; then
+ read -r -p "璇疯緭鍏ョ鍙e彿:" newPort
+ read -r -p "璇疯緭鍏ラ粯璁ょ殑绔彛鍙凤紝鍚屾椂浼氭洿鏀硅闃呯鍙d互鍙婅妭鐐圭鍙o紝[鍥炶溅]榛樿443:" defaultPort
+
+ if [[ -n "${defaultPort}" ]]; then
+ rm -rf "$(find ${configPath}* | grep "default")"
+ fi
+
+ if [[ -n "${newPort}" ]]; then
+
+ while read -r port; do
+ rm -rf "$(find ${configPath}* | grep "${port}")"
+
+ local fileName=
+ if [[ -n "${defaultPort}" && "${port}" == "${defaultPort}" ]]; then
+ fileName="${configPath}02_dokodemodoor_inbounds_${port}_default.json"
+ else
+ fileName="${configPath}02_dokodemodoor_inbounds_${port}.json"
+ fi
+
+ # 寮�鏀剧鍙�
+ allowPort "${port}"
+
+ cat <<EOF >"${fileName}"
+{
+ "inbounds": [
+ {
+ "listen": "0.0.0.0",
+ "port": ${port},
+ "protocol": "dokodemo-door",
+ "settings": {
+ "address": "127.0.0.1",
+ "port": 443,
+ "network": "tcp",
+ "followRedirect": false
+ },
+ "tag": "dokodemo-door-newPort-${port}"
+ }
+ ]
+}
+EOF
+ done < <(echo "${newPort}" | tr ',' '\n')
+
+ echoContent green " ---> 娣诲姞鎴愬姛"
+ reloadCore
+ fi
+ elif [[ "${selectNewPortType}" == "2" ]]; then
+
+ find ${configPath} -name "*dokodemodoor*" | awk -F "[c][o][n][f][/]" '{print ""NR""":"$2}'
+ read -r -p "璇疯緭鍏ヨ鍒犻櫎鐨勭鍙g紪鍙�:" portIndex
+ local dokoConfig
+ dokoConfig=$(find ${configPath} -name "*dokodemodoor*" | awk -F "[c][o][n][f][/]" '{print ""NR""":"$2}' | grep "${portIndex}:")
+ if [[ -n "${dokoConfig}" ]]; then
+ rm "${configPath}/$(echo "${dokoConfig}" | awk -F "[:]" '{print $2}')"
+ reloadCore
+ else
+ echoContent yellow "\n ---> 缂栧彿杈撳叆閿欒锛岃閲嶆柊閫夋嫨"
+ addCorePort
+ fi
+ fi
+}
+
+# 鍗歌浇鑴氭湰
+unInstall() {
+ read -r -p "鏄惁纭鍗歌浇瀹夎鍐呭锛焄y/n]:" unInstallStatus
+ if [[ "${unInstallStatus}" != "y" ]]; then
+ echoContent green " ---> 鏀惧純鍗歌浇"
+ menu
+ exit 0
+ fi
+
+ handleNginx stop
+ if [[ -z $(pgrep -f "nginx") ]]; then
+ echoContent green " ---> 鍋滄Nginx鎴愬姛"
+ fi
+
+ if [[ "${coreInstallType}" == "1" ]]; then
+ handleXray stop
+ rm -rf /etc/systemd/system/xray.service
+ echoContent green " ---> 鍒犻櫎Xray寮�鏈鸿嚜鍚畬鎴�"
+
+ elif [[ "${coreInstallType}" == "2" ]]; then
+
+ handleV2Ray stop
+ rm -rf /etc/systemd/system/v2ray.service
+ echoContent green " ---> 鍒犻櫎V2Ray寮�鏈鸿嚜鍚畬鎴�"
+
+ fi
+
+ if [[ -f "/root/.acme.sh/acme.sh.env" ]] && grep -q 'acme.sh.env' </root/.bashrc; then
+ sed -i 's/. "\/root\/.acme.sh\/acme.sh.env"//g' "$(grep '. "/root/.acme.sh/acme.sh.env"' -rl /root/.bashrc)"
+ fi
+ rm -rf /root/.acme.sh
+ echoContent green " ---> 鍒犻櫎acme.sh瀹屾垚"
+
+ rm -rf /tmp/v2ray-agent-tls/*
+ if [[ -d "/etc/v2ray-agent/tls" ]] && [[ -n $(find /etc/v2ray-agent/tls/ -name "*.key") ]] && [[ -n $(find /etc/v2ray-agent/tls/ -name "*.crt") ]]; then
+ mv /etc/v2ray-agent/tls /tmp/v2ray-agent-tls
+ if [[ -n $(find /tmp/v2ray-agent-tls -name '*.key') ]]; then
+ echoContent yellow " ---> 澶囦唤璇佷功鎴愬姛锛岃娉ㄦ剰鐣欏瓨銆俒/tmp/v2ray-agent-tls]"
+ fi
+ fi
+
+ rm -rf /etc/v2ray-agent
+ rm -rf ${nginxConfigPath}alone.conf
+
+ if [[ -d "/usr/share/nginx/html" && -f "/usr/share/nginx/html/check" ]]; then
+ rm -rf /usr/share/nginx/html
+ echoContent green " ---> 鍒犻櫎浼缃戠珯瀹屾垚"
+ fi
+
+ rm -rf /usr/bin/vasma
+ rm -rf /usr/sbin/vasma
+ echoContent green " ---> 鍗歌浇蹇嵎鏂瑰紡瀹屾垚"
+ echoContent green " ---> 鍗歌浇v2ray-agent鑴氭湰瀹屾垚"
+}
+
+# 淇敼V2Ray CDN鑺傜偣
+updateV2RayCDN() {
+
+ # todo 閲嶆瀯姝ゆ柟娉�
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 淇敼CDN鑺傜偣"
+
+ if [[ -n "${currentAdd}" ]]; then
+ echoContent red "=============================================================="
+ echoContent yellow "1.CNAME www.digitalocean.com"
+ echoContent yellow "2.CNAME www.cloudflare.com"
+ echoContent yellow "3.CNAME hostmonit.com"
+ echoContent yellow "4.鎵嬪姩杈撳叆"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" selectCDNType
+ case ${selectCDNType} in
+ 1)
+ setDomain="www.digitalocean.com"
+ ;;
+ 2)
+ setDomain="www.cloudflare.com"
+ ;;
+ 3)
+ setDomain="hostmonit.com"
+ ;;
+ 4)
+ read -r -p "璇疯緭鍏ユ兂瑕佽嚜瀹氫箟CDN IP鎴栬�呭煙鍚�:" setDomain
+ ;;
+ esac
+
+ if [[ -n ${setDomain} ]]; then
+ if [[ -n "${currentAdd}" ]]; then
+ sed -i "s/\"${currentAdd}\"/\"${setDomain}\"/g" "$(grep "${currentAdd}" -rl ${configPath}${frontingType}.json)"
+ fi
+ if [[ $(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json) == "${setDomain}" ]]; then
+ echoContent green " ---> CDN淇敼鎴愬姛"
+ reloadCore
+ else
+ echoContent red " ---> 淇敼CDN澶辫触"
+ fi
+ fi
+ else
+ 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
+}
+
+# 鑷畾涔塽uid
+customUUID() {
+ # read -r -p "鏄惁鑷畾涔塙UID 锛焄y/n]:" customUUIDStatus
+ # echo
+ # if [[ "${customUUIDStatus}" == "y" ]]; then
+ read -r -p "璇疯緭鍏ュ悎娉曠殑UUID锛孾鍥炶溅]闅忔満UUID:" currentCustomUUID
+ echo
+ if [[ -z "${currentCustomUUID}" ]]; then
+ # echoContent red " ---> UUID涓嶅彲涓虹┖"
+ currentCustomUUID=$(${ctlPath} uuid)
+ echoContent yellow "uuid:${currentCustomUUID}\n"
+
+ else
+ jq -r -c '.inbounds[0].settings.clients[].id' ${configPath}${frontingType}.json | while read -r line; do
+ if [[ "${line}" == "${currentCustomUUID}" ]]; then
+ echo >/tmp/v2ray-agent
+ fi
+ done
+ if [[ -f "/tmp/v2ray-agent" && -n $(cat /tmp/v2ray-agent) ]]; then
+ echoContent red " ---> UUID涓嶅彲閲嶅"
+ rm /tmp/v2ray-agent
+ exit 0
+ fi
+ fi
+ # fi
+}
+
+# 鑷畾涔塭mail
+customUserEmail() {
+ # read -r -p "鏄惁鑷畾涔塭mail 锛焄y/n]:" customEmailStatus
+ # echo
+ # if [[ "${customEmailStatus}" == "y" ]]; then
+ read -r -p "璇疯緭鍏ュ悎娉曠殑email锛孾鍥炶溅]闅忔満email:" currentCustomEmail
+ echo
+ if [[ -z "${currentCustomEmail}" ]]; then
+ currentCustomEmail="${currentHost}_${currentCustomUUID}"
+ echoContent yellow "email: ${currentCustomEmail}\n"
+ # echoContent red " ---> email涓嶅彲涓虹┖"
+ else
+ jq -r -c '.inbounds[0].settings.clients[].email' ${configPath}${frontingType}.json | while read -r line; do
+ if [[ "${line}" == "${currentCustomEmail}" ]]; then
+ echo >/tmp/v2ray-agent
+ fi
+ done
+ if [[ -f "/tmp/v2ray-agent" && -n $(cat /tmp/v2ray-agent) ]]; then
+ echoContent red " ---> email涓嶅彲閲嶅"
+ rm /tmp/v2ray-agent
+ exit 0
+ fi
+ fi
+ # fi
+}
+
+# 娣诲姞鐢ㄦ埛
+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}
+ else
+ email=${currentHost}_${uuid}
+ fi
+
+ # 鍏煎v2ray-core
+ users="{\"id\":\"${uuid}\",\"flow\":\"xtls-rprx-direct\",\"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/}"
+
+ 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//"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//\"flow\":\"xtls-rprx-direct\"\,/}"
+ 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-direct\"\,/}"
+ 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-direct\"\,/}"
+
+ 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-direct\"\,/}"
+ vlessGRPCUsers="${vlessGRPCUsers//\,\"alterId\":0/}"
+
+ 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-direct\"\,/}"
+ trojanUsers="${trojanUsers//id/password}"
+ trojanUsers="${trojanUsers//\,\"alterId\":0/}"
+
+ 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
+ done
+
+ reloadCore
+ echoContent green " ---> 娣诲姞瀹屾垚"
+ manageAccount 1
+}
+
+# 绉婚櫎鐢ㄦ埛
+removeUser() {
+
+ 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
+ vlessTcpResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}${frontingType}.json)
+ echo "${vlessTcpResult}" | jq . >${configPath}${frontingType}.json
+ fi
+ fi
+ if [[ -n "${delUserIndex}" ]]; then
+ if echo ${currentInstallProtocolType} | grep -q 1; then
+ local vlessWSResult
+ vlessWSResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${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
+ trojangRPCUsers=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}04_trojan_gRPC_inbounds.json)
+ echo "${trojangRPCUsers}" | jq . >${configPath}04_trojan_gRPC_inbounds.json
+ fi
+
+ if echo ${currentInstallProtocolType} | grep -q 3; then
+ local vmessWSResult
+ vmessWSResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}05_VMess_WS_inbounds.json)
+ echo "${vmessWSResult}" | jq . >${configPath}05_VMess_WS_inbounds.json
+ fi
+
+ if echo ${currentInstallProtocolType} | grep -q 5; then
+ local vlessGRPCResult
+ vlessGRPCResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}06_VLESS_gRPC_inbounds.json)
+ echo "${vlessGRPCResult}" | jq . >${configPath}06_VLESS_gRPC_inbounds.json
+ fi
+
+ if echo ${currentInstallProtocolType} | grep -q 4; then
+ local trojanTCPResult
+ trojanTCPResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}04_trojan_TCP_inbounds.json)
+ echo "${trojanTCPResult}" | jq . >${configPath}04_trojan_TCP_inbounds.json
+ fi
+
+ reloadCore
+ fi
+ manageAccount 1
+}
+# 鏇存柊鑴氭湰
+updateV2RayAgent() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鏇存柊v2ray-agent鑴氭湰"
+ rm -rf /etc/v2ray-agent/install.sh
+ if wget --help | grep -q show-progress; then
+ wget -c -q --show-progress -P /etc/v2ray-agent/ -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh"
+ else
+ wget -c -q -P /etc/v2ray-agent/ -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh"
+ fi
+
+ sudo chmod 700 /etc/v2ray-agent/install.sh
+ local version
+ version=$(grep '褰撳墠鐗堟湰:v' "/etc/v2ray-agent/install.sh" | awk -F "[v]" '{print $2}' | tail -n +2 | head -n 1 | awk -F "[\"]" '{print $1}')
+
+ echoContent green "\n ---> 鏇存柊瀹屾瘯"
+ echoContent yellow " ---> 璇锋墜鍔ㄦ墽琛孾vasma]鎵撳紑鑴氭湰"
+ echoContent green " ---> 褰撳墠鐗堟湰:${version}\n"
+ echoContent yellow "濡傛洿鏂颁笉鎴愬姛锛岃鎵嬪姩鎵ц涓嬮潰鍛戒护\n"
+ echoContent skyBlue "wget -P /root -N --no-check-certificate https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh && chmod 700 /root/install.sh && /root/install.sh"
+ echo
+ exit 0
+}
+
+# 闃茬伀澧�
+handleFirewall() {
+ if systemctl status ufw 2>/dev/null | grep -q "active (exited)" && [[ "$1" == "stop" ]]; then
+ systemctl stop ufw >/dev/null 2>&1
+ systemctl disable ufw >/dev/null 2>&1
+ echoContent green " ---> ufw鍏抽棴鎴愬姛"
+
+ fi
+
+ if systemctl status firewalld 2>/dev/null | grep -q "active (running)" && [[ "$1" == "stop" ]]; then
+ systemctl stop firewalld >/dev/null 2>&1
+ systemctl disable firewalld >/dev/null 2>&1
+ echoContent green " ---> firewalld鍏抽棴鎴愬姛"
+ fi
+}
+
+# 瀹夎BBR
+bbrInstall() {
+ echoContent red "\n=============================================================="
+ echoContent green "BBR銆丏D鑴氭湰鐢ㄧ殑[ylx2016]鐨勬垚鐔熶綔鍝侊紝鍦板潃[https://github.com/ylx2016/Linux-NetSpeed]锛岃鐔熺煡"
+ echoContent yellow "1.瀹夎鑴氭湰銆愭帹鑽愬師鐗圔BR+FQ銆�"
+ echoContent yellow "2.鍥為��涓荤洰褰�"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" installBBRStatus
+ if [[ "${installBBRStatus}" == "1" ]]; then
+ wget -N --no-check-certificate "https://raw.githubusercontent.com/ylx2016/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
+ else
+ menu
+ fi
+}
+
+# 鏌ョ湅銆佹鏌ユ棩蹇�
+checkLog() {
+ if [[ -z ${configPath} ]]; then
+ echoContent red " ---> 娌℃湁妫�娴嬪埌瀹夎鐩綍锛岃鎵ц鑴氭湰瀹夎鍐呭"
+ fi
+ local logStatus=false
+ if grep -q "access" ${configPath}00_log.json; then
+ logStatus=true
+ fi
+
+ echoContent skyBlue "\n鍔熻兘 $1/${totalProgress} : 鏌ョ湅鏃ュ織"
+ echoContent red "\n=============================================================="
+ echoContent yellow "# 寤鸿浠呰皟璇曟椂鎵撳紑access鏃ュ織\n"
+
+ if [[ "${logStatus}" == "false" ]]; then
+ echoContent yellow "1.鎵撳紑access鏃ュ織"
+ else
+ echoContent yellow "1.鍏抽棴access鏃ュ織"
+ fi
+
+ echoContent yellow "2.鐩戝惉access鏃ュ織"
+ echoContent yellow "3.鐩戝惉error鏃ュ織"
+ echoContent yellow "4.鏌ョ湅璇佷功瀹氭椂浠诲姟鏃ュ織"
+ echoContent yellow "5.鏌ョ湅璇佷功瀹夎鏃ュ織"
+ echoContent yellow "6.娓呯┖鏃ュ織"
+ echoContent red "=============================================================="
+
+ read -r -p "璇烽�夋嫨:" selectAccessLogType
+ local configPathLog=${configPath//conf\//}
+
+ case ${selectAccessLogType} in
+ 1)
+ if [[ "${logStatus}" == "false" ]]; then
+ cat <<EOF >${configPath}00_log.json
+{
+ "log": {
+ "access":"${configPathLog}access.log",
+ "error": "${configPathLog}error.log",
+ "loglevel": "debug"
+ }
+}
+EOF
+ elif [[ "${logStatus}" == "true" ]]; then
+ cat <<EOF >${configPath}00_log.json
+{
+ "log": {
+ "error": "${configPathLog}error.log",
+ "loglevel": "warning"
+ }
+}
+EOF
+ fi
+ reloadCore
+ checkLog 1
+ ;;
+ 2)
+ tail -f ${configPathLog}access.log
+ ;;
+ 3)
+ tail -f ${configPathLog}error.log
+ ;;
+ 4)
+ tail -n 100 /etc/v2ray-agent/crontab_tls.log
+ ;;
+ 5)
+ tail -n 100 /etc/v2ray-agent/tls/acme.log
+ ;;
+ 6)
+ echo >${configPathLog}access.log
+ echo >${configPathLog}error.log
+ ;;
+ esac
+}
+
+# 鑴氭湰蹇嵎鏂瑰紡
+aliasInstall() {
+
+ if [[ -f "$HOME/install.sh" ]] && [[ -d "/etc/v2ray-agent" ]] && grep <"$HOME/install.sh" -q "浣滆��:mack-a"; then
+ mv "$HOME/install.sh" /etc/v2ray-agent/install.sh
+ local vasmaType=
+ if [[ -d "/usr/bin/" ]]; then
+ if [[ ! -f "/usr/bin/vasma" ]]; then
+ ln -s /etc/v2ray-agent/install.sh /usr/bin/vasma
+ chmod 700 /usr/bin/vasma
+ vasmaType=true
+ fi
+
+ rm -rf "$HOME/install.sh"
+ elif [[ -d "/usr/sbin" ]]; then
+ if [[ ! -f "/usr/sbin/vasma" ]]; then
+ ln -s /etc/v2ray-agent/install.sh /usr/sbin/vasma
+ chmod 700 /usr/sbin/vasma
+ vasmaType=true
+ fi
+ rm -rf "$HOME/install.sh"
+ fi
+ if [[ "${vasmaType}" == "true" ]]; then
+ echoContent green "蹇嵎鏂瑰紡鍒涘缓鎴愬姛锛屽彲鎵ц[vasma]閲嶆柊鎵撳紑鑴氭湰"
+ fi
+ fi
+}
+
+# 妫�鏌pv6銆乮pv4
+checkIPv6() {
+ # pingIPv6=$(ping6 -c 1 www.google.com | sed '2{s/[^(]*(//;s/).*//;q;}' | tail -n +2)
+ pingIPv6=$(ping6 -c 1 www.google.com | sed -n '1p' | sed 's/.*(//g;s/).*//g')
+
+ if [[ -z "${pingIPv6}" ]]; then
+ echoContent red " ---> 涓嶆敮鎸乮pv6"
+ exit 0
+ fi
+}
+
+# ipv6 鍒嗘祦
+ipv6Routing() {
+ if [[ -z "${configPath}" ]]; then
+ echoContent red " ---> 鏈畨瑁咃紝璇蜂娇鐢ㄨ剼鏈畨瑁�"
+ menu
+ exit 0
+ fi
+
+ checkIPv6
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : IPv6鍒嗘祦"
+ echoContent red "\n=============================================================="
+ echoContent yellow "1.娣诲姞鍩熷悕"
+ echoContent yellow "2.鍗歌浇IPv6鍒嗘祦"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" ipv6Status
+ if [[ "${ipv6Status}" == "1" ]]; then
+ echoContent red "=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」\n"
+ echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
+ echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
+ echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
+ echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
+ echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
+ echoContent yellow "6.褰曞叆绀轰緥:google,youtube,facebook\n"
+ read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
+
+ if [[ -f "${configPath}09_routing.json" ]]; then
+
+ unInstallRouting IPv6-out outboundTag
+
+ routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"domain\":[\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"IPv6-out\"}]" ${configPath}09_routing.json)
+
+ echo "${routing}" | jq . >${configPath}09_routing.json
+
+ else
+ cat <<EOF >"${configPath}09_routing.json"
+{
+ "routing":{
+ "domainStrategy": "IPOnDemand",
+ "rules": [
+ {
+ "type": "field",
+ "domain": [
+ "geosite:${domainList//,/\",\"geosite:}"
+ ],
+ "outboundTag": "IPv6-out"
+ }
+ ]
+ }
+}
+EOF
+ fi
+
+ unInstallOutbounds IPv6-out
+
+ 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
+
+ echoContent green " ---> 娣诲姞鎴愬姛"
+
+ elif [[ "${ipv6Status}" == "2" ]]; then
+
+ unInstallRouting IPv6-out outboundTag
+
+ unInstallOutbounds IPv6-out
+
+ echoContent green " ---> IPv6鍒嗘祦鍗歌浇鎴愬姛"
+ else
+ echoContent red " ---> 閫夋嫨閿欒"
+ exit 0
+ fi
+
+ reloadCore
+}
+
+# bt涓嬭浇绠$悊
+btTools() {
+ if [[ -z "${configPath}" ]]; then
+ echoContent red " ---> 鏈畨瑁咃紝璇蜂娇鐢ㄨ剼鏈畨瑁�"
+ menu
+ exit 0
+ fi
+
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : bt涓嬭浇绠$悊"
+ echoContent red "\n=============================================================="
+
+ if [[ -f ${configPath}09_routing.json ]] && grep -q bittorrent <${configPath}09_routing.json; then
+ echoContent yellow "褰撳墠鐘舵��:宸茬鐢�"
+ else
+ echoContent yellow "褰撳墠鐘舵��:鏈鐢�"
+ fi
+
+ echoContent yellow "1.绂佺敤"
+ echoContent yellow "2.鎵撳紑"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" btStatus
+ if [[ "${btStatus}" == "1" ]]; then
+
+ if [[ -f "${configPath}09_routing.json" ]]; then
+
+ unInstallRouting blackhole-out outboundTag
+
+ routing=$(jq -r '.routing.rules += [{"type":"field","outboundTag":"blackhole-out","protocol":["bittorrent"]}]' ${configPath}09_routing.json)
+
+ echo "${routing}" | jq . >${configPath}09_routing.json
+
+ else
+ cat <<EOF >${configPath}09_routing.json
+{
+ "routing":{
+ "domainStrategy": "IPOnDemand",
+ "rules": [
+ {
+ "type": "field",
+ "outboundTag": "blackhole-out",
+ "protocol": [ "bittorrent" ]
+ }
+ ]
+ }
+}
+EOF
+ fi
+
+ installSniffing
+
+ unInstallOutbounds blackhole-out
+
+ outbounds=$(jq -r '.outbounds += [{"protocol":"blackhole","tag":"blackhole-out"}]' ${configPath}10_ipv4_outbounds.json)
+
+ echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
+
+ echoContent green " ---> BT涓嬭浇绂佺敤鎴愬姛"
+
+ elif [[ "${btStatus}" == "2" ]]; then
+
+ unInstallSniffing
+
+ unInstallRouting blackhole-out outboundTag bittorrent
+
+ # unInstallOutbounds blackhole-out
+
+ echoContent green " ---> BT涓嬭浇鎵撳紑鎴愬姛"
+ else
+ echoContent red " ---> 閫夋嫨閿欒"
+ exit 0
+ fi
+
+ reloadCore
+}
+
+# 鍩熷悕榛戝悕鍗�
+blacklist() {
+ if [[ -z "${configPath}" ]]; then
+ echoContent red " ---> 鏈畨瑁咃紝璇蜂娇鐢ㄨ剼鏈畨瑁�"
+ menu
+ exit 0
+ fi
+
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : 鍩熷悕榛戝悕鍗�"
+ echoContent red "\n=============================================================="
+ echoContent yellow "1.娣诲姞鍩熷悕"
+ echoContent yellow "2.鍒犻櫎榛戝悕鍗�"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" blacklistStatus
+ if [[ "${blacklistStatus}" == "1" ]]; then
+ echoContent red "=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」\n"
+ echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
+ echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
+ echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
+ echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
+ echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
+ echoContent yellow "6.褰曞叆绀轰緥:speedtest,facebook\n"
+ read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
+
+ if [[ -f "${configPath}09_routing.json" ]]; then
+ unInstallRouting blackhole-out outboundTag
+
+ routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"domain\":[\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"blackhole-out\"}]" ${configPath}09_routing.json)
+
+ echo "${routing}" | jq . >${configPath}09_routing.json
+
+ else
+ cat <<EOF >${configPath}09_routing.json
+{
+ "routing":{
+ "domainStrategy": "IPOnDemand",
+ "rules": [
+ {
+ "type": "field",
+ "domain": [
+ "geosite:${domainList//,/\",\"geosite:}"
+ ],
+ "outboundTag": "blackhole-out"
+ }
+ ]
+ }
+}
+EOF
+ fi
+
+ echoContent green " ---> 娣诲姞鎴愬姛"
+
+ elif [[ "${blacklistStatus}" == "2" ]]; then
+
+ unInstallRouting blackhole-out outboundTag
+
+ echoContent green " ---> 鍩熷悕榛戝悕鍗曞垹闄ゆ垚鍔�"
+ else
+ echoContent red " ---> 閫夋嫨閿欒"
+ exit 0
+ fi
+ reloadCore
+}
+
+# 鏍规嵁tag鍗歌浇Routing
+unInstallRouting() {
+ local tag=$1
+ local type=$2
+ local protocol=$3
+
+ if [[ -f "${configPath}09_routing.json" ]]; then
+ local routing
+ if grep -q "${tag}" ${configPath}09_routing.json && grep -q "${type}" ${configPath}09_routing.json; then
+
+ jq -c .routing.rules[] ${configPath}09_routing.json | while read -r line; do
+ local index=$((index + 1))
+ local delStatus=0
+ if [[ "${type}" == "outboundTag" ]] && echo "${line}" | jq .outboundTag | grep -q "${tag}"; then
+ delStatus=1
+ elif [[ "${type}" == "inboundTag" ]] && echo "${line}" | jq .inboundTag | grep -q "${tag}"; then
+ delStatus=1
+ fi
+
+ if [[ -n ${protocol} ]] && echo "${line}" | jq .protocol | grep -q "${protocol}"; then
+ delStatus=1
+ elif [[ -z ${protocol} ]] && [[ $(echo "${line}" | jq .protocol) != "null" ]]; then
+ delStatus=0
+ fi
+
+ if [[ ${delStatus} == 1 ]]; then
+ routing=$(jq -r 'del(.routing.rules['"$(("${index}" - 1))"'])' ${configPath}09_routing.json)
+ echo "${routing}" | jq . >${configPath}09_routing.json
+ fi
+ done
+ fi
+ fi
+}
+
+# 鏍规嵁tag鍗歌浇鍑虹珯
+unInstallOutbounds() {
+ local tag=$1
+
+ if grep -q "${tag}" ${configPath}10_ipv4_outbounds.json; then
+ local ipv6OutIndex
+ ipv6OutIndex=$(jq .outbounds[].tag ${configPath}10_ipv4_outbounds.json | awk '{print ""NR""":"$0}' | grep "${tag}" | awk -F "[:]" '{print $1}' | head -1)
+ if [[ ${ipv6OutIndex} -gt 0 ]]; then
+ routing=$(jq -r 'del(.outbounds['$(("${ipv6OutIndex}" - 1))'])' ${configPath}10_ipv4_outbounds.json)
+ echo "${routing}" | jq . >${configPath}10_ipv4_outbounds.json
+ fi
+ fi
+
+}
+
+# 鍗歌浇鍡呮帰
+unInstallSniffing() {
+
+ find ${configPath} -name "*inbounds.json*" | awk -F "[c][o][n][f][/]" '{print $2}' | while read -r inbound; do
+ sniffing=$(jq -r 'del(.inbounds[0].sniffing)' "${configPath}${inbound}")
+ echo "${sniffing}" | jq . >"${configPath}${inbound}"
+ done
+}
+
+# 瀹夎鍡呮帰
+installSniffing() {
+
+ find ${configPath} -name "*inbounds.json*" | awk -F "[c][o][n][f][/]" '{print $2}' | while read -r inbound; do
+ sniffing=$(jq -r '.inbounds[0].sniffing = {"enabled":true,"destOverride":["http","tls"]}' "${configPath}${inbound}")
+ echo "${sniffing}" | jq . >"${configPath}${inbound}"
+ done
+}
+
+# warp鍒嗘祦
+warpRouting() {
+ echoContent skyBlue "\n杩涘害 $1/${totalProgress} : WARP鍒嗘祦"
+ echoContent red "=============================================================="
+ # echoContent yellow "# 娉ㄦ剰浜嬮」\n"
+ # echoContent yellow "1.瀹樻柟warp缁忚繃鍑犺疆娴嬭瘯鏈塨ug锛岄噸鍚細瀵艰嚧warp澶辨晥锛屽苟涓旀棤娉曞惎鍔紝涔熸湁鍙兘CPU浣跨敤鐜囨毚娑�"
+ # echoContent yellow "2.涓嶉噸鍚満鍣ㄥ彲姝e父浣跨敤锛屽鏋滈潪瑕佷娇鐢ㄥ畼鏂箇arp锛屽缓璁笉閲嶅惎鏈哄櫒"
+ # echoContent yellow "3.鏈夌殑鏈哄櫒閲嶅惎鍚庝粛姝e父浣跨敤"
+ # echoContent yellow "4.閲嶅惎鍚庢棤娉曚娇鐢紝涔熷彲鍗歌浇閲嶆柊瀹夎"
+ # 瀹夎warp
+ if [[ -z $(which warp-cli) ]]; then
+ echo
+ read -r -p "WARP鏈畨瑁咃紝鏄惁瀹夎 锛焄y/n]:" installCloudflareWarpStatus
+ if [[ "${installCloudflareWarpStatus}" == "y" ]]; then
+ installWarp
+ else
+ echoContent yellow " ---> 鏀惧純瀹夎"
+ exit 0
+ fi
+ fi
+
+ echoContent red "\n=============================================================="
+ echoContent yellow "1.娣诲姞鍩熷悕"
+ echoContent yellow "2.鍗歌浇WARP鍒嗘祦"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" warpStatus
+ if [[ "${warpStatus}" == "1" ]]; then
+ echoContent red "=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」\n"
+ echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
+ echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
+ echoContent yellow "3.鍙彲浠ユ妸娴侀噺鍒嗘祦缁檞arp锛屼笉鍙寚瀹氭槸ipv4鎴栬�卛pv6"
+ echoContent yellow "4.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
+ echoContent yellow "5.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
+ echoContent yellow "6.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
+ echoContent yellow "7.褰曞叆绀轰緥:google,youtube,facebook\n"
+ read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
+
+ if [[ -f "${configPath}09_routing.json" ]]; then
+ unInstallRouting warp-socks-out outboundTag
+
+ routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"domain\":[\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"warp-socks-out\"}]" ${configPath}09_routing.json)
+
+ echo "${routing}" | jq . >${configPath}09_routing.json
+
+ else
+ cat <<EOF >${configPath}09_routing.json
+{
+ "routing":{
+ "domainStrategy": "IPOnDemand",
+ "rules": [
+ {
+ "type": "field",
+ "domain": [
+ "geosite:${domainList//,/\",\"geosite:}"
+ ],
+ "outboundTag": "warp-socks-out"
+ }
+ ]
+ }
+}
+EOF
+ fi
+ unInstallOutbounds warp-socks-out
+
+ local outbounds
+ outbounds=$(jq -r '.outbounds += [{"protocol":"socks","settings":{"servers":[{"address":"127.0.0.1","port":31303}]},"tag":"warp-socks-out"}]' ${configPath}10_ipv4_outbounds.json)
+
+ echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
+
+ echoContent green " ---> 娣诲姞鎴愬姛"
+
+ elif [[ "${warpStatus}" == "2" ]]; then
+
+ ${removeType} cloudflare-warp >/dev/null 2>&1
+
+ unInstallRouting warp-socks-out outboundTag
+
+ unInstallOutbounds warp-socks-out
+
+ echoContent green " ---> WARP鍒嗘祦鍗歌浇鎴愬姛"
+ else
+ echoContent red " ---> 閫夋嫨閿欒"
+ exit 0
+ fi
+ reloadCore
+}
+# 娴佸獟浣撳伐鍏风
+streamingToolbox() {
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 娴佸獟浣撳伐鍏风"
+ echoContent red "\n=============================================================="
+ # echoContent yellow "1.Netflix妫�娴�"
+ echoContent yellow "1.浠绘剰闂ㄨ惤鍦版満瑙i攣娴佸獟浣�"
+ echoContent yellow "2.DNS瑙i攣娴佸獟浣�"
+ echoContent yellow "3.VMess+WS+TLS瑙i攣娴佸獟浣�"
+ read -r -p "璇烽�夋嫨:" selectType
+
+ case ${selectType} in
+ 1)
+ dokodemoDoorUnblockStreamingMedia
+ ;;
+ 2)
+ dnsUnlockNetflix
+ ;;
+ 3)
+ unblockVMessWSTLSStreamingMedia
+ ;;
+ esac
+
+}
+
+# 浠绘剰闂ㄨВ閿佹祦濯掍綋
+dokodemoDoorUnblockStreamingMedia() {
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 浠绘剰闂ㄨ惤鍦版満瑙i攣娴佸獟浣�"
+ echoContent red "\n=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」"
+ echoContent yellow "浠绘剰闂ㄨВ閿佽瑙o紝璇锋煡鐪嬫鏂囩珷[https://github.com/mack-a/v2ray-agent/blob/master/documents/netflix/dokodemo-unblock_netflix.md]\n"
+
+ echoContent yellow "1.娣诲姞鍑虹珯"
+ echoContent yellow "2.娣诲姞鍏ョ珯"
+ echoContent yellow "3.鍗歌浇"
+ read -r -p "璇烽�夋嫨:" selectType
+
+ case ${selectType} in
+ 1)
+ setDokodemoDoorUnblockStreamingMediaOutbounds
+ ;;
+ 2)
+ setDokodemoDoorUnblockStreamingMediaInbounds
+ ;;
+ 3)
+ removeDokodemoDoorUnblockStreamingMedia
+ ;;
+ esac
+}
+
+# VMess+WS+TLS 鍑烘垬瑙i攣娴佸獟浣撱�愪粎鍑虹珯銆�
+unblockVMessWSTLSStreamingMedia() {
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : VMess+WS+TLS 鍑虹珯瑙i攣娴佸獟浣�"
+ echoContent red "\n=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」"
+ echoContent yellow "閫傚悎閫氳繃鍏朵粬鏈嶅姟鍟嗘彁渚涚殑VMess瑙i攣鏈嶅姟\n"
+
+ echoContent yellow "1.娣诲姞鍑虹珯"
+ echoContent yellow "2.鍗歌浇"
+ read -r -p "璇烽�夋嫨:" selectType
+
+ case ${selectType} in
+ 1)
+ setVMessWSTLSUnblockStreamingMediaOutbounds
+ ;;
+ 2)
+ removeVMessWSTLSUnblockStreamingMedia
+ ;;
+ esac
+}
+
+# 璁剧疆VMess+WS+TLS瑙i攣Netflix銆愪粎鍑虹珯銆�
+setVMessWSTLSUnblockStreamingMediaOutbounds() {
+ read -r -p "璇疯緭鍏ヨВ閿佹祦濯掍綋VMess+WS+TLS鐨勫湴鍧�:" setVMessWSTLSAddress
+ echoContent red "=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」\n"
+ echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
+ echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
+ echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
+ echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
+ echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
+ echoContent yellow "6.褰曞叆绀轰緥:netflix,disney,hulu\n"
+ read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
+
+ if [[ -z ${domainList} ]]; then
+ echoContent red " ---> 鍩熷悕涓嶅彲涓虹┖"
+ setVMessWSTLSUnblockStreamingMediaOutbounds
+ fi
+
+ if [[ -n "${setVMessWSTLSAddress}" ]]; then
+
+ unInstallOutbounds VMess-out
+
+ echo
+ read -r -p "璇疯緭鍏Mess+WS+TLS鐨勭鍙�:" setVMessWSTLSPort
+ echo
+ if [[ -z "${setVMessWSTLSPort}" ]]; then
+ echoContent red " ---> 绔彛涓嶅彲涓虹┖"
+ fi
+
+ read -r -p "璇疯緭鍏Mess+WS+TLS鐨刄UID:" setVMessWSTLSUUID
+ echo
+ if [[ -z "${setVMessWSTLSUUID}" ]]; then
+ echoContent red " ---> UUID涓嶅彲涓虹┖"
+ fi
+
+ read -r -p "璇疯緭鍏Mess+WS+TLS鐨凱ath璺緞:" setVMessWSTLSPath
+ echo
+ if [[ -z "${setVMessWSTLSPath}" ]]; then
+ echoContent red " ---> 璺緞涓嶅彲涓虹┖"
+ fi
+
+ outbounds=$(jq -r ".outbounds += [{\"tag\":\"VMess-out\",\"protocol\":\"vmess\",\"streamSettings\":{\"network\":\"ws\",\"security\":\"tls\",\"tlsSettings\":{\"allowInsecure\":false},\"wsSettings\":{\"path\":\"${setVMessWSTLSPath}\"}},\"mux\":{\"enabled\":true,\"concurrency\":8},\"settings\":{\"vnext\":[{\"address\":\"${setVMessWSTLSAddress}\",\"port\":${setVMessWSTLSPort},\"users\":[{\"id\":\"${setVMessWSTLSUUID}\",\"security\":\"auto\",\"alterId\":0}]}]}}]" ${configPath}10_ipv4_outbounds.json)
+
+ echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
+
+ if [[ -f "${configPath}09_routing.json" ]]; then
+ unInstallRouting VMess-out outboundTag
+
+ local routing
+
+ routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"domain\":[\"ip.sb\",\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"VMess-out\"}]" ${configPath}09_routing.json)
+
+ echo "${routing}" | jq . >${configPath}09_routing.json
+ else
+ cat <<EOF >${configPath}09_routing.json
+{
+ "routing": {
+ "rules": [
+ {
+ "type": "field",
+ "domain": [
+ "ip.sb",
+ "geosite:${domainList//,/\",\"geosite:}"
+ ],
+ "outboundTag": "VMess-out"
+ }
+ ]
+ }
+}
+EOF
+ fi
+ reloadCore
+ echoContent green " ---> 娣诲姞鍑虹珯瑙i攣鎴愬姛"
+ exit 0
+ fi
+ echoContent red " ---> 鍦板潃涓嶅彲涓虹┖"
+ setVMessWSTLSUnblockStreamingMediaOutbounds
+}
+
+# 璁剧疆浠绘剰闂ㄨВ閿丯etflix銆愬嚭绔欍��
+setDokodemoDoorUnblockStreamingMediaOutbounds() {
+ read -r -p "璇疯緭鍏ヨВ閿佹祦濯掍綋 vps鐨処P:" setIP
+ echoContent red "=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」\n"
+ echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
+ echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
+ echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
+ echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
+ echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
+ echoContent yellow "6.褰曞叆绀轰緥:netflix,disney,hulu\n"
+ read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
+
+ if [[ -z ${domainList} ]]; then
+ echoContent red " ---> 鍩熷悕涓嶅彲涓虹┖"
+ setDokodemoDoorUnblockStreamingMediaOutbounds
+ fi
+
+ if [[ -n "${setIP}" ]]; then
+
+ unInstallOutbounds streamingMedia-80
+ unInstallOutbounds streamingMedia-443
+
+ outbounds=$(jq -r ".outbounds += [{\"tag\":\"streamingMedia-80\",\"protocol\":\"freedom\",\"settings\":{\"domainStrategy\":\"AsIs\",\"redirect\":\"${setIP}:22387\"}},{\"tag\":\"streamingMedia-443\",\"protocol\":\"freedom\",\"settings\":{\"domainStrategy\":\"AsIs\",\"redirect\":\"${setIP}:22388\"}}]" ${configPath}10_ipv4_outbounds.json)
+
+ echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
+
+ if [[ -f "${configPath}09_routing.json" ]]; then
+ unInstallRouting streamingMedia-80 outboundTag
+ unInstallRouting streamingMedia-443 outboundTag
+
+ local routing
+
+ routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"port\":80,\"domain\":[\"ip.sb\",\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"streamingMedia-80\"},{\"type\":\"field\",\"port\":443,\"domain\":[\"ip.sb\",\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"streamingMedia-443\"}]" ${configPath}09_routing.json)
+
+ echo "${routing}" | jq . >${configPath}09_routing.json
+ else
+ cat <<EOF >${configPath}09_routing.json
+{
+ "routing": {
+ "domainStrategy": "AsIs",
+ "rules": [
+ {
+ "type": "field",
+ "port": 80,
+ "domain": [
+ "ip.sb",
+ "geosite:${domainList//,/\",\"geosite:}"
+ ],
+ "outboundTag": "streamingMedia-80"
+ },
+ {
+ "type": "field",
+ "port": 443,
+ "domain": [
+ "ip.sb",
+ "geosite:${domainList//,/\",\"geosite:}"
+ ],
+ "outboundTag": "streamingMedia-443"
+ }
+ ]
+ }
+}
+EOF
+ fi
+ reloadCore
+ echoContent green " ---> 娣诲姞鍑虹珯瑙i攣鎴愬姛"
+ exit 0
+ fi
+ echoContent red " ---> ip涓嶅彲涓虹┖"
+}
+
+# 璁剧疆浠绘剰闂ㄨВ閿丯etflix銆愬叆绔欍��
+setDokodemoDoorUnblockStreamingMediaInbounds() {
+
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 浠绘剰闂ㄦ坊鍔犲叆绔�"
+ echoContent red "\n=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」\n"
+ echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
+ echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
+ echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
+ echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
+ echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
+ echoContent yellow "6.ip褰曞叆绀轰緥:1.1.1.1,1.1.1.2"
+ echoContent yellow "7.涓嬮潰鐨勫煙鍚嶄竴瀹氳鍜屽嚭绔欑殑vps涓�鑷�"
+ # echoContent yellow "8.濡傛湁闃茬伀澧欒鎵嬪姩寮�鍚�22387銆�22388绔彛"
+ echoContent yellow "8.鍩熷悕褰曞叆绀轰緥:netflix,disney,hulu\n"
+ read -r -p "璇疯緭鍏ュ厑璁歌闂瑙i攣 vps鐨処P:" setIPs
+ if [[ -n "${setIPs}" ]]; then
+ read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
+ allowPort 22387
+ allowPort 22388
+
+ cat <<EOF >${configPath}01_netflix_inbounds.json
+{
+ "inbounds": [
+ {
+ "listen": "0.0.0.0",
+ "port": 22387,
+ "protocol": "dokodemo-door",
+ "settings": {
+ "address": "0.0.0.0",
+ "port": 80,
+ "network": "tcp",
+ "followRedirect": false
+ },
+ "sniffing": {
+ "enabled": true,
+ "destOverride": [
+ "http"
+ ]
+ },
+ "tag": "streamingMedia-80"
+ },
+ {
+ "listen": "0.0.0.0",
+ "port": 22388,
+ "protocol": "dokodemo-door",
+ "settings": {
+ "address": "0.0.0.0",
+ "port": 443,
+ "network": "tcp",
+ "followRedirect": false
+ },
+ "sniffing": {
+ "enabled": true,
+ "destOverride": [
+ "tls"
+ ]
+ },
+ "tag": "streamingMedia-443"
+ }
+ ]
+}
+EOF
+
+ cat <<EOF >${configPath}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
+
+ if [[ -f "${configPath}09_routing.json" ]]; then
+ unInstallRouting streamingMedia-80 inboundTag
+ unInstallRouting streamingMedia-443 inboundTag
+
+ local routing
+ routing=$(jq -r ".routing.rules += [{\"source\":[\"${setIPs//,/\",\"}\"],\"type\":\"field\",\"inboundTag\":[\"streamingMedia-80\",\"streamingMedia-443\"],\"outboundTag\":\"direct\"},{\"domains\":[\"geosite:${domainList//,/\",\"geosite:}\"],\"type\":\"field\",\"inboundTag\":[\"streamingMedia-80\",\"streamingMedia-443\"],\"outboundTag\":\"blackhole-out\"}]" ${configPath}09_routing.json)
+ echo "${routing}" | jq . >${configPath}09_routing.json
+ else
+ cat <<EOF >${configPath}09_routing.json
+ {
+ "routing": {
+ "rules": [
+ {
+ "source": [
+ "${setIPs//,/\",\"}"
+ ],
+ "type": "field",
+ "inboundTag": [
+ "streamingMedia-80",
+ "streamingMedia-443"
+ ],
+ "outboundTag": "direct"
+ },
+ {
+ "domains": [
+ "geosite:${domainList//,/\",\"geosite:}"
+ ],
+ "type": "field",
+ "inboundTag": [
+ "streamingMedia-80",
+ "streamingMedia-443"
+ ],
+ "outboundTag": "blackhole-out"
+ }
+ ]
+ }
+ }
+EOF
+
+ fi
+
+ reloadCore
+ echoContent green " ---> 娣诲姞钀藉湴鏈哄叆绔欒В閿佹垚鍔�"
+ exit 0
+ fi
+ echoContent red " ---> ip涓嶅彲涓虹┖"
+}
+
+# 绉婚櫎浠绘剰闂ㄨВ閿丯etflix
+removeDokodemoDoorUnblockStreamingMedia() {
+
+ unInstallOutbounds streamingMedia-80
+ unInstallOutbounds streamingMedia-443
+
+ unInstallRouting streamingMedia-80 inboundTag
+ unInstallRouting streamingMedia-443 inboundTag
+
+ unInstallRouting streamingMedia-80 outboundTag
+ unInstallRouting streamingMedia-443 outboundTag
+
+ rm -rf ${configPath}01_netflix_inbounds.json
+
+ reloadCore
+ echoContent green " ---> 鍗歌浇鎴愬姛"
+}
+
+# 绉婚櫎VMess+WS+TLS瑙i攣娴佸獟浣�
+removeVMessWSTLSUnblockStreamingMedia() {
+
+ unInstallOutbounds VMess-out
+
+ unInstallRouting VMess-out outboundTag
+
+ reloadCore
+ echoContent green " ---> 鍗歌浇鎴愬姛"
+}
+
+# 閲嶅惎鏍稿績
+reloadCore() {
+ if [[ "${coreInstallType}" == "1" ]]; then
+ handleXray stop
+ handleXray start
+ elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then
+ handleV2Ray stop
+ handleV2Ray start
+ fi
+}
+
+# dns瑙i攣Netflix
+dnsUnlockNetflix() {
+ if [[ -z "${configPath}" ]]; then
+ echoContent red " ---> 鏈畨瑁咃紝璇蜂娇鐢ㄨ剼鏈畨瑁�"
+ menu
+ exit 0
+ fi
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : DNS瑙i攣娴佸獟浣�"
+ echoContent red "\n=============================================================="
+ echoContent yellow "1.娣诲姞"
+ echoContent yellow "2.鍗歌浇"
+ read -r -p "璇烽�夋嫨:" selectType
+
+ case ${selectType} in
+ 1)
+ setUnlockDNS
+ ;;
+ 2)
+ removeUnlockDNS
+ ;;
+ esac
+}
+
+# 璁剧疆dns
+setUnlockDNS() {
+ read -r -p "璇疯緭鍏ヨВ閿佹祦濯掍綋DNS:" setDNS
+ if [[ -n ${setDNS} ]]; then
+ echoContent red "=============================================================="
+ echoContent yellow "# 娉ㄦ剰浜嬮」\n"
+ echoContent yellow "1.瑙勫垯浠呮敮鎸侀瀹氫箟鍩熷悕鍒楄〃[https://github.com/v2fly/domain-list-community]"
+ echoContent yellow "2.璇︾粏鏂囨。[https://www.v2fly.org/config/routing.html]"
+ echoContent yellow "3.濡傚唴鏍稿惎鍔ㄥけ璐ヨ妫�鏌ュ煙鍚嶅悗閲嶆柊娣诲姞鍩熷悕"
+ echoContent yellow "4.涓嶅厑璁告湁鐗规畩瀛楃锛屾敞鎰忛�楀彿鐨勬牸寮�"
+ echoContent yellow "5.姣忔娣诲姞閮芥槸閲嶆柊娣诲姞锛屼笉浼氫繚鐣欎笂娆″煙鍚�"
+ echoContent yellow "6.褰曞叆绀轰緥:netflix,disney,hulu"
+ echoContent yellow "7.榛樿鏂规璇疯緭鍏�1锛岄粯璁ゆ柟妗堝寘鎷互涓嬪唴瀹�"
+ echoContent yellow "netflix,bahamut,hulu,hbo,disney,bbc,4chan,fox,abema,dmm,niconico,pixiv,bilibili,viu"
+ read -r -p "璇锋寜鐓т笂闈㈢ず渚嬪綍鍏ュ煙鍚�:" domainList
+ if [[ "${domainList}" == "1" ]]; then
+ cat <<EOF >${configPath}11_dns.json
+ {
+ "dns": {
+ "servers": [
+ {
+ "address": "${setDNS}",
+ "port": 53,
+ "domains": [
+ "geosite:netflix",
+ "geosite:bahamut",
+ "geosite:hulu",
+ "geosite:hbo",
+ "geosite:disney",
+ "geosite:bbc",
+ "geosite:4chan",
+ "geosite:fox",
+ "geosite:abema",
+ "geosite:dmm",
+ "geosite:niconico",
+ "geosite:pixiv",
+ "geosite:bilibili",
+ "geosite:viu"
+ ]
+ },
+ "localhost"
+ ]
+ }
+ }
+EOF
+ elif [[ -n "${domainList}" ]]; then
+ cat <<EOF >${configPath}11_dns.json
+ {
+ "dns": {
+ "servers": [
+ {
+ "address": "${setDNS}",
+ "port": 53,
+ "domains": [
+ "geosite:${domainList//,/\",\"geosite:}"
+ ]
+ },
+ "localhost"
+ ]
+ }
+ }
+EOF
+ fi
+
+ reloadCore
+
+ echoContent yellow "\n ---> 濡傝繕鏃犳硶瑙傜湅鍙互灏濊瘯浠ヤ笅涓ょ鏂规"
+ echoContent yellow " 1.閲嶅惎vps"
+ echoContent yellow " 2.鍗歌浇dns瑙i攣鍚庯紝淇敼鏈湴鐨刐/etc/resolv.conf]DNS璁剧疆骞堕噸鍚痸ps\n"
+ else
+ echoContent red " ---> dns涓嶅彲涓虹┖"
+ fi
+ exit 0
+}
+
+# 绉婚櫎Netflix瑙i攣
+removeUnlockDNS() {
+ cat <<EOF >${configPath}11_dns.json
+{
+ "dns": {
+ "servers": [
+ "localhost"
+ ]
+ }
+}
+EOF
+ reloadCore
+
+ echoContent green " ---> 鍗歌浇鎴愬姛"
+
+ exit 0
+}
+
+# v2ray-core涓�у寲瀹夎
+customV2RayInstall() {
+ echoContent skyBlue "\n========================涓�у寲瀹夎============================"
+ echoContent yellow "VLESS鍓嶇疆锛岄粯璁ゅ畨瑁�0锛屽鏋滃彧闇�瑕佸畨瑁�0锛屽垯鍙�夋嫨0鍗冲彲"
+ echoContent yellow "0.VLESS+TLS/XTLS+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"
+ echoContent yellow "5.VLESS+TLS+gRPC[CDN]"
+ read -r -p "璇烽�夋嫨[澶氶�塢锛孾渚嬪:123]:" selectCustomInstallType
+ echoContent skyBlue "--------------------------------------------------------------"
+ if [[ -z ${selectCustomInstallType} ]]; then
+ selectCustomInstallType=0
+ fi
+ if [[ "${selectCustomInstallType}" =~ ^[0-5]+$ ]]; then
+ cleanUp xrayClean
+ totalProgress=17
+ installTools 1
+ # 鐢宠tls
+ initTLSNginxConfig 2
+ 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
+
+ # 瀹夎V2Ray
+ installV2Ray 8
+ installV2RayService 9
+ initV2RayConfig custom 10
+ cleanUp xrayDel
+ installCronTLS 14
+ handleV2Ray stop
+ handleV2Ray start
+ # 鐢熸垚璐﹀彿
+ checkGFWStatue 15
+ showAccounts 16
+ else
+ echoContent red " ---> 杈撳叆涓嶅悎娉�"
+ customV2RayInstall
+ fi
+}
+
+# Xray-core涓�у寲瀹夎
+customXrayInstall() {
+ echoContent skyBlue "\n========================涓�у寲瀹夎============================"
+ echoContent yellow "VLESS鍓嶇疆锛岄粯璁ゅ畨瑁�0锛屽鏋滃彧闇�瑕佸畨瑁�0锛屽垯鍙�夋嫨0鍗冲彲"
+ echoContent yellow "0.VLESS+TLS/XTLS+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"
+ echoContent yellow "5.VLESS+TLS+gRPC[CDN]"
+ read -r -p "璇烽�夋嫨[澶氶�塢锛孾渚嬪:123]:" selectCustomInstallType
+ echoContent skyBlue "--------------------------------------------------------------"
+ if [[ -z ${selectCustomInstallType} ]]; then
+ echoContent red " ---> 涓嶅彲涓虹┖"
+ customXrayInstall
+ elif [[ "${selectCustomInstallType}" =~ ^[0-5]+$ ]]; then
+ cleanUp v2rayClean
+ totalProgress=17
+ installTools 1
+ # 鐢宠tls
+ initTLSNginxConfig 2
+ installTLS 3
+ handleNginx stop
+ # 闅忔満path
+ if echo "${selectCustomInstallType}" | grep -q 1 || echo "${selectCustomInstallType}" | grep -q 2 || echo "${selectCustomInstallType}" | grep -q 3 || echo "${selectCustomInstallType}" | grep -q 5; then
+ randomPathFunction 5
+ customCDNIP 6
+ fi
+ nginxBlog 7
+ updateRedirectNginxConf
+ handleNginx start
+
+ # 瀹夎V2Ray
+ installXray 8
+ installXrayService 9
+ initXrayConfig custom 10
+ cleanUp v2rayDel
+
+ installCronTLS 14
+ handleXray stop
+ handleXray start
+ # 鐢熸垚璐﹀彿
+ checkGFWStatue 15
+ showAccounts 16
+ else
+ echoContent red " ---> 杈撳叆涓嶅悎娉�"
+ customXrayInstall
+ fi
+}
+
+# 閫夋嫨鏍稿績瀹夎---v2ray-core銆亁ray-core
+selectCoreInstall() {
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 閫夋嫨鏍稿績瀹夎"
+ echoContent red "\n=============================================================="
+ echoContent yellow "1.Xray-core"
+ echoContent yellow "2.v2ray-core"
+ echoContent red "=============================================================="
+ read -r -p "璇烽�夋嫨:" selectCoreType
+ case ${selectCoreType} in
+ 1)
+ if [[ "${selectInstallType}" == "2" ]]; then
+ customXrayInstall
+ else
+ xrayCoreInstall
+ fi
+ ;;
+ 2)
+ v2rayCoreVersion=
+ if [[ "${selectInstallType}" == "2" ]]; then
+ customV2RayInstall
+ else
+ v2rayCoreInstall
+ fi
+ ;;
+ 3)
+ v2rayCoreVersion=v4.32.1
+ if [[ "${selectInstallType}" == "2" ]]; then
+ customV2RayInstall
+ else
+ v2rayCoreInstall
+ fi
+ ;;
+ *)
+ echoContent red ' ---> 閫夋嫨閿欒锛岄噸鏂伴�夋嫨'
+ selectCoreInstall
+ ;;
+ esac
+}
+
+# v2ray-core 瀹夎
+v2rayCoreInstall() {
+ cleanUp xrayClean
+ selectCustomInstallType=
+ totalProgress=13
+ installTools 2
+ # 鐢宠tls
+ initTLSNginxConfig 3
+ installTLS 4
+ handleNginx stop
+ # initNginxConfig 5
+ 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
+ selectCustomInstallType=
+ totalProgress=13
+ installTools 2
+ # 鐢宠tls
+ initTLSNginxConfig 3
+ installTLS 4
+ handleNginx stop
+ randomPathFunction 5
+ # 瀹夎Xray
+ # handleV2Ray stop
+ installXray 6
+ installXrayService 7
+ customCDNIP 8
+ initXrayConfig all 9
+ cleanUp v2rayDel
+ installCronTLS 10
+ nginxBlog 11
+ updateRedirectNginxConf
+ handleXray stop
+ sleep 2
+ handleXray start
+
+ handleNginx start
+ # 鐢熸垚璐﹀彿
+ checkGFWStatue 12
+ showAccounts 13
+}
+
+# 鏍稿績绠$悊
+coreVersionManageMenu() {
+
+ if [[ -z "${coreInstallType}" ]]; then
+ echoContent red "\n ---> 娌℃湁妫�娴嬪埌瀹夎鐩綍锛岃鎵ц鑴氭湰瀹夎鍐呭"
+ menu
+ exit 0
+ fi
+ if [[ "${coreInstallType}" == "1" ]]; then
+ xrayVersionManageMenu 1
+ elif [[ "${coreInstallType}" == "2" ]]; then
+ v2rayCoreVersion=
+ v2rayVersionManageMenu 1
+
+ elif [[ "${coreInstallType}" == "3" ]]; then
+ v2rayCoreVersion=v4.32.1
+ v2rayVersionManageMenu 1
+ fi
+}
+# 瀹氭椂浠诲姟妫�鏌ヨ瘉涔�
+cronRenewTLS() {
+ if [[ "${renewTLS}" == "RenewTLS" ]]; then
+ renewalTLS
+ exit 0
+ fi
+}
+# 璐﹀彿绠$悊
+manageAccount() {
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 璐﹀彿绠$悊"
+ echoContent red "\n=============================================================="
+ echoContent yellow "# 姣忔鍒犻櫎銆佹坊鍔犺处鍙峰悗锛岄渶瑕侀噸鏂版煡鐪嬭闃呯敓鎴愯闃匼n"
+ echoContent yellow "1.鏌ョ湅璐﹀彿"
+ echoContent yellow "2.鏌ョ湅璁㈤槄"
+ echoContent yellow "3.娣诲姞鐢ㄦ埛"
+ echoContent yellow "4.鍒犻櫎鐢ㄦ埛"
+ echoContent red "=============================================================="
+ read -r -p "璇疯緭鍏�:" manageAccountStatus
+ if [[ "${manageAccountStatus}" == "1" ]]; then
+ showAccounts 1
+ elif [[ "${manageAccountStatus}" == "2" ]]; then
+ subscribe 1
+ elif [[ "${manageAccountStatus}" == "3" ]]; then
+ addUser
+ elif [[ "${manageAccountStatus}" == "4" ]]; then
+ removeUser
+ else
+ echoContent red " ---> 閫夋嫨閿欒"
+ fi
+}
+
+# 璁㈤槄
+subscribe() {
+ if [[ -n "${configPath}" ]]; then
+ echoContent skyBlue "-------------------------澶囨敞---------------------------------"
+ echoContent yellow "# 鏌ョ湅璁㈤槄鏃朵細閲嶆柊鐢熸垚璁㈤槄"
+ echoContent yellow "# 姣忔娣诲姞銆佸垹闄よ处鍙烽渶瑕侀噸鏂版煡鐪嬭闃�"
+ rm -rf /etc/v2ray-agent/subscribe/*
+ rm -rf /etc/v2ray-agent/subscribe_tmp/*
+ showAccounts >/dev/null
+ mv /etc/v2ray-agent/subscribe_tmp/* /etc/v2ray-agent/subscribe/
+
+ if [[ -n $(ls /etc/v2ray-agent/subscribe/) ]]; then
+ find /etc/v2ray-agent/subscribe/* | while read -r email; do
+ email=$(echo "${email}" | awk -F "[b][e][/]" '{print $2}')
+
+ local base64Result
+ base64Result=$(base64 -w 0 "/etc/v2ray-agent/subscribe/${email}")
+ echo "${base64Result}" >"/etc/v2ray-agent/subscribe/${email}"
+ echoContent skyBlue "--------------------------------------------------------------"
+ echoContent yellow "email:${email}\n"
+ local currentDomain=${currentHost}
+
+ if [[ -n "${currentDefaultPort}" && "${currentDefaultPort}" != "443" ]]; then
+ currentDomain="${currentHost}:${currentDefaultPort}"
+ fi
+
+ echoContent yellow "url:https://${currentDomain}/s/${email}\n"
+ echoContent yellow "鍦ㄧ嚎浜岀淮鐮�:https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=https://${currentDomain}/s/${email}\n"
+ echo "https://${currentDomain}/s/${email}" | qrencode -s 10 -m 1 -t UTF8
+ echoContent skyBlue "--------------------------------------------------------------"
+ done
+ fi
+ else
+ echoContent red " ---> 鏈畨瑁�"
+ fi
+}
+
+# 鍒囨崲alpn
+switchAlpn() {
+ echoContent skyBlue "\n鍔熻兘 1/${totalProgress} : 鍒囨崲alpn"
+ if [[ -z ${currentAlpn} ]]; then
+ echoContent red " ---> 鏃犳硶璇诲彇alpn锛岃妫�鏌ユ槸鍚﹀畨瑁�"
+ exit 0
+ fi
+
+ echoContent red "\n=============================================================="
+ echoContent green "褰撳墠alpn棣栦綅涓�:${currentAlpn}"
+ echoContent yellow " 1.褰揾ttp/1.1棣栦綅鏃讹紝trojan鍙敤锛実RPC閮ㄥ垎瀹㈡埛绔彲鐢ㄣ�愬鎴风鏀寔鎵嬪姩閫夋嫨alpn鐨勫彲鐢ㄣ��"
+ echoContent yellow " 2.褰揾2棣栦綅鏃讹紝gRPC鍙敤锛宼rojan閮ㄥ垎瀹㈡埛绔彲鐢ㄣ�愬鎴风鏀寔鎵嬪姩閫夋嫨alpn鐨勫彲鐢ㄣ��"
+ echoContent yellow " 3.濡傚鎴风涓嶆敮鎸佹墜鍔ㄦ洿鎹lpn锛屽缓璁娇鐢ㄦ鍔熻兘鏇存敼鏈嶅姟绔痑lpn椤哄簭锛屾潵浣跨敤鐩稿簲鐨勫崗璁�"
+ echoContent red "=============================================================="
+
+ if [[ "${currentAlpn}" == "http/1.1" ]]; then
+ echoContent yellow "1.鍒囨崲alpn h2 棣栦綅"
+ elif [[ "${currentAlpn}" == "h2" ]]; then
+ echoContent yellow "1.鍒囨崲alpn http/1.1 棣栦綅"
+ else
+ echoContent red '涓嶇鍚�'
+ fi
+
+ echoContent red "=============================================================="
+
+ read -r -p "璇烽�夋嫨:" selectSwitchAlpnType
+ if [[ "${selectSwitchAlpnType}" == "1" && "${currentAlpn}" == "http/1.1" ]]; then
+
+ local frontingTypeJSON
+ frontingTypeJSON=$(jq -r ".inbounds[0].streamSettings.xtlsSettings.alpn = [\"h2\",\"http/1.1\"]" ${configPath}${frontingType}.json)
+ echo "${frontingTypeJSON}" | jq . >${configPath}${frontingType}.json
+
+ elif [[ "${selectSwitchAlpnType}" == "1" && "${currentAlpn}" == "h2" ]]; then
+ local frontingTypeJSON
+ frontingTypeJSON=$(jq -r ".inbounds[0].streamSettings.xtlsSettings.alpn =[\"http/1.1\",\"h2\"]" ${configPath}${frontingType}.json)
+ echo "${frontingTypeJSON}" | jq . >${configPath}${frontingType}.json
+ else
+ echoContent red " ---> 閫夋嫨閿欒"
+ exit 0
+ fi
+ reloadCore
+}
+# 涓昏彍鍗�
+menu() {
+ cd "$HOME" || exit
+ echoContent red "\n=============================================================="
+ echoContent green "浣滆��:mack-a"
+ echoContent green "褰撳墠鐗堟湰:v2.5.72"
+ echoContent green "Github:https://github.com/mack-a/v2ray-agent"
+ echoContent green "鎻忚堪:鍏悎涓�鍏卞瓨鑴氭湰\c"
+ showInstallStatus
+ echoContent red "\n=============================================================="
+ echoContent red " 鎺ㄥ箍鍖� "
+ echoContent green "AFF鎹愯禒锛歨ttps://github.com/mack-a/v2ray-agent/blob/master/documents/donation_aff.md\n"
+ echoContent green "铏氭嫙甯佹崘璧狅細0xB08b731653515b083deE362fefFc45d5eb96c35d\n"
+ echoContent green "鎺ㄥ箍鍙仈绯籘G锛歨ttps://t.me/mackaff"
+ echoContent red "=============================================================="
+ if [[ -n "${coreInstallType}" ]]; then
+ echoContent yellow "1.閲嶆柊瀹夎"
+ else
+ echoContent yellow "1.瀹夎"
+ 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 skyBlue "-------------------------宸ュ叿绠$悊-----------------------------"
+ echoContent yellow "4.璐﹀彿绠$悊"
+ echoContent yellow "5.鏇存崲浼绔�"
+ echoContent yellow "6.鏇存柊璇佷功"
+ echoContent yellow "7.鏇存崲CDN鑺傜偣"
+ echoContent yellow "8.IPv6鍒嗘祦"
+ echoContent yellow "9.WARP鍒嗘祦"
+ echoContent yellow "10.娴佸獟浣撳伐鍏�"
+ echoContent yellow "11.娣诲姞鏂扮鍙�"
+ echoContent yellow "12.BT涓嬭浇绠$悊"
+ echoContent yellow "13.鍒囨崲alpn"
+ echoContent yellow "14.鍩熷悕榛戝悕鍗�"
+ echoContent skyBlue "-------------------------鐗堟湰绠$悊-----------------------------"
+ echoContent yellow "15.core绠$悊"
+ echoContent yellow "16.鏇存柊鑴氭湰"
+ echoContent yellow "17.瀹夎BBR銆丏D鑴氭湰"
+ echoContent skyBlue "-------------------------鑴氭湰绠$悊-----------------------------"
+ echoContent yellow "18.鏌ョ湅鏃ュ織"
+ echoContent yellow "19.鍗歌浇鑴氭湰"
+ echoContent red "=============================================================="
+ mkdirTools
+ aliasInstall
+ read -r -p "璇烽�夋嫨:" selectInstallType
+ case ${selectInstallType} in
+ 1)
+ selectCoreInstall
+ ;;
+ 2)
+ selectCoreInstall
+ ;;
+ 3)
+ initXrayFrontingConfig 1
+ ;;
+ 4)
+ manageAccount 1
+ ;;
+ 5)
+ updateNginxBlog 1
+ ;;
+ 6)
+ renewalTLS 1
+ ;;
+ 7)
+ updateV2RayCDN 1
+ ;;
+ 8)
+ ipv6Routing 1
+ ;;
+ 9)
+ warpRouting 1
+ ;;
+ 10)
+ streamingToolbox 1
+ ;;
+ 11)
+ addCorePort 1
+ ;;
+ 12)
+ btTools 1
+ ;;
+ 13)
+ switchAlpn 1
+ ;;
+ 14)
+ blacklist 1
+ ;;
+ 15)
+ coreVersionManageMenu 1
+ ;;
+ 16)
+ updateV2RayAgent 1
+ ;;
+ 17)
+ bbrInstall
+ ;;
+ 18)
+ checkLog 1
+ ;;
+ 19)
+ unInstall 1
+ ;;
+ esac
+}
+cronRenewTLS
+menu
--
Gitblit v1.9.1