You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
v2ray/v2ray.sh

2894 lines
72 KiB

7 years ago
#!/bin/bash
red='\e[91m'
green='\e[92m'
yellow='\e[93m'
magenta='\e[95m'
cyan='\e[96m'
none='\e[0m'
# Root
[[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1
_version="v3.10"
7 years ago
cmd="apt-get"
sys_bit=$(uname -m)
6 years ago
case $sys_bit in
i[36]86)
7 years ago
v2ray_bit="32"
6 years ago
caddy_arch="386"
;;
x86_64)
7 years ago
v2ray_bit="64"
6 years ago
caddy_arch="amd64"
;;
*armv6*)
v2ray_bit="arm"
caddy_arch="arm6"
;;
*armv7*)
v2ray_bit="arm"
caddy_arch="arm7"
;;
*aarch64* | *armv8*)
v2ray_bit="arm64"
caddy_arch="arm64"
;;
*)
echo -e "
哈哈……这个 ${red}辣鸡脚本${none} 不支持你的系统。 ${yellow}(-_-) ${none}
备注: 仅支持 Ubuntu 16+ / Debian 8+ / CentOS 7+ 系统
" && exit 1
;;
esac
if [[ $(command -v yum) ]]; then
7 years ago
6 years ago
cmd="yum"
7 years ago
fi
backup="/etc/v2ray/233blog_v2ray_backup.conf"
7 years ago
7 years ago
if [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f $backup && -d /etc/v2ray/233boy/v2ray ]]; then
7 years ago
. $backup
7 years ago
elif [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f /etc/v2ray/233blog_v2ray_backup.txt && -d /etc/v2ray/233boy/v2ray ]]; then
6 years ago
. /etc/v2ray/233boy/v2ray/tools/v1xx_to_v3xx.sh
7 years ago
else
echo -e " 哎呀哎呀…… ${red}出错咯...请重新安装V2Ray${none} ${yellow}~(^_^) ${none}" && exit 1
fi
6 years ago
if [[ $mark != "v3" ]]; then
. /etc/v2ray/233boy/v2ray/tools/v3.sh
7 years ago
fi
6 years ago
if [[ $v2ray_transport -ge 18 ]]; then
7 years ago
dynamicPort=true
port_range="${v2ray_dynamicPort_start}-${v2ray_dynamicPort_end}"
fi
7 years ago
if [[ $path_status ]]; then
is_path=true
fi
7 years ago
uuid=$(cat /proc/sys/kernel/random/uuid)
6 years ago
old_id="e55c8d17-2cf3-b21a-bcf1-eeacb011ed79"
7 years ago
v2ray_server_config="/etc/v2ray/config.json"
v2ray_client_config="/etc/v2ray/233blog_v2ray_config.json"
6 years ago
v2ray_pid=$(pgrep -f /usr/bin/v2ray/v2ray)
caddy_pid=$(pgrep -f /usr/local/bin/caddy)
_v2ray_sh="/usr/local/sbin/v2ray"
v2ray_ver="$(/usr/bin/v2ray/v2ray -version | head -n 1 | cut -d " " -f2)"
6 years ago
. /etc/v2ray/233boy/v2ray/src/init.sh
systemd=true
# _test=true
if [[ $v2ray_ver != v* ]]; then
v2ray_ver="v$v2ray_ver"
fi
if [[ ! -f $_v2ray_sh ]]; then
mv -f /usr/local/bin/v2ray $_v2ray_sh
chmod +x $_v2ray_sh
echo -e "\n $yellow 警告: 请重新登录 SSH 以避免出现 v2ray 命令未找到的情况。$none \n" && exit 1
fi
7 years ago
if [ $v2ray_pid ]; then
v2ray_status="$green正在运行$none"
else
v2ray_status="$red未在运行$none"
fi
6 years ago
if [[ $v2ray_transport == [45] && $caddy ]] && [[ $caddy_pid ]]; then
caddy_run_status="$green正在运行$none"
else
caddy_run_status="$red未在运行$none"
fi
7 years ago
6 years ago
_load transport.sh
7 years ago
ciphers=(
aes-128-cfb
aes-256-cfb
chacha20
chacha20-ietf
aes-128-gcm
aes-256-gcm
chacha20-ietf-poly1305
)
get_transport_args() {
6 years ago
_load v2ray-info.sh
_v2_args
7 years ago
}
create_vmess_URL_config() {
7 years ago
[[ -z $net ]] && get_transport_args
6 years ago
if [[ $v2ray_transport == [45] ]]; then
cat >/etc/v2ray/vmess_qr.json <<-EOF
{
7 years ago
"v": "2",
6 years ago
"ps": "233v2.com_${domain}",
"add": "${domain}",
"port": "443",
"id": "${v2ray_id}",
"aid": "${alterId}",
7 years ago
"net": "${net}",
"type": "none",
"host": "${domain}",
"path": "$_path",
"tls": "tls"
}
EOF
else
[[ -z $ip ]] && get_ip
cat >/etc/v2ray/vmess_qr.json <<-EOF
{
7 years ago
"v": "2",
6 years ago
"ps": "233v2.com_${ip}",
"add": "${ip}",
"port": "${v2ray_port}",
"id": "${v2ray_id}",
"aid": "${alterId}",
"net": "${net}",
"type": "${header}",
"host": "${host}",
7 years ago
"path": "",
"tls": ""
}
EOF
fi
}
7 years ago
view_v2ray_config_info() {
6 years ago
_load v2ray-info.sh
_v2_args
_v2_info
7 years ago
}
get_shadowsocks_config() {
if [[ $shadowsocks ]]; then
while :; do
echo
echo -e "$yellow 1. $none查看 Shadowsocks 配置信息"
echo
echo -e "$yellow 2. $none生成二维码链接"
echo
read -p "$(echo -e "请选择 [${magenta}1-2$none]:")" _opt
if [[ -z $_opt ]]; then
error
else
case $_opt in
1)
view_shadowsocks_config_info
break
;;
2)
get_shadowsocks_config_qr_link
break
;;
*)
error
;;
esac
fi
done
else
shadowsocks_config
fi
}
view_shadowsocks_config_info() {
if [[ $shadowsocks ]]; then
6 years ago
_load ss-info.sh
7 years ago
else
shadowsocks_config
fi
}
get_shadowsocks_config_qr_link() {
if [[ $shadowsocks ]]; then
get_ip
_load qr.sh
_ss_qr
7 years ago
else
shadowsocks_config
fi
}
get_shadowsocks_config_qr_ask() {
echo
while :; do
echo -e "是否需要生成$yellow Shadowsocks 配置信息 $none二维码链接 [${magenta}Y/N$none]"
read -p "$(echo -e "默认 [${magenta}N$none]:")" y_n
[ -z $y_n ] && y_n="n"
if [[ $y_n == [Yy] ]]; then
get_shadowsocks_config_qr_link
break
elif [[ $y_n == [Nn] ]]; then
break
else
error
fi
done
}
change_shadowsocks_config() {
if [[ $shadowsocks ]]; then
while :; do
echo
echo -e "$yellow 1. $none修改 Shadowsocks 端口"
echo
echo -e "$yellow 2. $none修改 Shadowsocks 密码"
echo
echo -e "$yellow 3. $none修改 Shadowsocks 加密协议"
echo
echo -e "$yellow 4. $none关闭 Shadowsocks"
echo
read -p "$(echo -e "请选择 [${magenta}1-4$none]:")" _opt
if [[ -z $_opt ]]; then
error
else
case $_opt in
1)
change_shadowsocks_port
break
;;
2)
change_shadowsocks_password
break
;;
3)
change_shadowsocks_ciphers
break
;;
4)
disable_shadowsocks
break
;;
*)
error
;;
esac
fi
done
else
shadowsocks_config
fi
}
shadowsocks_config() {
echo
echo
echo -e " $red大佬...你没有配置 Shadowsocks $none...不过现在想要配置的话也是可以的 ^_^"
echo
echo
while :; do
echo -e "是否配置 ${yellow}Shadowsocks${none} [${magenta}Y/N$none]"
read -p "$(echo -e "(默认 [${cyan}N$none]):") " install_shadowsocks
7 years ago
[[ -z "$install_shadowsocks" ]] && install_shadowsocks="n"
if [[ "$install_shadowsocks" == [Yy] ]]; then
echo
7 years ago
shadowsocks=true
7 years ago
shadowsocks_port_config
shadowsocks_password_config
shadowsocks_ciphers_config
pause
7 years ago
open_port $new_ssport
backup_config +ss
7 years ago
ssport=$new_ssport
sspass=$new_sspass
ssciphers=$new_ssciphers
7 years ago
config
clear
7 years ago
view_shadowsocks_config_info
6 years ago
# get_shadowsocks_config_qr_ask
7 years ago
break
elif [[ "$install_shadowsocks" == [Nn] ]]; then
echo
echo -e " $green已取消配置 Shadowsocks ....$none"
echo
break
else
error
fi
done
}
shadowsocks_port_config() {
local random=$(shuf -i20001-65535 -n1)
7 years ago
while :; do
echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"],不能和 "$yellow"V2ray"$none" 端口相同"
read -p "$(echo -e "(默认端口: ${cyan}${random}$none):") " new_ssport
[ -z "$new_ssport" ] && new_ssport=$random
7 years ago
case $new_ssport in
$v2ray_port)
echo
echo -e " 不能和$cyan V2Ray 端口 $none一毛一样...."
6 years ago
echo
echo -e " 当前 V2Ray 端口:${cyan}$v2ray_port${none}"
7 years ago
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
6 years ago
if [[ $v2ray_transport == [45] ]]; then
7 years ago
local tls=ture
fi
if [[ $tls && $new_ssport == "80" ]] || [[ $tls && $new_ssport == "443" ]]; then
7 years ago
echo
7 years ago
echo -e "由于你当前已使用了 "$green"WebSocket + TLS $none或$green HTTP/2"$none" 传输协议."
7 years ago
echo
echo -e "所以不能选择 "$magenta"80"$none" 或 "$magenta"443"$none" 端口"
error
elif [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start == $new_ssport || $v2ray_dynamicPort_end == $new_ssport ]]; then
echo
6 years ago
echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}"
7 years ago
error
elif [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start -lt $new_ssport && $new_ssport -le $v2ray_dynamicPort_end ]]; then
echo
6 years ago
echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}"
error
elif [[ $socks && $new_ssport == $socks_port ]]; then
echo
echo -e "抱歉, 此端口跟 Socks 端口冲突...当前 Socks 端口: ${cyan}$socks_port$none"
error
elif [[ $mtproto && $new_ssport == $mtproto_port ]]; then
echo
echo -e "抱歉, 此端口跟 MTProto 端口冲突...当前 MTProto 端口: ${cyan}$mtproto_port$none"
7 years ago
error
else
echo
echo
echo -e "$yellow Shadowsocks 端口 = $cyan$new_ssport$none"
echo "----------------------------------------------------------------"
echo
break
fi
;;
*)
error
;;
esac
done
}
shadowsocks_password_config() {
while :; do
echo -e "请输入 "$yellow"Shadowsocks"$none" 密码"
read -p "$(echo -e "(默认密码: ${cyan}233blog.com$none)"): " new_sspass
7 years ago
[ -z "$new_sspass" ] && new_sspass="233blog.com"
case $new_sspass in
*[/$]*)
7 years ago
echo
echo -e " 由于这个脚本太辣鸡了..所以密码不能包含$red / $none或$red $ $none这两个符号.... "
7 years ago
echo
error
;;
*)
echo
echo
echo -e "$yellow Shadowsocks 密码 = $cyan$new_sspass$none"
echo "----------------------------------------------------------------"
echo
break
;;
esac
done
}
shadowsocks_ciphers_config() {
while :; do
echo -e "请选择 "$yellow"Shadowsocks"$none" 加密协议 [${magenta}1-7$none]"
for ((i = 1; i <= ${#ciphers[*]}; i++)); do
ciphers_show="${ciphers[$i - 1]}"
echo
echo -e "$yellow $i. $none${ciphers_show}"
done
echo
read -p "$(echo -e "(默认加密协议: ${cyan}${ciphers[6]}$none)"):" ssciphers_opt
7 years ago
[ -z "$ssciphers_opt" ] && ssciphers_opt=7
case $ssciphers_opt in
[1-7])
new_ssciphers=${ciphers[$ssciphers_opt - 1]}
echo
echo
echo -e "$yellow Shadowsocks 加密协议 = $cyan${new_ssciphers}$none"
echo "----------------------------------------------------------------"
echo
break
;;
*)
error
;;
esac
done
}
change_shadowsocks_port() {
echo
while :; do
echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"]"
read -p "$(echo -e "(当前端口: ${cyan}$ssport$none):") " new_ssport
7 years ago
[ -z "$new_ssport" ] && error && continue
case $new_ssport in
$ssport)
echo
echo " 跟当前端口一毛一样....修改个鸡鸡哦"
error
;;
$v2ray_port)
echo
echo -e " 不能和$cyan V2Ray 端口 $none一毛一样...."
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
6 years ago
if [[ $v2ray_transport == [45] ]]; then
7 years ago
local tls=ture
fi
if [[ $tls && $new_ssport == "80" ]] || [[ $tls && $new_ssport == "443" ]]; then
7 years ago
echo
6 years ago
echo -e "由于你已选择了 "$green"WebSocket + TLS $none或$green HTTP/2"$none" 传输协议."
7 years ago
echo
echo -e "所以不能选择 "$magenta"80"$none" 或 "$magenta"443"$none" 端口"
error
elif [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start == $new_ssport || $v2ray_dynamicPort_end == $new_ssport ]]; then
echo
6 years ago
echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}"
7 years ago
error
elif [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start -lt $new_ssport && $new_ssport -le $v2ray_dynamicPort_end ]]; then
echo
6 years ago
echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}"
error
elif [[ $socks && $new_ssport == $socks_port ]]; then
echo
echo -e "抱歉, 此端口跟 Socks 端口冲突...当前 Socks 端口: ${cyan}$socks_port$none"
error
elif [[ $mtproto && $new_ssport == $mtproto_port ]]; then
echo
echo -e "抱歉, 此端口跟 MTProto 端口冲突...当前 MTProto 端口: ${cyan}$mtproto_port$none"
7 years ago
error
else
echo
echo
echo -e "$yellow Shadowsocks 端口 = $cyan$new_ssport$none"
echo "----------------------------------------------------------------"
echo
pause
backup_config ssport
7 years ago
del_port $ssport
open_port $new_ssport
ssport=$new_ssport
config
clear
view_shadowsocks_config_info
6 years ago
# get_shadowsocks_config_qr_ask
7 years ago
break
fi
;;
*)
error
;;
esac
done
}
change_shadowsocks_password() {
echo
while :; do
echo -e "请输入 "$yellow"Shadowsocks"$none" 密码"
read -p "$(echo -e "(当前密码:${cyan}$sspass$none)"): " new_sspass
7 years ago
[ -z "$new_sspass" ] && error && continue
case $new_sspass in
$sspass)
echo
echo " 跟当前密码一毛一样....修改个鸡鸡哦"
error
;;
*[/$]*)
7 years ago
echo
echo -e " 由于这个脚本太辣鸡了..所以密码不能包含$red / $none或$red $ $none这两个符号.... "
7 years ago
echo
error
;;
*)
echo
echo
echo -e "$yellow Shadowsocks 密码 = $cyan$new_sspass$none"
echo "----------------------------------------------------------------"
echo
pause
backup_config sspass
7 years ago
sspass=$new_sspass
config
clear
view_shadowsocks_config_info
6 years ago
# get_shadowsocks_config_qr_ask
7 years ago
break
;;
esac
done
}
change_shadowsocks_ciphers() {
echo
while :; do
7 years ago
echo -e "请选择 "$yellow"Shadowsocks"$none" 加密协议 [${magenta}1-${#ciphers[*]}$none]"
7 years ago
for ((i = 1; i <= ${#ciphers[*]}; i++)); do
ciphers_show="${ciphers[$i - 1]}"
echo
echo -e "$yellow $i. $none${ciphers_show}"
done
echo
read -p "$(echo -e "(当前加密协议: ${cyan}${ssciphers}$none)"):" ssciphers_opt
7 years ago
[ -z "$ssciphers_opt" ] && error && continue
case $ssciphers_opt in
[1-7])
new_ssciphers=${ciphers[$ssciphers_opt - 1]}
if [[ $new_ssciphers == $ssciphers ]]; then
echo
echo " 跟当前加密协议一毛一样....修改个鸡鸡哦"
error && continue
fi
echo
echo
echo -e "$yellow Shadowsocks 加密协议 = $cyan${new_ssciphers}$none"
echo "----------------------------------------------------------------"
echo
pause
backup_config ssciphers
7 years ago
ssciphers=$new_ssciphers
config
clear
view_shadowsocks_config_info
6 years ago
# get_shadowsocks_config_qr_ask
7 years ago
break
;;
*)
error
;;
esac
done
}
disable_shadowsocks() {
echo
while :; do
echo -e "是否关闭 ${yellow}Shadowsocks${none} [${magenta}Y/N$none]"
read -p "$(echo -e "(默认 [${cyan}N$none]):") " y_n
7 years ago
[[ -z "$y_n" ]] && y_n="n"
if [[ "$y_n" == [Yy] ]]; then
echo
echo
echo -e "$yellow 关闭 Shadowsocks = $cyan是$none"
echo "----------------------------------------------------------------"
echo
pause
backup_config -ss
7 years ago
del_port $ssport
shadowsocks=''
config
# clear
echo
echo
echo
echo -e "$green Shadowsocks 已关闭...不过你也可以随时重新启用 Shadowsocks ...只要你喜欢$none"
echo
break
elif [[ "$y_n" == [Nn] ]]; then
echo
echo -e " $green已取消关闭 Shadowsocks ....$none"
echo
break
else
error
fi
done
}
change_v2ray_config() {
7 years ago
local _menu=(
"修改 V2Ray 端口"
"修改 V2Ray 传输协议"
"修改 V2Ray 动态端口 (如果可以)"
"修改 用户ID ( UUID )"
"修改 TLS 域名 (如果可以)"
"修改 分流的路径 (如果可以)"
"修改 伪装的网址 (如果可以)"
"关闭 网站伪装 和 路径分流 (如果可以)"
"开启 / 关闭 广告拦截"
)
7 years ago
while :; do
7 years ago
for ((i = 1; i <= ${#_menu[*]}; i++)); do
if [[ "$i" -le 9 ]]; then
echo
echo -e "$yellow $i. $none${_menu[$i - 1]}"
else
echo
echo -e "$yellow $i. $none${_menu[$i - 1]}"
fi
done
7 years ago
echo
7 years ago
read -p "$(echo -e "请选择 [${magenta}1-${#_menu[*]}$none]:")" _opt
7 years ago
if [[ -z $_opt ]]; then
error
else
case $_opt in
1)
change_v2ray_port
break
;;
2)
change_v2ray_transport
break
;;
3)
change_v2ray_dynamicport
break
;;
4)
change_v2ray_id
break
;;
5)
change_domain
break
;;
6)
7 years ago
change_path_config
break
;;
7)
change_proxy_site_config
break
;;
8)
7 years ago
disable_path
break
;;
9)
7 years ago
blocked_hosts
break
;;
7 years ago
[aA][Ii][aA][Ii] | [Dd][Dd])
custom_uuid
break
;;
[Dd] | [Aa][Ii] | 233 | 233[Bb][Ll][Oo][Gg] | 233[Bb][Ll][Oo][Gg].[Cc][Oo][Mm] | 233[Bb][Oo][Yy] | [Aa][Ll][Tt][Ee][Rr][Ii][Dd])
change_v2ray_alterId
break
;;
7 years ago
*)
error
;;
esac
fi
done
}
change_v2ray_port() {
if [[ $v2ray_transport == 4 ]]; then
echo
echo -e " 由于你目前使用的是$yellow WebSocket + TLS $none传输协议...所以修不修改 V2Ray 端口没有什么不一样的"
echo
echo " 如果你想要使用其他端口...可以先修改 V2Ray 的传输协议..之后再修改 V2Ray 端口"
echo
change_v2ray_transport_ask
6 years ago
elif [[ $v2ray_transport == 5 ]]; then
7 years ago
echo
echo -e " 由于你目前使用的是$yellow HTTP/2 $none传输协议...所以修不修改 V2Ray 端口没有什么不一样的"
echo
echo " 如果你想要使用其他端口...可以先修改 V2Ray 的传输协议..之后再修改 V2Ray 端口"
echo
change_v2ray_transport_ask
7 years ago
else
echo
while :; do
echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"]"
read -p "$(echo -e "(当前端口: ${cyan}${v2ray_port}$none):")" v2ray_port_opt
7 years ago
[[ -z $v2ray_port_opt ]] && error && continue
case $v2ray_port_opt in
$v2ray_port)
echo
echo " 哎呀...跟当前端口一毛一样呀...修改个鸡鸡哦"
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
6 years ago
if [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start == $v2ray_port_opt || $v2ray_dynamicPort_end == $v2ray_port_opt ]]; then
echo
echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}"
error
elif [[ $dynamicPort ]] && [[ $v2ray_dynamicPort_start -lt $v2ray_port_opt && $v2ray_port_opt -le $v2ray_dynamicPort_end ]]; then
7 years ago
echo
6 years ago
echo -e " 抱歉,此端口和 V2Ray 动态端口 冲突,当前 V2Ray 动态端口范围为:${cyan}$port_range${none}"
7 years ago
error
6 years ago
elif [[ $shadowsocks && $v2ray_port_opt == $ssport ]]; then
7 years ago
echo
6 years ago
echo -e "抱歉, 此端口跟 Shadowsocks 端口冲突...当前 Shadowsocks 端口: ${cyan}$ssport$none"
7 years ago
error
6 years ago
elif [[ $socks && $v2ray_port_opt == $socks_port ]]; then
7 years ago
echo
6 years ago
echo -e "抱歉, 此端口跟 Socks 端口冲突...当前 Socks 端口: ${cyan}$socks_port$none"
error
elif [[ $mtproto && $v2ray_port_opt == $mtproto_port ]]; then
echo
echo -e "抱歉, 此端口跟 MTProto 端口冲突...当前 MTProto 端口: ${cyan}$mtproto_port$none"
7 years ago
error
else
echo
echo
echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port_opt$none"
echo "----------------------------------------------------------------"
echo
pause
backup_config v2ray_port
7 years ago
del_port $v2ray_port
open_port $v2ray_port_opt
v2ray_port=$v2ray_port_opt
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
7 years ago
break
fi
;;
*)
error
;;
esac
done
fi
}
download_v2ray_config_ask() {
echo
while :; do
echo -e "是否需要 下载 V2Ray 配置 / 生成配置信息链接 / 生成二维码链接 [${magenta}Y/N$none]"
read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n
7 years ago
[ -z $y_n ] && y_n="n"
if [[ $y_n == [Yy] ]]; then
download_v2ray_config
break
elif [[ $y_n == [Nn] ]]; then
break
else
error
fi
done
}
change_v2ray_transport_ask() {
echo
while :; do
echo -e "是否需要修改$yellow V2Ray $none传输协议 [${magenta}Y/N$none]"
read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n
7 years ago
[ -z $y_n ] && break
if [[ $y_n == [Yy] ]]; then
change_v2ray_transport
break
elif [[ $y_n == [Nn] ]]; then
break
else
error
fi
done
}
change_v2ray_transport() {
echo
while :; do
7 years ago
echo -e "请选择 "$yellow"V2Ray"$none" 传输协议 [${magenta}1-${#transport[*]}$none]"
7 years ago
echo
for ((i = 1; i <= ${#transport[*]}; i++)); do
Stream="${transport[$i - 1]}"
if [[ "$i" -le 9 ]]; then
# echo
echo -e "$yellow $i. $none${Stream}"
else
# echo
echo -e "$yellow $i. $none${Stream}"
fi
done
echo
echo "备注1: 含有 [dynamicPort] 的即启用动态端口.."
6 years ago
echo "备注2: [utp | srtp | wechat-video | dtls | wireguard] 分别伪装成 [BT下载 | 视频通话 | 微信视频通话 | DTLS 1.2 数据包 | WireGuard 数据包]"
7 years ago
echo
read -p "$(echo -e "(当前传输协议: ${cyan}${transport[$v2ray_transport - 1]}$none)"):" v2ray_transport_opt
7 years ago
if [ -z "$v2ray_transport_opt" ]; then
error
else
case $v2ray_transport_opt in
$v2ray_transport)
echo
echo " 哎呀...跟当前传输协议一毛一样呀...修改个鸡鸡哦"
error
;;
6 years ago
4 | 5)
7 years ago
if [[ $v2ray_port == "80" || $v2ray_port == "443" ]]; then
echo
7 years ago
echo -e " 抱歉...如果你想要使用${cyan} ${transport[$v2ray_transport_opt - 1]} $none传输协议.. ${red}V2Ray 端口不能为 80 或者 443 ...$none"
7 years ago
echo
echo -e " 当前 V2Ray 端口: ${cyan}$v2ray_port$none"
error
elif [[ $shadowsocks ]] && [[ $ssport == "80" || $ssport == "443" ]]; then
echo
7 years ago
echo -e " 抱歉...如果你想要使用${cyan} ${transport[$v2ray_transport_opt - 1]} $none传输协议.. ${red}Shadowsocks 端口不能为 80 或者 443 ...$none"
7 years ago
echo
echo -e " 当前 Shadowsocks 端口: ${cyan}$ssport$none"
error
6 years ago
elif [[ $socks ]] && [[ $socks_port == "80" || $socks_port == "443" ]]; then
echo
echo -e " 抱歉...如果你想要使用${cyan} ${transport[$v2ray_transport_opt - 1]} $none传输协议.. ${red}Socks 端口不能为 80 或者 443 ...$none"
echo
echo -e " 当前 Socks 端口: ${cyan}$socks_port$none"
error
elif [[ $mtproto ]] && [[ $mtproto_port == "80" || $mtproto_port == "443" ]]; then
echo
echo -e " 抱歉...如果你想要使用${cyan} ${transport[$v2ray_transport_opt - 1]} $none传输协议.. ${red}MTProto 端口不能为 80 或者 443 ...$none"
echo
echo -e " 当前 MTProto 端口: ${cyan}$mtproto_port$none"
error
7 years ago
else
echo
echo
echo -e "$yellow V2Ray 传输协议 = $cyan${transport[$v2ray_transport_opt - 1]}$none"
echo "----------------------------------------------------------------"
echo
break
fi
;;
6 years ago
[1-9] | [1-2][0-9] | 3[0-2])
7 years ago
echo
echo
echo -e "$yellow V2Ray 传输协议 = $cyan${transport[$v2ray_transport_opt - 1]}$none"
echo "----------------------------------------------------------------"
echo
break
;;
*)
error
;;
esac
fi
done
pause
6 years ago
if [[ $v2ray_transport_opt == [45] ]]; then
7 years ago
tls_config
6 years ago
elif [[ $v2ray_transport_opt -ge 18 ]]; then
7 years ago
v2ray_dynamic_port_start
v2ray_dynamic_port_end
pause
7 years ago
old_transport
7 years ago
open_port "multiport"
backup_config v2ray_transport v2ray_dynamicPort_start v2ray_dynamicPort_end
7 years ago
port_range="${v2ray_dynamic_port_start_input}-${v2ray_dynamic_port_end_input}"
7 years ago
v2ray_transport=$v2ray_transport_opt
7 years ago
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
7 years ago
else
7 years ago
old_transport
backup_config v2ray_transport
7 years ago
v2ray_transport=$v2ray_transport_opt
7 years ago
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
7 years ago
fi
}
7 years ago
old_transport() {
6 years ago
if [[ $v2ray_transport == [45] ]]; then
7 years ago
del_port "80"
del_port "443"
6 years ago
if [[ $caddy && $caddy_pid ]]; then
7 years ago
do_service stop caddy
if [[ $systemd ]]; then
systemctl disable caddy >/dev/null 2>&1
else
update-rc.d -f caddy remove >/dev/null 2>&1
fi
6 years ago
elif [[ $caddy ]]; then
7 years ago
if [[ $systemd ]]; then
systemctl disable caddy >/dev/null 2>&1
else
update-rc.d -f caddy remove >/dev/null 2>&1
fi
fi
if [[ $is_path ]]; then
backup_config -path
fi
6 years ago
elif [[ $v2ray_transport -ge 18 ]]; then
7 years ago
del_port "multiport"
fi
}
7 years ago
tls_config() {
7 years ago
while :; do
echo
echo
echo
echo -e "请输入一个 $magenta正确的域名$none,一定一定一定要正确,不!能!出!错!"
read -p "(例如:233blog.com): " new_domain
[ -z "$new_domain" ] && error && continue
echo
echo
echo -e "$yellow 你的域名 = $cyan$new_domain$none"
echo "----------------------------------------------------------------"
break
done
get_ip
echo
echo
echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none"
echo
echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none"
echo
echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none"
echo "----------------------------------------------------------------"
echo
while :; do
read -p "$(echo -e "(是否已经正确解析: [${magenta}Y$none]):") " record
if [[ -z "$record" ]]; then
error
else
if [[ "$record" == [Yy] ]]; then
6 years ago
domain_check
7 years ago
echo
echo
echo -e "$yellow 域名解析 = ${cyan}我确定已经有解析了$none"
7 years ago
echo "----------------------------------------------------------------"
echo
break
else
error
fi
fi
done
6 years ago
if [[ $caddy ]]; then
7 years ago
path_config_ask
7 years ago
pause
6 years ago
# domain_check
backup_config v2ray_transport domain
7 years ago
if [[ $new_path ]]; then
backup_config +path
path=$new_path
proxy_site=$new_proxy_site
7 years ago
is_path=true
fi
6 years ago
if [[ $v2ray_transport -ge 18 ]]; then
7 years ago
del_port "multiport"
fi
domain=$new_domain
7 years ago
open_port "80"
open_port "443"
if [[ $systemd ]]; then
systemctl enable caddy >/dev/null 2>&1
else
update-rc.d -f caddy defaults >/dev/null 2>&1
fi
7 years ago
v2ray_transport=$v2ray_transport_opt
7 years ago
caddy_config
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
7 years ago
else
6 years ago
if [[ $v2ray_transport_opt == 5 ]]; then
7 years ago
path_config_ask
pause
domain_check
backup_config v2ray_transport domain caddy
if [[ $new_path ]]; then
backup_config +path
path=$new_path
proxy_site=$new_proxy_site
is_path=true
fi
6 years ago
if [[ $v2ray_transport -ge 18 ]]; then
7 years ago
del_port "multiport"
fi
domain=$new_domain
install_caddy
open_port "80"
open_port "443"
v2ray_transport=$v2ray_transport_opt
caddy_config
config
6 years ago
caddy=true
7 years ago
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
7 years ago
else
auto_tls_config
fi
fi
}
auto_tls_config() {
echo -e "
7 years ago
安装 Caddy 来实现 自动配置 TLS
如果你已经安装 Nginx 或 Caddy
$yellow并且..自己能搞定配置 TLS$none
那么就不需要 打开自动配置 TLS
"
7 years ago
echo "----------------------------------------------------------------"
echo
7 years ago
7 years ago
while :; do
7 years ago
7 years ago
read -p "$(echo -e "(是否自动配置 TLS: [${magenta}Y/N$none]):") " auto_install_caddy
if [[ -z "$auto_install_caddy" ]]; then
error
else
if [[ "$auto_install_caddy" == [Yy] ]]; then
echo
echo
echo -e "$yellow 自动配置 TLS = $cyan打开$none"
echo "----------------------------------------------------------------"
echo
path_config_ask
pause
domain_check
backup_config v2ray_transport domain caddy
if [[ $new_path ]]; then
backup_config +path
path=$new_path
proxy_site=$new_proxy_site
is_path=true
fi
6 years ago
if [[ $v2ray_transport -ge 18 ]]; then
7 years ago
del_port "multiport"
fi
domain=$new_domain
install_caddy
open_port "80"
open_port "443"
v2ray_transport=$v2ray_transport_opt
caddy_config
config
6 years ago
caddy=true
7 years ago
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
7 years ago
break
elif [[ "$auto_install_caddy" == [Nn] ]]; then
echo
echo
echo -e "$yellow 自动配置 TLS = $cyan关闭$none"
echo "----------------------------------------------------------------"
echo
pause
domain_check
backup_config v2ray_transport domain
6 years ago
if [[ $v2ray_transport -ge 18 ]]; then
7 years ago
del_port "multiport"
7 years ago
fi
7 years ago
domain=$new_domain
open_port "80"
open_port "443"
v2ray_transport=$v2ray_transport_opt
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
7 years ago
break
else
error
7 years ago
fi
7 years ago
fi
7 years ago
7 years ago
done
7 years ago
}
7 years ago
path_config_ask() {
echo
while :; do
echo -e "是否开启 网站伪装 和 路径分流 [${magenta}Y/N$none]"
7 years ago
read -p "$(echo -e "(默认: [${cyan}N$none]):")" path_ask
[[ -z $path_ask ]] && path_ask="n"
7 years ago
case $path_ask in
Y | y)
7 years ago
path_config
break
;;
N | n)
echo
echo
echo -e "$yellow 网站伪装 和 路径分流 = $cyan不想配置$none"
echo "----------------------------------------------------------------"
echo
break
;;
*)
error
;;
esac
done
}
7 years ago
path_config() {
echo
while :; do
echo -e "请输入想要 ${magenta}用来分流的路径$none , 例如 /233blog , 那么只需要输入 233blog 即可"
7 years ago
read -p "$(echo -e "(默认: [${cyan}233blog$none]):")" new_path
[[ -z $new_path ]] && new_path="233blog"
7 years ago
case $new_path in
*[/$]*)
echo
echo -e " 由于这个脚本太辣鸡了..所以分流的路径不能包含$red / $none或$red $ $none这两个符号.... "
echo
error
;;
*)
echo
echo
7 years ago
echo -e "$yellow 分流的路径 = ${cyan}/${new_path}$none"
echo "----------------------------------------------------------------"
echo
break
;;
esac
done
proxy_site_config
}
proxy_site_config() {
echo
while :; do
echo -e "请输入 ${magenta}一个正确的$none ${cyan}网址$none 用来作为 ${cyan}网站的伪装$none , 例如 https://liyafly.com"
echo -e "举例...假设你当前的域名是$green $domain $none, 伪装的网址的是 https://liyafly.com"
echo -e "然后打开你的域名时候...显示出来的内容就是来自 https://liyafly.com 的内容"
echo -e "其实就是一个反代...明白就好..."
echo -e "如果不能伪装成功...可以使用 v2ray config 修改伪装的网址"
read -p "$(echo -e "(默认: [${cyan}https://liyafly.com$none]):")" new_proxy_site
[[ -z $new_proxy_site ]] && new_proxy_site="https://liyafly.com"
case $new_proxy_site in
*[#$]*)
echo
echo -e " 由于这个脚本太辣鸡了..所以伪装的网址不能包含$red # $none或$red $ $none这两个符号.... "
echo
error
;;
*)
echo
echo
echo -e "$yellow 伪装的网址 = ${cyan}${new_proxy_site}$none"
echo "----------------------------------------------------------------"
echo
break
;;
esac
done
}
7 years ago
install_caddy() {
6 years ago
_load download-caddy.sh
_download_caddy_file
_install_caddy_service
7 years ago
}
caddy_config() {
6 years ago
# local email=$(shuf -i1-10000000000 -n1)
6 years ago
_load caddy-config.sh
7 years ago
# systemctl restart caddy
do_service restart caddy
}
v2ray_dynamic_port_start() {
echo
echo
while :; do
echo -e "请输入 "$yellow"V2Ray 动态端口开始 "$none"范围 ["$magenta"1-65535"$none"]"
read -p "$(echo -e "(默认开始端口: ${cyan}10000$none):")" v2ray_dynamic_port_start_input
7 years ago
[ -z $v2ray_dynamic_port_start_input ] && v2ray_dynamic_port_start_input=10000
case $v2ray_dynamic_port_start_input in
$v2ray_port)
echo
echo " 不能和 V2Ray 端口一毛一样...."
6 years ago
echo
echo -e " 当前 V2Ray 端口:${cyan}$v2ray_port${none}"
7 years ago
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
6 years ago
if [[ $shadowsocks && $v2ray_dynamic_port_start_input == $ssport ]]; then
echo
echo -e "抱歉, 此端口跟 Shadowsocks 端口冲突...当前 Shadowsocks 端口: ${cyan}$ssport$none"
error
elif [[ $socks && $v2ray_dynamic_port_start_input == $socks_port ]]; then
7 years ago
echo
6 years ago
echo -e "抱歉, 此端口跟 Socks 端口冲突...当前 Socks 端口: ${cyan}$socks_port$none"
error
elif [[ $mtproto && $v2ray_dynamic_port_start_input == $mtproto_port ]]; then
6 years ago
echo
6 years ago
echo -e "抱歉, 此端口跟 MTProto 端口冲突...当前 MTProto 端口: ${cyan}$mtproto_port$none"
7 years ago
error
else
echo
echo
echo -e "$yellow V2Ray 动态端口开始 = $cyan$v2ray_dynamic_port_start_input$none"
echo "----------------------------------------------------------------"
echo
break
fi
;;
*)
error
;;
esac
done
if [[ $v2ray_dynamic_port_start_input -lt $v2ray_port ]]; then
lt_v2ray_port=true
fi
if [[ $shadowsocks ]] && [[ $v2ray_dynamic_port_start_input -lt $ssport ]]; then
lt_ssport=true
fi
6 years ago
if [[ $socks ]] && [[ $v2ray_dynamic_port_start_input -lt $socks_port ]]; then
lt_socks_port=true
fi
if [[ $mtproto ]] && [[ $v2ray_dynamic_port_start_input -lt $mtproto_port ]]; then
lt_mtproto_port=true
fi
7 years ago
}
v2ray_dynamic_port_end() {
echo
while :; do
echo -e "请输入 "$yellow"V2Ray 动态端口结束 "$none"范围 ["$magenta"1-65535"$none"]"
read -p "$(echo -e "(默认结束端口: ${cyan}20000$none):")" v2ray_dynamic_port_end_input
7 years ago
[ -z $v2ray_dynamic_port_end_input ] && v2ray_dynamic_port_end_input=20000
case $v2ray_dynamic_port_end_input in
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
7 years ago
if [[ $v2ray_dynamic_port_end_input -le $v2ray_dynamic_port_start_input ]]; then
echo
echo " 不能小于或等于 V2Ray 动态端口开始范围"
6 years ago
echo
echo -e " 当前 V2Ray 动态端口开始:${cyan}$v2ray_dynamic_port_start_input${none}"
7 years ago
error
elif [ $lt_v2ray_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $v2ray_port ]]; then
echo
echo " V2Ray 动态端口结束范围 不能包括 V2Ray 端口..."
echo
echo -e " 当前 V2Ray 端口: ${cyan}$v2ray_port$none"
error
elif [ $lt_ssport ] && [[ ${v2ray_dynamic_port_end_input} -ge $ssport ]]; then
echo
echo " V2Ray 动态端口结束范围 不能包括 Shadowsocks 端口..."
echo
echo -e " 当前 Shadowsocks 端口: ${cyan}$ssport$none"
error
6 years ago
elif [ $lt_socks_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $socks_port ]]; then
echo
echo " V2Ray 动态端口结束范围 不能包括 Socks 端口..."
echo
echo -e " 当前 Socks 端口: ${cyan}$socks_port$none"
error
elif [ $lt_mtproto_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $mtproto_port ]]; then
echo
echo " V2Ray 动态端口结束范围 不能包括 MTProto 端口..."
echo
echo -e " 当前 MTProto 端口: ${cyan}$mtproto_port$none"
error
7 years ago
else
echo
echo
echo -e "$yellow V2Ray 动态端口结束 = $cyan$v2ray_dynamic_port_end_input$none"
echo "----------------------------------------------------------------"
echo
break
fi
;;
*)
error
;;
esac
done
}
change_v2ray_dynamicport() {
6 years ago
if [[ $v2ray_transport -ge 18 ]]; then
7 years ago
change_v2ray_dynamic_port_start
change_v2ray_dynamic_port_end
pause
del_port "multiport"
open_port "multiport"
backup_config v2ray_dynamicPort_start v2ray_dynamicPort_end
7 years ago
port_range="${v2ray_dynamic_port_start_input}-${v2ray_dynamic_port_end_input}"
config
# clear
echo
echo -e "$green 动态端口修改成功啦...你不需要修改 V2Ray 客户端配置...保持原有的配置即可...$none"
7 years ago
echo
else
echo
echo -e "$red ...当前传输协议木有启用动态端口...$none"
echo
while :; do
echo -e "是否需要修改传输协议 [${magenta}Y/N$none]"
read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n
7 years ago
if [[ -z $y_n ]]; then
echo
echo -e "$green 已取消修改传输协议...$none"
echo
break
else
if [[ $y_n == [Yy] ]]; then
change_v2ray_transport
break
elif [[ $y_n == [Nn] ]]; then
echo
echo -e "$green 已取消修改传输协议...$none"
echo
break
else
error
fi
fi
done
fi
}
change_v2ray_dynamic_port_start() {
echo
echo
while :; do
echo -e "请输入 "$yellow"V2Ray 动态端口开始 "$none"范围 ["$magenta"1-65535"$none"]"
read -p "$(echo -e "(当前动态开始端口: ${cyan}$v2ray_dynamicPort_start$none):")" v2ray_dynamic_port_start_input
7 years ago
[ -z $v2ray_dynamic_port_start_input ] && error && continue
case $v2ray_dynamic_port_start_input in
$v2ray_port)
echo
echo " 不能和 V2Ray 端口一毛一样...."
6 years ago
echo
echo -e " 当前 V2Ray 端口:${cyan}$v2ray_port${none}"
7 years ago
error
;;
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
6 years ago
if [[ $shadowsocks && $v2ray_dynamic_port_start_input == $ssport ]]; then
7 years ago
echo
6 years ago
echo -e "抱歉, 此端口跟 Shadowsocks 端口冲突...当前 Shadowsocks 端口: ${cyan}$ssport$none"
error
elif [[ $socks && $v2ray_dynamic_port_start_input == $socks_port ]]; then
echo
echo -e "抱歉, 此端口跟 Socks 端口冲突...当前 Socks 端口: ${cyan}$socks_port$none"
error
elif [[ $mtproto && $v2ray_dynamic_port_start_input == $mtproto_port ]]; then
6 years ago
echo
6 years ago
echo -e "抱歉, 此端口跟 MTProto 端口冲突...当前 MTProto 端口: ${cyan}$mtproto_port$none"
7 years ago
error
else
echo
echo
echo -e "$yellow V2Ray 动态端口开始 = $cyan$v2ray_dynamic_port_start_input$none"
echo "----------------------------------------------------------------"
echo
break
fi
;;
*)
error
;;
esac
done
if [[ $v2ray_dynamic_port_start_input -lt $v2ray_port ]]; then
lt_v2ray_port=true
fi
if [[ $shadowsocks ]] && [[ $v2ray_dynamic_port_start_input -lt $ssport ]]; then
lt_ssport=true
fi
6 years ago
if [[ $socks ]] && [[ $v2ray_dynamic_port_start_input -lt $socks_port ]]; then
lt_socks_port=true
fi
if [[ $mtproto ]] && [[ $v2ray_dynamic_port_start_input -lt $mtproto_port ]]; then
lt_mtproto_port=true
fi
7 years ago
}
change_v2ray_dynamic_port_end() {
echo
while :; do
echo -e "请输入 "$yellow"V2Ray 动态端口结束 "$none"范围 ["$magenta"1-65535"$none"]"
read -p "$(echo -e "(当前动态结束端口: ${cyan}$v2ray_dynamicPort_end$none):")" v2ray_dynamic_port_end_input
7 years ago
[ -z $v2ray_dynamic_port_end_input ] && error && continue
case $v2ray_dynamic_port_end_input in
[1-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
7 years ago
if [[ $v2ray_dynamic_port_end_input -le $v2ray_dynamic_port_start_input ]]; then
echo
echo " 不能小于或等于 V2Ray 动态端口开始范围"
6 years ago
echo
echo -e " 当前 V2Ray 动态端口开始:${cyan}$v2ray_dynamic_port_start_input${none}"
7 years ago
error
elif [ $lt_v2ray_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $v2ray_port ]]; then
echo
echo " V2Ray 动态端口结束范围 不能包括 V2Ray 端口..."
echo
echo -e " 当前 V2Ray 端口: ${cyan}$v2ray_port$none"
error
elif [ $lt_ssport ] && [[ ${v2ray_dynamic_port_end_input} -ge $ssport ]]; then
echo
echo " V2Ray 动态端口结束范围 不能包括 Shadowsocks 端口..."
echo
echo -e " 当前 Shadowsocks 端口: ${cyan}$ssport$none"
error
6 years ago
elif [ $lt_socks_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $socks_port ]]; then
echo
echo " V2Ray 动态端口结束范围 不能包括 Socks 端口..."
echo
echo -e " 当前 Socks 端口: ${cyan}$socks_port$none"
error
elif [ $lt_mtproto_port ] && [[ ${v2ray_dynamic_port_end_input} -ge $mtproto_port ]]; then
echo
echo " V2Ray 动态端口结束范围 不能包括 MTProto 端口..."
echo
echo -e " 当前 MTProto 端口: ${cyan}$mtproto_port$none"
error
7 years ago
else
echo
echo
echo -e "$yellow V2Ray 动态端口结束 = $cyan$v2ray_dynamic_port_end_input$none"
echo "----------------------------------------------------------------"
echo
break
fi
;;
*)
error
;;
esac
done
}
change_v2ray_id() {
echo
while :; do
echo -e "是否确定要修改用户ID [${magenta}Y/N$none]"
read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n
7 years ago
if [[ -z $y_n ]]; then
echo
echo -e "$green 已取消修改用户ID...$none"
echo
break
else
if [[ $y_n == [Yy] ]]; then
echo
echo
echo -e "$yellow 修改用户ID = $cyan确定$none"
echo "----------------------------------------------------------------"
echo
pause
backup_config uuid
7 years ago
v2ray_id=$uuid
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
7 years ago
break
elif [[ $y_n == [Nn] ]]; then
echo
echo -e "$green 已取消修改用户ID...$none"
echo
break
else
error
fi
fi
done
}
change_domain() {
6 years ago
if [[ $v2ray_transport == [45] ]] && [[ $caddy ]]; then
7 years ago
while :; do
echo
echo -e "请输入一个 $magenta正确的域名$none,一定一定一定要正确,不!能!出!错!"
read -p "$(echo -e "(当前域名: ${cyan}$domain$none):") " new_domain
7 years ago
[ -z "$new_domain" ] && error && continue
if [[ $new_domain == $domain ]]; then
echo
echo -e " 跟当前域名一毛一样啊...修改个鸡鸡哦"
echo
error && continue
fi
echo
echo
echo -e "$yellow 你的域名 = $cyan$new_domain$none"
echo "----------------------------------------------------------------"
break
done
get_ip
echo
echo
echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none"
echo
echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none"
echo
echo -e "$yellow 请将 $magenta$new_domain$none $yellow解析到: $cyan$ip$none"
echo "----------------------------------------------------------------"
echo
while :; do
read -p "$(echo -e "(是否已经正确解析: [${magenta}Y$none]):") " record
if [[ -z "$record" ]]; then
error
else
if [[ "$record" == [Yy] ]]; then
6 years ago
domain_check
7 years ago
echo
echo
echo -e "$yellow 域名解析 = ${cyan}我确定已经有解析了$none"
7 years ago
echo "----------------------------------------------------------------"
echo
pause
6 years ago
# domain_check
backup_config domain
7 years ago
domain=$new_domain
caddy_config
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
7 years ago
break
else
error
fi
fi
done
else
echo
echo -e "$red 抱歉...不支持修改...$none"
echo
7 years ago
echo -e " 备注..修改 TLS 域名仅支持传输协议为 ${yellow}WebSocket + TLS$none${yellow}HTTP/2$none 并且$yellow 自动配置 TLS = 打开$none"
7 years ago
echo
echo -e " 当前传输协议为: ${cyan}${transport[$v2ray_transport - 1]}${none}"
echo
6 years ago
if [[ $caddy ]]; then
7 years ago
echo -e " 自动配置 TLS = ${cyan}打开$none"
else
echo -e " 自动配置 TLS = $red关闭$none"
fi
echo
fi
}
7 years ago
change_path_config() {
6 years ago
if [[ $v2ray_transport == [45] ]] && [[ $caddy && $is_path ]]; then
echo
while :; do
echo -e "请输入想要 ${magenta}用来分流的路径$none , 例如 /233blog , 那么只需要输入 233blog 即可"
7 years ago
read -p "$(echo -e "(当前分流的路径: [${cyan}/${path}$none]):")" new_path
[[ -z $new_path ]] && error && continue
7 years ago
case $new_path in
$path)
echo
echo -e " 大佬...跟 当前分流的路径 一毛一样啊...修改个鸡鸡哦 "
echo
error
;;
*[/$]*)
echo
echo -e " 由于这个脚本太辣鸡了..所以分流的路径不能包含$red / $none或$red $ $none这两个符号.... "
echo
error
;;
*)
echo
echo
7 years ago
echo -e "$yellow 分流的路径 = ${cyan}/${new_path}$none"
echo "----------------------------------------------------------------"
echo
break
;;
esac
done
pause
7 years ago
backup_config path
path=$new_path
caddy_config
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
elif [[ $v2ray_transport == [45] ]] && [[ $caddy ]]; then
7 years ago
path_config_ask
if [[ $new_path ]]; then
backup_config +path
path=$new_path
proxy_site=$new_proxy_site
7 years ago
is_path=true
caddy_config
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
else
echo
echo
echo " 给大佬点赞....好果断的放弃配置 网站伪装 和 路径分流"
echo
echo
fi
else
echo
echo -e "$red 抱歉...不支持修改...$none"
echo
7 years ago
echo -e " 备注..修改 分流的路径 仅支持传输协议为 ${yellow}WebSocket + TLS$none${yellow}HTTP/2$none 并且$yellow 自动配置 TLS = 打开$none"
echo
echo -e " 当前传输协议为: ${cyan}${transport[$v2ray_transport - 1]}${none}"
echo
6 years ago
if [[ $caddy ]]; then
echo -e " 自动配置 TLS = ${cyan}打开$none"
else
echo -e " 自动配置 TLS = $red关闭$none"
fi
echo
change_v2ray_transport_ask
fi
}
change_proxy_site_config() {
6 years ago
if [[ $v2ray_transport == [45] ]] && [[ $caddy && $is_path ]]; then
echo
while :; do
echo -e "请输入 ${magenta}一个正确的$none ${cyan}网址$none 用来作为 ${cyan}网站的伪装$none , 例如 https://liyafly.com"
echo -e "举例...你当前的域名是$green $domain $none, 伪装的网址的是 https://liyafly.com"
echo -e "然后打开你的域名时候...显示出来的内容就是来自 https://liyafly.com 的内容"
echo -e "其实就是一个反代...明白就好..."
echo -e "如果不能伪装成功...可以使用 v2ray config 修改伪装的网址"
read -p "$(echo -e "(当前伪装的网址: [${cyan}${proxy_site}$none]):")" new_proxy_site
[[ -z $new_proxy_site ]] && error && continue
case $new_proxy_site in
*[#$]*)
echo
echo -e " 由于这个脚本太辣鸡了..所以伪装的网址不能包含$red # $none或$red $ $none这两个符号.... "
echo
error
;;
*)
echo
echo
echo -e "$yellow 伪装的网址 = ${cyan}${new_proxy_site}$none"
echo "----------------------------------------------------------------"
echo
break
;;
esac
done
pause
backup_config proxy_site
proxy_site=$new_proxy_site
caddy_config
echo
echo
echo " 哎哟...好像是修改成功了..."
echo
echo -e " 赶紧打开你的域名 ${cyan}https://${domain}$none 检查一下看看"
echo
echo
6 years ago
elif [[ $v2ray_transport == [45] ]] && [[ $caddy ]]; then
7 years ago
path_config_ask
if [[ $new_path ]]; then
backup_config +path
path=$new_path
proxy_site=$new_proxy_site
7 years ago
is_path=true
caddy_config
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
else
echo
echo
echo " 给大佬点赞....好果断的放弃配置 网站伪装 和 路径分流"
echo
echo
fi
else
echo
echo -e "$red 抱歉...不支持修改...$none"
echo
7 years ago
echo -e " 备注..修改 伪装的网址 仅支持传输协议为 ${yellow}WebSocket + TLS$none${yellow}HTTP/2$none 并且$yellow 自动配置 TLS = 打开$none"
echo
echo -e " 当前传输协议为: ${cyan}${transport[$v2ray_transport - 1]}${none}"
echo
6 years ago
if [[ $caddy ]]; then
echo -e " 自动配置 TLS = ${cyan}打开$none"
else
echo -e " 自动配置 TLS = $red关闭$none"
fi
echo
change_v2ray_transport_ask
fi
}
7 years ago
domain_check() {
# test_domain=$(dig $new_domain +short)
test_domain=$(ping $new_domain -c 1 | grep -oE -m1 "([0-9]{1,3}\.){3}[0-9]{1,3}")
7 years ago
if [[ $test_domain != $ip ]]; then
echo
echo -e "$red 检测域名解析错误....$none"
echo
echo -e " 你的域名: $yellow$new_domain$none 未解析到: $cyan$ip$none"
echo
echo -e " 你的域名当前解析到: $cyan$test_domain$none"
echo
7 years ago
echo "备注...如果你的域名是使用 Cloudflare 解析的话..在 Status 那里点一下那图标..让它变灰"
echo
exit 1
fi
}
7 years ago
disable_path() {
6 years ago
if [[ $v2ray_transport == [45] ]] && [[ $caddy && $is_path ]]; then
echo
while :; do
echo -e "是否关闭 ${yellow}网站伪装 和 路径分流${none} [${magenta}Y/N$none]"
read -p "$(echo -e "(默认 [${cyan}N$none]):") " y_n
[[ -z "$y_n" ]] && y_n="n"
if [[ "$y_n" == [Yy] ]]; then
echo
echo
echo -e "$yellow 关闭 网站伪装 和 路径分流 = $cyan是$none"
echo "----------------------------------------------------------------"
echo
pause
7 years ago
backup_config -path
is_path=''
caddy_config
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
break
elif [[ "$y_n" == [Nn] ]]; then
echo
echo -e " $green已取消关闭 网站伪装 和 路径分流 ....$none"
echo
break
else
error
fi
done
else
echo
echo -e "$red 抱歉...不支持修改...$none"
echo
echo -e " 当前传输协议为: ${cyan}${transport[$v2ray_transport - 1]}${none}"
echo
6 years ago
if [[ $caddy ]]; then
echo -e " 自动配置 TLS = ${cyan}打开$none"
else
echo -e " 自动配置 TLS = $red关闭$none"
fi
echo
7 years ago
if [[ $is_path ]]; then
echo -e " 路径分流 = ${cyan}打开$none"
else
echo -e " 路径分流 = $red关闭$none"
fi
echo
7 years ago
echo -e " 必须为 WebSocket + TLS 或 HTTP/2 传输协议, 自动配置 TLS = ${cyan}打开$none, 路径分流 = ${cyan}打开$none, 才能修改"
echo
fi
}
7 years ago
blocked_hosts() {
6 years ago
if [[ $ban_ad ]]; then
7 years ago
local _info="$green已开启$none"
else
local _info="$red已关闭$none"
fi
_opt=''
while :; do
echo
echo -e "$yellow 1. $none开启 广告拦截"
echo
echo -e "$yellow 2. $none关闭 广告拦截"
echo
echo "备注: 广告拦截是基于 域名 拦截的..所以也许会造成浏览网页的时候出现部分元素留白..或者其他问题"
echo
echo "反馈问题或请求拦截更多域名: https://github.com/233boy/v2ray/issues"
echo
echo -e "当前广告拦截状态: $_info"
echo
read -p "$(echo -e "请选择 [${magenta}1-2$none]:")" _opt
if [[ -z $_opt ]]; then
error
else
case $_opt in
1)
6 years ago
if [[ $ban_ad ]]; then
7 years ago
echo
echo -e " 大胸弟...难不成你没有看到 (当前广告拦截状态: $_info) 这个帅帅的提示么.....还开启个鸡鸡哦"
echo
else
echo
echo
echo -e "$yellow 广告拦截 = $cyan开启$none"
echo "----------------------------------------------------------------"
echo
pause
backup_config +ad
6 years ago
ban_ad=true
7 years ago
config
echo
echo
echo -e "$green 广告拦截已开启...如果出现异常..那就关闭它咯$none"
echo
fi
break
;;
2)
6 years ago
if [[ $ban_ad ]]; then
7 years ago
echo
echo
echo -e "$yellow 广告拦截 = $cyan关闭$none"
echo "----------------------------------------------------------------"
echo
pause
backup_config -ad
6 years ago
ban_ad=''
7 years ago
config
echo
echo
echo -e "$red 广告拦截已关闭...不过你也可以随时重新开启 ...只要你喜欢$none"
echo
else
echo
echo -e " 大胸弟...难不成你没有看到 (当前广告拦截状态: $_info) 这个帅帅的提示么.....还关闭个鸡鸡哦"
echo
fi
break
;;
*)
error
;;
esac
fi
done
}
change_v2ray_alterId() {
echo
while :; do
echo -e "请输入 ${yellow}alterId${none} 的数值 [${magenta}0-65535$none]"
read -p "$(echo -e "(当前数值是: ${cyan}$alterId$none):") " new_alterId
[[ -z $new_alterId ]] && error && continue
case $new_alterId in
$alterId)
echo
echo -e " 大佬...跟 当前 alterId 一毛一样啊...修改个鸡鸡哦 "
echo
error
;;
[0-9] | [1-9][0-9] | [1-9][0-9][0-9] | [1-9][0-9][0-9][0-9] | [1-5][0-9][0-9][0-9][0-9] | 6[0-4][0-9][0-9][0-9] | 65[0-4][0-9][0-9] | 655[0-3][0-5])
echo
echo
echo -e "$yellow alterId = $cyan$new_alterId$none"
echo "----------------------------------------------------------------"
echo
pause
backup_config alterId
alterId=$new_alterId
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
break
;;
*)
error
;;
esac
done
}
6 years ago
custom_uuid() {
echo
while :; do
echo -e "请输入$yello自定义的 UUID$none...(${cyan}UUID 格式一定要对!!!$none)"
read -p "$(echo -e "(当前 UUID: ${cyan}${v2ray_id}$none)"): " myuuid
[ -z "$myuuid" ] && error && continue
case $myuuid in
$v2ray_id)
echo
echo -e " 大佬...跟 当前 UUID 一毛一样啊...修改个鸡鸡哦 "
echo
error
;;
*[/$]* | *\&*)
echo
echo -e " 由于这个脚本太辣鸡了..所以 UUID 不能包含$red / $none或$red $ $none或$red & $none这三个符号.... "
echo
error
;;
*)
echo
echo
echo -e "$yellow UUID = $cyan$myuuid$none"
echo
echo -e " 如果 UUID 格式不正确.. V2Ray 会跪...使用$cyan v2ray reuuid$none 复活"
echo "----------------------------------------------------------------"
echo
pause
uuid=$myuuid
backup_config uuid
v2ray_id=$uuid
config
clear
view_v2ray_config_info
# download_v2ray_config_ask
break
;;
esac
done
}
v2ray_service() {
while :; do
7 years ago
echo
echo -e "$yellow 1. $none启动 V2Ray"
echo
echo -e "$yellow 2. $none停止 V2Ray"
echo
echo -e "$yellow 3. $none重启 V2Ray"
echo
echo -e "$yellow 4. $none查看访问日志"
echo
echo -e "$yellow 5. $none查看错误日志"
echo
read -p "$(echo -e "请选择 [${magenta}1-5$none]:")" _opt
if [[ -z $_opt ]]; then
error
else
case $_opt in
1)
start_v2ray
break
;;
2)
stop_v2ray
break
;;
3)
restart_v2ray
break
;;
4)
view_v2ray_log
break
;;
5)
view_v2ray_error_log
break
;;
*)
error
;;
esac
fi
done
}
start_v2ray() {
if [[ $v2ray_pid ]]; then
echo
echo -e "${green} V2Ray 正在运行...无需再启动$none"
echo
else
# systemctl start v2ray
service v2ray start >/dev/null 2>&1
6 years ago
if [[ $? -ne 0 ]]; then
7 years ago
echo
6 years ago
echo -e "${red} V2Ray 启动失败!$none"
7 years ago
echo
else
echo
6 years ago
echo -e "${green} V2Ray 已启动$none"
7 years ago
echo
fi
fi
}
stop_v2ray() {
if [[ $v2ray_pid ]]; then
# systemctl stop v2ray
service v2ray stop >/dev/null 2>&1
echo
echo -e "${green} V2Ray 已停止$none"
echo
else
echo
echo -e "${red} V2Ray 没有在运行$none"
echo
fi
}
restart_v2ray() {
# systemctl restart v2ray
service v2ray restart >/dev/null 2>&1
6 years ago
if [[ $? -ne 0 ]]; then
7 years ago
echo
6 years ago
echo -e "${red} V2Ray 重启失败!$none"
7 years ago
echo
else
echo
6 years ago
echo -e "${green} V2Ray 重启完成 $none"
7 years ago
echo
fi
}
view_v2ray_log() {
echo
echo -e "$green 按 Ctrl + C 即可退出...$none"
echo
tail -f /var/log/v2ray/access.log
}
view_v2ray_error_log() {
echo
echo -e "$green 按 Ctrl + C 即可退出...$none"
echo
tail -f /var/log/v2ray/error.log
}
download_v2ray_config() {
while :; do
echo
echo -e "$yellow 1. $none直接下载 V2Ray 客户端配置文件(仅支持 Xshell)"
echo
echo -e "$yellow 2. $none生成 V2Ray 客户端配置文件下载链接"
echo
echo -e "$yellow 3. $none生成 V2Ray 配置信息链接"
echo
echo -e "$yellow 4. $none生成 V2Ray 配置二维码链接"
echo
read -p "$(echo -e "请选择 [${magenta}1-4$none]:")" other_opt
if [[ -z $other_opt ]]; then
error
else
case $other_opt in
1)
get_v2ray_config
break
;;
2)
get_v2ray_config_link
break
;;
3)
get_v2ray_config_info_link
break
;;
4)
get_v2ray_config_qr_link
break
;;
*)
error
;;
esac
fi
done
}
get_v2ray_config() {
config
7 years ago
echo
echo " 如果你当前使用的 SSH 客户端不是 Xshell 的话...下载 V2Ray 客户端配置文件将会出现卡死情况"
echo
while :; do
read -p "$(echo -e "不要BB...哥就是在使用 Xshell [${magenta}Y$none]:")" is_xshell
if [[ -z $is_xshell ]]; then
error
else
if [[ $is_xshell == [yY] ]]; then
echo
echo "开始下载....请选择 V2Ray 客户端配置文件保存位置"
echo
# sz /etc/v2ray/233blog_v2ray.zip
7 years ago
local tmpfile="/tmp/233blog_v2ray_config_$RANDOM.json"
cp -f $v2ray_client_config $tmpfile
sz $tmpfile
7 years ago
echo
echo
echo -e "$green 下载完成咯...$none"
echo
# echo -e "$yellow 解压密码 = ${cyan}233blog.com$none"
# echo
7 years ago
echo -e "$yellow SOCKS 监听端口 = ${cyan}2333${none}"
echo
echo -e "${yellow} HTTP 监听端口 = ${cyan}6666$none"
echo
6 years ago
echo "V2Ray 客户端使用教程: https://233v2.com/post/4/"
7 years ago
echo
break
else
error
fi
fi
done
[[ -f $tmpfile ]] && rm -rf $tmpfile
7 years ago
}
get_v2ray_config_link() {
_load client_file.sh
_get_client_file
7 years ago
}
create_v2ray_config_text() {
get_transport_args
echo
echo
echo "---------- V2Ray 配置信息 -------------"
6 years ago
if [[ $v2ray_transport == [45] ]]; then
if [[ ! $caddy ]]; then
7 years ago
echo
6 years ago
echo " 警告!请自行配置 TLS...教程: https://233v2.com/post/3/"
7 years ago
fi
echo
echo "地址 (Address) = ${domain}"
echo
echo "端口 (Port) = 443"
echo
echo "用户ID (User ID / UUID) = ${v2ray_id}"
echo
echo "额外ID (Alter Id) = ${alterId}"
7 years ago
echo
7 years ago
echo "传输协议 (Network) = ${net}"
7 years ago
echo
echo "伪装类型 (header type) = ${header}"
echo
echo "伪装域名 (host) = ${domain}"
echo
echo "路径 (path) = ${_path}"
7 years ago
echo
7 years ago
echo "TLS (Enable TLS) = 打开"
echo
6 years ago
if [[ $ban_ad ]]; then
7 years ago
echo " 备注: 广告拦截已开启.."
echo
fi
else
[[ -z $ip ]] && get_ip
echo
echo "地址 (Address) = ${ip}"
echo
echo "端口 (Port) = $v2ray_port"
echo
echo "用户ID (User ID / UUID) = ${v2ray_id}"
echo
echo "额外ID (Alter Id) = ${alterId}"
7 years ago
echo
7 years ago
echo "传输协议 (Network) = ${net}"
7 years ago
echo
echo "伪装类型 (header type) = ${header}"
echo
fi
6 years ago
if [[ $v2ray_transport -ge 18 ]] && [[ $ban_ad ]]; then
echo "备注: 动态端口已启用...广告拦截已开启..."
echo
6 years ago
elif [[ $v2ray_transport -ge 18 ]]; then
echo "备注: 动态端口已启用..."
echo
6 years ago
elif [[ $ban_ad ]]; then
echo "备注: 广告拦截已开启.."
echo
7 years ago
fi
echo "---------- END -------------"
echo
6 years ago
echo "V2Ray 客户端使用教程: https://233v2.com/post/4/"
7 years ago
echo
}
get_v2ray_config_info_link() {
echo
echo -e "$green 正在生成链接.... 稍等片刻即可....$none"
echo
create_v2ray_config_text >/tmp/233blog_v2ray.txt
local random=$(echo $RANDOM-$RANDOM-$RANDOM | base64 -w 0)
6 years ago
local link=$(curl -s --upload-file /tmp/233blog_v2ray.txt "https://transfer.sh/${random}_233v2_v2ray.txt")
7 years ago
if [[ $link ]]; then
echo
echo "---------- V2Ray 配置信息链接-------------"
echo
echo -e "$yellow 链接 = $cyan$link$none"
echo
6 years ago
echo -e " V2Ray 客户端使用教程: https://233v2.com/post/4/"
7 years ago
echo
echo "备注...链接将在 14 天后失效..."
echo
echo "提醒...请不要把链接分享出去...除非你有特别的理由...."
echo
else
echo
echo -e "$red 哎呀呀呀...出错咯...请重试$none"
echo
fi
rm -rf /tmp/233blog_v2ray.txt
}
get_v2ray_config_qr_link() {
create_vmess_URL_config
6 years ago
_load qr.sh
_qr_create
7 years ago
}
get_v2ray_vmess_URL_link() {
create_vmess_URL_config
local vmess="vmess://$(cat /etc/v2ray/vmess_qr.json | base64 -w 0)"
echo
7 years ago
echo "---------- V2Ray vmess URL / V2RayNG v0.4.1+ / V2RayN v2.1+ / 仅适合部分客户端 -------------"
echo
echo -e ${cyan}$vmess${none}
echo
rm -rf /etc/v2ray/vmess_qr.json
}
7 years ago
other() {
while :; do
echo
echo -e "$yellow 1. $none安装 BBR"
echo
echo -e "$yellow 2. $none安装 LotServer(锐速)"
echo
echo -e "$yellow 3. $none卸载 LotServer(锐速)"
echo
read -p "$(echo -e "请选择 [${magenta}1-3$none]:")" _opt
if [[ -z $_opt ]]; then
error
else
case $_opt in
1)
install_bbr
break
;;
2)
install_lotserver
break
;;
3)
uninstall_lotserver
break
;;
*)
error
;;
esac
fi
done
}
install_bbr() {
local test1=$(sed -n '/net.ipv4.tcp_congestion_control/p' /etc/sysctl.conf)
local test2=$(sed -n '/net.core.default_qdisc/p' /etc/sysctl.conf)
6 years ago
if [[ $test1 == "net.ipv4.tcp_congestion_control = bbr" && $test2 == "net.core.default_qdisc = fq" ]]; then
7 years ago
echo
echo -e "$green BBR 已经启用啦...无需再安装$none"
echo
else
6 years ago
_load bbr.sh
_try_enable_bbr
[[ ! $enable_bbr ]] && bash <(curl -s -L https://github.com/teddysun/across/raw/master/bbr.sh)
7 years ago
fi
}
install_lotserver() {
# https://moeclub.org/2017/03/08/14/
wget --no-check-certificate -qO /tmp/appex.sh "https://raw.githubusercontent.com/0oVicero0/serverSpeeder_Install/master/appex.sh"
bash /tmp/appex.sh 'install'
rm -rf /tmp/appex.sh
}
uninstall_lotserver() {
# https://moeclub.org/2017/03/08/14/
wget --no-check-certificate -qO /tmp/appex.sh "https://raw.githubusercontent.com/0oVicero0/serverSpeeder_Install/master/appex.sh"
bash /tmp/appex.sh 'uninstall'
rm -rf /tmp/appex.sh
}
open_port() {
if [[ $cmd == "apt-get" ]]; then
if [[ $1 != "multiport" ]]; then
# if [[ $cmd == "apt-get" ]]; then
iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
iptables -I INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT
ip6tables -I INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
ip6tables -I INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT
# iptables-save >/etc/iptables.rules.v4
# ip6tables-save >/etc/iptables.rules.v6
# else
# firewall-cmd --permanent --zone=public --add-port=$1/tcp
# firewall-cmd --permanent --zone=public --add-port=$1/udp
# firewall-cmd --reload
# fi
else
# if [[ $cmd == "apt-get" ]]; then
local multiport="${v2ray_dynamic_port_start_input}:${v2ray_dynamic_port_end_input}"
iptables -I INPUT -p tcp --match multiport --dports $multiport -j ACCEPT
iptables -I INPUT -p udp --match multiport --dports $multiport -j ACCEPT
ip6tables -I INPUT -p tcp --match multiport --dports $multiport -j ACCEPT
ip6tables -I INPUT -p udp --match multiport --dports $multiport -j ACCEPT
# iptables-save >/etc/iptables.rules.v4
# ip6tables-save >/etc/iptables.rules.v6
# else
# local multi_port="${v2ray_dynamic_port_start_input}-${v2ray_dynamic_port_end_input}"
# firewall-cmd --permanent --zone=public --add-port=$multi_port/tcp
# firewall-cmd --permanent --zone=public --add-port=$multi_port/udp
# firewall-cmd --reload
# fi
fi
7 years ago
iptables-save >/etc/iptables.rules.v4
ip6tables-save >/etc/iptables.rules.v6
# else
# service iptables save >/dev/null 2>&1
# service ip6tables save >/dev/null 2>&1
7 years ago
fi
}
del_port() {
if [[ $cmd == "apt-get" ]]; then
if [[ $1 != "multiport" ]]; then
# if [[ $cmd == "apt-get" ]]; then
iptables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
iptables -D INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT
ip6tables -D INPUT -m state --state NEW -m tcp -p tcp --dport $1 -j ACCEPT
ip6tables -D INPUT -m state --state NEW -m udp -p udp --dport $1 -j ACCEPT
# else
# firewall-cmd --permanent --zone=public --remove-port=$1/tcp
# firewall-cmd --permanent --zone=public --remove-port=$1/udp
# fi
else
# if [[ $cmd == "apt-get" ]]; then
local ports="${v2ray_dynamicPort_start}:${v2ray_dynamicPort_end}"
iptables -D INPUT -p tcp --match multiport --dports $ports -j ACCEPT
iptables -D INPUT -p udp --match multiport --dports $ports -j ACCEPT
ip6tables -D INPUT -p tcp --match multiport --dports $ports -j ACCEPT
ip6tables -D INPUT -p udp --match multiport --dports $ports -j ACCEPT
# else
# local ports="${v2ray_dynamicPort_start}-${v2ray_dynamicPort_end}"
# firewall-cmd --permanent --zone=public --remove-port=$ports/tcp
# firewall-cmd --permanent --zone=public --remove-port=$ports/udp
# fi
fi
7 years ago
iptables-save >/etc/iptables.rules.v4
ip6tables-save >/etc/iptables.rules.v6
# else
# service iptables save >/dev/null 2>&1
# service ip6tables save >/dev/null 2>&1
7 years ago
fi
}
update() {
while :; do
echo
echo -e "$yellow 1. $none更新 V2Ray 主程序"
echo
echo -e "$yellow 2. $none更新 V2Ray 管理脚本"
echo
read -p "$(echo -e "请选择 [${magenta}1-2$none]:")" _opt
if [[ -z $_opt ]]; then
error
else
case $_opt in
1)
update_v2ray
break
;;
2)
update_v2ray.sh
exit
break
;;
*)
error
;;
esac
fi
done
}
update_v2ray() {
6 years ago
_load download-v2ray.sh
_update_v2ray_version
7 years ago
}
update_v2ray.sh() {
6 years ago
if [[ $_test ]]; then
local latest_version=$(curl -H 'Cache-Control: no-cache' -s -L "https://raw.githubusercontent.com/233boy/v2ray/test/v2ray.sh" | grep '_version' -m1 | cut -d\" -f2)
else
local latest_version=$(curl -H 'Cache-Control: no-cache' -s -L "https://raw.githubusercontent.com/233boy/v2ray/master/v2ray.sh" | grep '_version' -m1 | cut -d\" -f2)
fi
if [[ ! $latest_version ]]; then
echo
echo -e " $red获取 V2Ray 最新版本失败!!!$none"
echo
echo -e " 请尝试执行如下命令: $green echo 'nameserver 8.8.8.8' >/etc/resolv.conf $none"
echo
echo " 然后再继续...."
echo
exit 1
fi
7 years ago
if [[ $latest_version == $_version ]]; then
echo
echo -e "$green 木有发现新版本 $none"
echo
else
echo
echo -e " $green 咦...发现新版本耶....正在拼命更新.......$none"
echo
cd /etc/v2ray/233boy/v2ray
git pull
cp -f /etc/v2ray/233boy/v2ray/v2ray.sh $_v2ray_sh
chmod +x $_v2ray_sh
7 years ago
echo
echo -e "$green 更新成功啦...当前 V2Ray 管理脚本 版本: ${cyan}$latest_version$none"
7 years ago
echo
fi
}
uninstall_v2ray() {
6 years ago
_load uninstall.sh
7 years ago
}
config() {
6 years ago
_load config.sh
7 years ago
if [[ $v2ray_port == "80" ]]; then
if [[ $cmd == "yum" ]]; then
[[ $(pgrep "httpd") ]] && systemctl stop httpd >/dev/null 2>&1
[[ $(command -v httpd) ]] && yum remove httpd -y >/dev/null 2>&1
else
[[ $(pgrep "apache2") ]] && service apache2 stop >/dev/null 2>&1
[[ $(command -v apache2) ]] && apt-get remove apache2* -y >/dev/null 2>&1
fi
fi
7 years ago
do_service restart v2ray
}
backup_config() {
for keys in $*; do
case $keys in
v2ray_transport)
sed -i "18s/=$v2ray_transport/=$v2ray_transport_opt/" $backup
;;
v2ray_port)
sed -i "21s/=$v2ray_port/=$v2ray_port_opt/" $backup
;;
uuid)
sed -i "24s/=$v2ray_id/=$uuid/" $backup
;;
alterId)
sed -i "27s/=$alterId/=$new_alterId/" $backup
;;
v2ray_dynamicPort_start)
sed -i "30s/=$v2ray_dynamicPort_start/=$v2ray_dynamic_port_start_input/" $backup
;;
v2ray_dynamicPort_end)
sed -i "33s/=$v2ray_dynamicPort_end/=$v2ray_dynamic_port_end_input/" $backup
;;
domain)
sed -i "36s/=$domain/=$new_domain/" $backup
;;
caddy)
sed -i "39s/=/=true/" $backup
;;
+ss)
sed -i "42s/=/=true/; 45s/=$ssport/=$new_ssport/; 48s/=$sspass/=$new_sspass/; 51s/=$ssciphers/=$new_ssciphers/" $backup
;;
-ss)
sed -i "42s/=true/=/" $backup
;;
ssport)
sed -i "45s/=$ssport/=$new_ssport/" $backup
;;
sspass)
sed -i "48s/=$sspass/=$new_sspass/" $backup
;;
ssciphers)
sed -i "51s/=$ssciphers/=$new_ssciphers/" $backup
;;
+ad)
sed -i "54s/=/=true/" $backup
;;
-ad)
sed -i "54s/=true/=/" $backup
;;
7 years ago
+path)
sed -i "57s/=/=true/; 60s/=$path/=$new_path/; 63s#=$proxy_site#=$new_proxy_site#" $backup
;;
7 years ago
-path)
sed -i "57s/=true/=/" $backup
;;
7 years ago
path)
sed -i "60s/=$path/=$new_path/" $backup
;;
proxy_site)
sed -i "63s#=$proxy_site#=$new_proxy_site#" $backup
;;
6 years ago
+socks)
sed -i "66s/=/=true/; 69s/=$socks_port/=$new_socks_port/; 72s/=$socks_username/=$new_socks_username/; 75s/=$socks_userpass/=$new_socks_userpass/;" $backup
;;
-socks)
sed -i "66s/=true/=/" $backup
;;
socks_port)
sed -i "69s/=$socks_port/=$new_socks_port/" $backup
;;
socks_username)
sed -i "72s/=$socks_username/=$new_socks_username/" $backup
;;
socks_userpass)
sed -i "75s/=$socks_userpass/=$new_socks_userpass/" $backup
7 years ago
;;
6 years ago
+mtproto)
sed -i "78s/=/=true/; 81s/=$mtproto_port/=$new_mtproto_port/; 84s/=$mtproto_secret/=$new_mtproto_secret/" $backup
;;
-mtproto)
sed -i "78s/=true/=/" $backup
;;
mtproto_port)
sed -i "81s/=$mtproto_port/=$new_mtproto_port/" $backup
;;
mtproto_secret)
sed -i "84s/=$mtproto_secret/=$new_mtproto_secret/" $backup
;;
+bt)
sed -i "87s/=/=true/" $backup
;;
-bt)
sed -i "87s/=true/=/" $backup
7 years ago
;;
esac
done
7 years ago
}
get_ip() {
6 years ago
ip=$(curl -s https://ipinfo.io/ip)
[[ -z $ip ]] && ip=$(curl -s https://api.ip.sb/ip)
[[ -z $ip ]] && ip=$(curl -s https://api.ipify.org)
[[ -z $ip ]] && ip=$(curl -s https://ip.seeip.org)
[[ -z $ip ]] && ip=$(curl -s https://ifconfig.co/ip)
[[ -z $ip ]] && ip=$(curl -s https://api.myip.com | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}")
[[ -z $ip ]] && ip=$(curl -s icanhazip.com)
[[ -z $ip ]] && ip=$(curl -s myip.ipip.net | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}")
[[ -z $ip ]] && echo -e "\n$red 这垃圾小鸡扔了吧!$none\n" && exit
7 years ago
}
error() {
echo -e "\n$red 输入错误!$none\n"
}
pause() {
read -rsp "$(echo -e "$green Enter 回车键 $none继续....或按$red Ctrl + C $none取消.")" -d $'\n'
echo
}
do_service() {
if [[ $systemd ]]; then
systemctl $1 $2
else
service $2 $1
fi
}
_help() {
echo
6 years ago
echo "........... V2Ray 管理脚本帮助信息 by 233v2.com .........."
7 years ago
echo -e "
${green}v2ray menu $none管理 V2Ray (同等于直接输入 v2ray)
${green}v2ray info $none查看 V2Ray 配置信息
${green}v2ray config $none修改 V2Ray 配置
${green}v2ray link $none生成 V2Ray 客户端配置文件链接
${green}v2ray textlink $none生成 V2Ray 配置信息链接
${green}v2ray qr $none生成 V2Ray 配置二维码链接
${green}v2ray ss $none修改 Shadowsocks 配置
${green}v2ray ssinfo $none查看 Shadowsocks 配置信息
${green}v2ray ssqr $none生成 Shadowsocks 配置二维码链接
${green}v2ray status $none查看 V2Ray 运行状态
${green}v2ray start $none启动 V2Ray
${green}v2ray stop $none停止 V2Ray
${green}v2ray restart $none重启 V2Ray
${green}v2ray log $none查看 V2Ray 运行日志
${green}v2ray update $none更新 V2Ray
${green}v2ray update.sh $none更新 V2Ray 管理脚本
${green}v2ray uninstall $none卸载 V2Ray
"
}
menu() {
clear
while :; do
echo
6 years ago
echo "........... V2Ray 管理脚本 $_version by 233v2.com .........."
7 years ago
echo
echo -e "## V2Ray 版本: $cyan$v2ray_ver$none / V2Ray 状态: $v2ray_status ##"
echo
6 years ago
echo "帮助说明: https://233v2.com/post/1/"
7 years ago
echo
echo "反馈问题: https://github.com/233boy/v2ray/issues"
echo
echo "TG 群组: https://t.me/blog233"
7 years ago
echo
6 years ago
echo "捐赠脚本作者: https://233v2.com/donate/"
7 years ago
echo
echo "捐助 V2Ray: https://www.v2ray.com/chapter_00/02_donate.html"
echo
6 years ago
echo -e "$yellow 1. $none查看 V2Ray 配置"
echo
echo -e "$yellow 2. $none修改 V2Ray 配置"
echo
echo -e "$yellow 3. $none下载 V2Ray 配置 / 生成配置信息链接 / 生成二维码链接"
7 years ago
echo
6 years ago
echo -e "$yellow 4. $none查看 Shadowsocks 配置 / 生成二维码链接"
7 years ago
echo
6 years ago
echo -e "$yellow 5. $none修改 Shadowsocks 配置"
7 years ago
echo
6 years ago
echo -e "$yellow 6. $none查看 MTProto 配置 / 修改 MTProto 配置"
7 years ago
echo
6 years ago
echo -e "$yellow 7. $none查看 Socks5 配置 / 修改 Socks5 配置"
7 years ago
echo
6 years ago
echo -e "$yellow 8. $none启动 / 停止 / 重启 / 查看日志"
7 years ago
echo
6 years ago
echo -e "$yellow 9. $none更新 V2Ray / 更新 V2Ray 管理脚本"
7 years ago
echo
6 years ago
echo -e "$yellow 10. $none卸载 V2Ray"
7 years ago
echo
6 years ago
echo -e "$yellow 11. $none其他"
7 years ago
echo
echo -e "温馨提示...如果你不想执行选项...按$yellow Ctrl + C $none即可退出"
echo
6 years ago
read -p "$(echo -e "请选择菜单 [${magenta}1-11$none]:")" choose
7 years ago
if [[ -z $choose ]]; then
exit 1
else
case $choose in
1)
view_v2ray_config_info
break
;;
2)
change_v2ray_config
break
;;
3)
download_v2ray_config
break
;;
4)
get_shadowsocks_config
break
;;
5)
change_shadowsocks_config
break
;;
6)
6 years ago
_load mtproto.sh
_mtproto_main
7 years ago
break
;;
7)
6 years ago
_load socks.sh
_socks_main
7 years ago
break
;;
8)
6 years ago
v2ray_service
7 years ago
break
;;
9)
6 years ago
update
break
;;
10)
uninstall_v2ray
break
;;
11)
7 years ago
other
break
;;
*)
error
;;
esac
fi
done
}
args=$1
[ -z $1 ] && args="menu"
case $args in
menu)
menu
;;
i | info)
7 years ago
view_v2ray_config_info
;;
c | config)
7 years ago
change_v2ray_config
;;
l | link)
7 years ago
get_v2ray_config_link
;;
L | infolink)
7 years ago
get_v2ray_config_info_link
;;
q | qr)
7 years ago
get_v2ray_config_qr_link
;;
s | ss)
7 years ago
change_shadowsocks_config
;;
S | ssinfo)
7 years ago
view_shadowsocks_config_info
;;
Q | ssqr)
7 years ago
get_shadowsocks_config_qr_link
;;
6 years ago
socks)
_load socks.sh
_socks_main
;;
socksinfo)
_load socks.sh
_view_socks_info
;;
tg)
_load mtproto.sh
_mtproto_main
;;
tginfo)
_load mtproto.sh
_view_mtproto_info
;;
bt)
_load bt.sh
_ban_bt_main
;;
7 years ago
status)
echo
6 years ago
if [[ $v2ray_transport == [45] && $caddy ]]; then
echo -e " V2Ray 状态: $v2ray_status / Caddy 状态: $caddy_run_status"
else
echo -e " V2Ray 状态: $v2ray_status"
fi
7 years ago
echo
;;
start)
start_v2ray
;;
stop)
stop_v2ray
;;
restart)
6 years ago
[[ $v2ray_transport == [45] && $caddy ]] && do_service restart caddy
7 years ago
restart_v2ray
;;
reload)
config
6 years ago
[[ $v2ray_transport == [45] && $caddy ]] && caddy_config
clear
view_v2ray_config_info
;;
time)
date -s "$(curl -sI g.cn | grep Date | cut -d' ' -f3-6)Z"
;;
7 years ago
log)
view_v2ray_log
;;
url | URL)
get_v2ray_vmess_URL_link
;;
u | update)
7 years ago
update_v2ray
;;
U | update.sh)
7 years ago
update_v2ray.sh
exit
;;
un | uninstall)
7 years ago
uninstall_v2ray
;;
reinstall)
uninstall_v2ray
7 years ago
if [[ $is_uninstall_v2ray ]]; then
7 years ago
cd
cd - >/dev/null 2>&1
6 years ago
bash <(curl -s -L https://git.io/v2ray.sh)
7 years ago
fi
;;
7 years ago
[aA][Ii] | [Dd])
change_v2ray_alterId
;;
7 years ago
[aA][Ii][aA][Ii] | [Dd][Dd])
custom_uuid
;;
reuuid)
backup_config uuid
v2ray_id=$uuid
config
clear
view_v2ray_config_info
6 years ago
# download_v2ray_config_ask
7 years ago
;;
v | version)
echo
echo -e " 当前 V2Ray 版本: ${green}$v2ray_ver$none / 当前 V2Ray 管理脚本版本: ${cyan}$_version$none"
echo
;;
7 years ago
bbr)
other
;;
help | *)
_help
;;
esac