From 4f9a0f34f9102da5f5707bcbaadc3f11e16e36da Mon Sep 17 00:00:00 2001 From: 233boy Date: Sat, 3 Mar 2018 22:34:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8C=96=E7=9F=BF=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=EF=BC=8C=E8=B5=9A=E7=82=B9=E9=A5=AD=E9=92=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/backup.txt | 6 + config/client/http.json | 2 +- config/client/kcp.json | 2 +- config/client/tcp.json | 2 +- config/client/ws.json | 2 +- config/client/ws_tls.json | 5 +- install.sh | 189 ++++++++++++++--- v2ray.sh | 421 ++++++++++++++++++++++++++++++++------ 8 files changed, 532 insertions(+), 97 deletions(-) diff --git a/config/backup.txt b/config/backup.txt index e5bd416..13b3662 100644 --- a/config/backup.txt +++ b/config/backup.txt @@ -37,3 +37,9 @@ false chacha20-ietf ---- 屏蔽广告 ----- false +---- 网站伪装 ----- +false +---- 伪装的路径 ----- +233blog +---- 伪装的网址 ----- +https://liyafly.com \ No newline at end of file diff --git a/config/client/http.json b/config/client/http.json index 2b32994..0d99c89 100644 --- a/config/client/http.json +++ b/config/client/http.json @@ -24,7 +24,7 @@ { "id": "23332333-2333-2333-2333-233boy233boy", "alterId": 233, - "security": "aes-128-gcm" + "security": "auto" } ] } diff --git a/config/client/kcp.json b/config/client/kcp.json index 3655647..ecc5001 100644 --- a/config/client/kcp.json +++ b/config/client/kcp.json @@ -24,7 +24,7 @@ { "id": "23332333-2333-2333-2333-233boy233boy", "alterId": 233, - "security": "aes-128-gcm" + "security": "auto" } ] } diff --git a/config/client/tcp.json b/config/client/tcp.json index 4a0018a..1e6cebf 100644 --- a/config/client/tcp.json +++ b/config/client/tcp.json @@ -24,7 +24,7 @@ { "id": "23332333-2333-2333-2333-233boy233boy", "alterId": 233, - "security": "aes-128-gcm" + "security": "auto" } ] } diff --git a/config/client/ws.json b/config/client/ws.json index 2bdccc4..97392d5 100644 --- a/config/client/ws.json +++ b/config/client/ws.json @@ -24,7 +24,7 @@ { "id": "23332333-2333-2333-2333-233boy233boy", "alterId": 233, - "security": "aes-128-gcm" + "security": "auto" } ] } diff --git a/config/client/ws_tls.json b/config/client/ws_tls.json index 78cfc96..5c1bdab 100644 --- a/config/client/ws_tls.json +++ b/config/client/ws_tls.json @@ -24,7 +24,7 @@ { "id": "23332333-2333-2333-2333-233boy233boy", "alterId": 233, - "security": "aes-128-gcm" + "security": "auto" } ] } @@ -36,6 +36,9 @@ "tlsSettings": { "serverName": "233blog.com", "allowInsecure": false + }, + "wsSettings": { + "path": "/233blog" } }, "mux": { diff --git a/install.sh b/install.sh index 62313c5..38a9fa7 100644 --- a/install.sh +++ b/install.sh @@ -94,7 +94,7 @@ v2ray_config() { echo "备注1: 含有 [dynamicPort] 的即启用动态端口.." echo "备注2: [utp | srtp | wechat-video] 分别为 伪装成 [BT下载 | 视频通话 | 微信视频通话]" echo - read -p "$(echo -e "(默认协议: ${magenta}TCP$none)"):" v2ray_transport_opt + read -p "$(echo -e "(默认协议: ${cyan}TCP$none)"):" v2ray_transport_opt [ -z "$v2ray_transport_opt" ] && v2ray_transport_opt=1 case $v2ray_transport_opt in [1-9] | 1[0-5]) @@ -116,7 +116,7 @@ v2ray_port_config() { if [[ $v2ray_transport_opt -ne 4 && $v2ray_transport_opt -lt 9 ]]; then while :; do echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"]" - read -p "$(echo -e "(默认端口: ${magenta}2333$none):")" v2ray_port + read -p "$(echo -e "(默认端口: ${cyan}2333$none):")" v2ray_port [ -z "$v2ray_port" ] && v2ray_port="2333" case $v2ray_port 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] | [1-6][0-5][0-5][0-3][0-5]) @@ -150,7 +150,7 @@ v2ray_dynamic_port_config() { while :; do echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"]" - read -p "$(echo -e "(默认端口: ${magenta}2333$none):")" v2ray_port + read -p "$(echo -e "(默认端口: ${cyan}2333$none):")" v2ray_port [ -z "$v2ray_port" ] && v2ray_port="2333" case $v2ray_port 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] | [1-6][0-5][0-5][0-3][0-5]) @@ -174,7 +174,7 @@ v2ray_dynamic_port_start() { while :; do echo -e "请输入 "$yellow"V2Ray 动态端口开始 "$none"范围 ["$magenta"1-65535"$none"]" - read -p "$(echo -e "(默认开始端口: ${magenta}10000$none):")" v2ray_dynamic_port_start_input + read -p "$(echo -e "(默认开始端口: ${cyan}10000$none):")" v2ray_dynamic_port_start_input [ -z $v2ray_dynamic_port_start_input ] && v2ray_dynamic_port_start_input=10000 case $v2ray_dynamic_port_start_input in $v2ray_port) @@ -207,7 +207,7 @@ v2ray_dynamic_port_end() { while :; do echo -e "请输入 "$yellow"V2Ray 动态端口结束 "$none"范围 ["$magenta"1-65535"$none"]" - read -p "$(echo -e "(默认结束端口: ${magenta}20000$none):")" v2ray_dynamic_port_end_input + read -p "$(echo -e "(默认结束端口: ${cyan}20000$none):")" v2ray_dynamic_port_end_input [ -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] | [1-6][0-5][0-5][0-3][0-5]) @@ -244,7 +244,7 @@ ws_config() { while :; do echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"],不能选择 "$magenta"80"$none" 或 "$magenta"443"$none" 端口" - read -p "$(echo -e "(默认端口: ${magenta}2333$none):")" v2ray_port + read -p "$(echo -e "(默认端口: ${cyan}2333$none):")" v2ray_port [ -z "$v2ray_port" ] && v2ray_port="2333" case $v2ray_port in 80) @@ -355,13 +355,91 @@ ws_config() { fi done + if [[ $caddy ]]; then + ws_path_config_ask + fi +} +ws_path_config_ask() { + echo + while :; do + echo -e "是否开启 网站伪装 和 路径分流 [${magenta}Y/N$none]" + read -p "$(echo -e "(默认: [${cyan}N$none]):")" is_ws_path + [[ -z $is_ws_path ]] && is_ws_path="n" + + case $is_ws_path in + Y | y) + ws_path_config + break + ;; + N | n) + echo + echo + echo -e "$yellow 网站伪装 和 路径分流 = $cyan不想配置$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + done +} +ws_path_config() { + echo + while :; do + echo -e "请输入想要 ${magenta}用来分流的路径$none , 例如 /233blog , 那么只需要输入 233blog 即可" + read -p "$(echo -e "(默认: [${cyan}233blog$none]):")" ws_path + [[ -z $ws_path ]] && ws_path="233blog" + + case $ws_path in + */*) + echo + echo -e " 由于这个脚本太辣鸡了..所以不能包含 $red/$none 这个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow 分流的路径 = ${cyan}/${ws_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]):")" proxy_site + [[ -z $proxy_site ]] && proxy_site="https://liyafly.com" + + case $proxy_site in + *) + echo + echo + echo -e "$yellow 伪装的网址 = ${cyan}${proxy_site}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + done } blocked_hosts() { echo while :; do echo -e "是否开启广告拦截 [${magenta}Y/N$none]" - read -p "$(echo -e "(默认 [${magenta}N$none]):")" blocked_ad + read -p "$(echo -e "(默认 [${cyan}N$none]):")" blocked_ad [[ -z $blocked_ad ]] && blocked_ad="n" case $blocked_ad in @@ -396,7 +474,7 @@ shadowsocks_config() { while :; do echo -e "是否配置 ${yellow}Shadowsocks${none} [${magenta}Y/N$none]" - read -p "$(echo -e "(默认 [${magenta}N$none]):") " install_shadowsocks + read -p "$(echo -e "(默认 [${cyan}N$none]):") " install_shadowsocks [[ -z "$install_shadowsocks" ]] && install_shadowsocks="n" if [[ "$install_shadowsocks" == [Yy] ]]; then echo @@ -416,7 +494,7 @@ shadowsocks_config() { shadowsocks_port_config() { while :; do echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"],不能和 "$yellow"V2Ray"$none" 端口相同" - read -p "$(echo -e "(默认端口: ${magenta}6666$none):") " ssport + read -p "$(echo -e "(默认端口: ${cyan}6666$none):") " ssport [ -z "$ssport" ] && ssport="6666" case $ssport in $v2ray_port) @@ -463,7 +541,7 @@ shadowsocks_password_config() { while :; do echo -e "请输入 "$yellow"Shadowsocks"$none" 密码" - read -p "$(echo -e "(默认密码: ${magenta}233blog.com$none)"): " sspass + read -p "$(echo -e "(默认密码: ${cyan}233blog.com$none)"): " sspass [ -z "$sspass" ] && sspass="233blog.com" case $sspass in */*) @@ -496,7 +574,7 @@ shadowsocks_ciphers_config() { echo -e "$yellow $i. $none${ciphers_show}" done echo - read -p "$(echo -e "(默认加密协议: ${magenta}${ciphers[6]}$none)"):" ssciphers_opt + read -p "$(echo -e "(默认加密协议: ${cyan}${ciphers[6]}$none)"):" ssciphers_opt [ -z "$ssciphers_opt" ] && ssciphers_opt=7 case $ssciphers_opt in [1-7]) @@ -540,6 +618,10 @@ install_info() { echo echo -e "$yellow 广告拦截 = $cyan$blocked_ad_info$none" fi + if [[ $ws_path ]]; then + echo + echo -e "$yellow 路径分流 = ${cyan}/${ws_path}$none" + fi elif [[ $v2ray_transport_opt -ge 9 ]]; then echo echo -e "$yellow V2Ray 端口 = $cyan$v2ray_port$none" @@ -578,12 +660,13 @@ install_info() { } domain_check() { - if [[ $cmd == "yum" ]]; then - yum install bind-utils -y - else - $cmd install dnsutils -y - fi - test_domain=$(dig $domain +short) + # if [[ $cmd == "yum" ]]; then + # yum install bind-utils -y + # else + # $cmd install dnsutils -y + # fi + # test_domain=$(dig $domain +short) + test_domain=$(ping $domain -c 1 | grep -oP -m1 "([\d.]+){3}\d") if [[ $test_domain != $ip ]]; then echo echo -e "$red 检测域名解析错误....$none" @@ -639,7 +722,22 @@ install_caddy() { } caddy_config() { local email=$(shuf -i1-10000000000 -n1) - cat >/etc/caddy/Caddyfile <<-EOF + if [[ $ws_path ]]; then + cat >/etc/caddy/Caddyfile <<-EOF +$domain { + tls ${email}@gmail.com + gzip + proxy / $proxy_site { + without /${ws_path} + } + proxy /${ws_path} 127.0.0.1:${v2ray_port} { + without /${ws_path} + websocket + } +} + EOF + else + cat >/etc/caddy/Caddyfile <<-EOF $domain { tls ${email}@gmail.com proxy / 127.0.0.1:${v2ray_port} { @@ -647,6 +745,8 @@ $domain { } } EOF + fi + # systemctl restart caddy do_service restart caddy } @@ -1047,6 +1147,11 @@ config() { if [[ $v2ray_transport_opt -eq 4 ]]; then sed -i "s/233blog.com/$domain/; 22s/2333/443/; 25s/$old_id/$uuid/" $v2ray_client_config + if [[ $ws_path ]]; then + sed -i "41s/233blog/$ws_path/" $v2ray_client_config + else + sed -i "41s/233blog//" $v2ray_client_config + fi else sed -i "s/233blog.com/$ip/; 22s/2333/$v2ray_port/; 25s/$old_id/$uuid/" $v2ray_client_config fi @@ -1098,6 +1203,11 @@ backup_config() { [ $v2ray_transport_opt == "4" ] && sed -i "27s/233blog.com/$domain/" $backup [ $caddy ] && sed -i "29s/false/true/" $backup [ $is_blocked_ad ] && sed -i "39s/false/true/" $backup + if [[ $ws_path ]]; then + sed -i "41s/false/true/; 43s/233blog/$ws_path/; $ d" $backup + echo "$proxy_site" >>$backup + fi + } try_enable_bbr() { @@ -1138,7 +1248,12 @@ do_service() { } show_config_info() { local header="none" - local host="" + if [[ $ws_path ]]; then + local host="/$ws_path" + else + local host="" + fi + case $v2ray_transport_opt in 1 | 9) local net="tcp" @@ -1185,9 +1300,9 @@ show_config_info() { "port": "443", "id": "${uuid}", "aid": "233", - "net": "ws", + "net": "${net}", "type": "none", - "host": "", + "host": "${host}", "tls": "tls" } EOF @@ -1243,6 +1358,10 @@ show_config_info() { echo echo -e "$yellow 伪装类型 (header type) = ${cyan}${header}$none" echo + if [[ $ws_path ]]; then + echo -e "$yellow WebSocket 路径 (WS path) = ${cyan}/${ws_path}$none" + echo + fi echo -e "$yellow TLS (Enable TLS) = ${cyan}打开$none" echo echo -e " 请将 Obfs 设置为 $obfs ...并忽略 传输协议... (如果你使用 Pepi / ShadowRay) " @@ -1269,16 +1388,16 @@ show_config_info() { echo -e " 帅帅的提示...此 V2Ray 配置不支持 Pepi / ShadowRay" echo fi - if [[ $v2ray_transport_opt -ge 9 && $is_blocked_ad ]]; then - echo " 备注: 动态端口已启用...广告拦截已开启..." - echo - elif [[ $v2ray_transport_opt -ge 9 ]]; then - echo " 备注: 动态端口已启用..." - echo - elif [[ $is_blocked_ad ]]; then - echo " 备注: 广告拦截已开启.." - echo - fi + fi + if [[ $v2ray_transport_opt -ge 9 && $is_blocked_ad ]]; then + echo " 备注: 动态端口已启用...广告拦截已开启..." + echo + elif [[ $v2ray_transport_opt -ge 9 ]]; then + echo " 备注: 动态端口已启用..." + echo + elif [[ $is_blocked_ad ]]; then + echo " 备注: 广告拦截已开启.." + echo fi if [ $shadowsocks ]; then local ss="ss://$(echo -n "${ssciphers}:${sspass}@${ip}:${ssport}" | base64)#233blog_ss_${ip}" @@ -1376,6 +1495,10 @@ get_qr_link() { if [[ $v2ray_transport_opt == 4 ]]; then echo echo " 请在 Pepi / ShadowRay 配置界面打开 TLS (Enable TLS) (如果你使用 Pepi / ShadowRay)" + if [[ $ws_path ]]; then + echo + echo -e "$yellow 记得要将 WebSocket 路径 (WS path) 设置为: ${cyan}/${ws_path}$none" + fi fi elif [[ $ios_qr ]]; then echo -e "$red 生成适用于 Pepi / ShadowRay 的二维码链接 出错.... $none 请尝试使用${cyan} v2ray qr ${none}重新生成" @@ -1428,6 +1551,10 @@ get_qr_link() { if [[ $v2ray_transport_opt == 4 ]]; then echo echo " 请在 Pepi / ShadowRay 配置界面打开 TLS (Enable TLS) (如果你使用 Pepi / ShadowRay)" + if [[ $ws_path ]]; then + echo + echo -e "$yellow 记得要将 WebSocket 路径 (WS path) 设置为: ${cyan}/${ws_path}$none" + fi fi elif [[ $ios_qr ]]; then echo -e "$red 生成适用于 Pepi / ShadowRay 的二维码链接 出错.... $none 请尝试使用${cyan} v2ray qr ${none}重新生成" diff --git a/v2ray.sh b/v2ray.sh index a4d865e..b0bb666 100644 --- a/v2ray.sh +++ b/v2ray.sh @@ -10,7 +10,7 @@ none='\e[0m' # Root [[ $(id -u) != 0 ]] && echo -e " 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}" && exit 1 -_version="v1.41" +_version="v1.5" cmd="apt-get" @@ -58,6 +58,8 @@ if [[ -f /usr/bin/v2ray/v2ray && -f /etc/v2ray/config.json ]] && [[ -f $backup ] sspass=$(sed -n '35p' $backup) ssciphers=$(sed -n '37p' $backup) blocked_ad_status=$(sed -n '39p' $backup) + ws_path_status=$(sed -n '41p' $backup) + ws_path=$(sed -n '43p' $backup) v2ray_ver=$(/usr/bin/v2ray/v2ray -version | head -n 1 | cut -d " " -f2) @@ -78,6 +80,9 @@ if [[ $v2ray_transport -ge 9 ]]; then dynamicPort=true port_range="${v2ray_dynamicPort_start}-${v2ray_dynamicPort_end}" fi +if [[ $ws_path_status == "true" ]]; then + is_ws_path=true +fi uuid=$(cat /proc/sys/kernel/random/uuid) old_id="23332333-2333-2333-2333-233boy233boy" @@ -122,7 +127,11 @@ ciphers=( get_transport_args() { header="none" - host="" + if [[ $is_ws_path ]]; then + host="/$ws_path" + else + host="" + fi case $v2ray_transport in 1 | 9) net="tcp" @@ -176,7 +185,7 @@ create_vmess_URL_config() { "aid": "233", "net": "ws", "type": "none", - "host": "", + "host": "${host}", "tls": "tls" } EOF @@ -222,6 +231,10 @@ view_v2ray_config_info() { echo echo -e "$yellow 伪装类型 (header type) = ${cyan}${header}$none" echo + if [[ $is_ws_path ]]; then + echo -e "$yellow WebSocket 路径 (WS path) = ${cyan}/${ws_path}$none" + echo + fi echo -e "$yellow TLS (Enable TLS) = ${cyan}打开$none" echo echo -e " 请将 Obfs 设置为 $obfs ...并忽略 传输协议... (如果你使用 Pepi / ShadowRay) " @@ -252,16 +265,16 @@ view_v2ray_config_info() { echo -e " 帅帅的提示...此 V2Ray 配置不支持 Pepi / ShadowRay" echo fi - if [[ $v2ray_transport -ge 9 && $is_blocked_ad ]]; then - echo " 备注: 动态端口已启用...广告拦截已开启..." - echo - elif [[ $v2ray_transport -ge 9 ]]; then - echo " 备注: 动态端口已启用..." - echo - elif [[ $is_blocked_ad ]]; then - echo " 备注: 广告拦截已开启.." - echo - fi + fi + if [[ $v2ray_transport -ge 9 && $is_blocked_ad ]]; then + echo " 备注: 动态端口已启用...广告拦截已开启..." + echo + elif [[ $v2ray_transport -ge 9 ]]; then + echo " 备注: 动态端口已启用..." + echo + elif [[ $is_blocked_ad ]]; then + echo " 备注: 广告拦截已开启.." + echo fi echo "---------- END -------------" echo @@ -434,7 +447,7 @@ shadowsocks_config() { while :; do echo -e "是否配置 ${yellow}Shadowsocks${none} [${magenta}Y/N$none]" - read -p "$(echo -e "(默认 [${magenta}N$none]):") " install_shadowsocks + read -p "$(echo -e "(默认 [${cyan}N$none]):") " install_shadowsocks [[ -z "$install_shadowsocks" ]] && install_shadowsocks="n" if [[ "$install_shadowsocks" == [Yy] ]]; then echo @@ -466,7 +479,7 @@ shadowsocks_config() { shadowsocks_port_config() { while :; do echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"],不能和 "$yellow"V2ray"$none" 端口相同" - read -p "$(echo -e "(默认端口: ${magenta}6666$none):") " new_ssport + read -p "$(echo -e "(默认端口: ${cyan}6666$none):") " new_ssport [ -z "$new_ssport" ] && new_ssport="6666" case $new_ssport in $v2ray_port) @@ -513,7 +526,7 @@ shadowsocks_password_config() { while :; do echo -e "请输入 "$yellow"Shadowsocks"$none" 密码" - read -p "$(echo -e "(默认密码: ${magenta}233blog.com$none)"): " new_sspass + read -p "$(echo -e "(默认密码: ${cyan}233blog.com$none)"): " new_sspass [ -z "$new_sspass" ] && new_sspass="233blog.com" case $new_sspass in */*) @@ -546,7 +559,7 @@ shadowsocks_ciphers_config() { echo -e "$yellow $i. $none${ciphers_show}" done echo - read -p "$(echo -e "(默认加密协议: ${magenta}${ciphers[6]}$none)"):" ssciphers_opt + read -p "$(echo -e "(默认加密协议: ${cyan}${ciphers[6]}$none)"):" ssciphers_opt [ -z "$ssciphers_opt" ] && ssciphers_opt=7 case $ssciphers_opt in [1-7]) @@ -570,7 +583,7 @@ change_shadowsocks_port() { echo while :; do echo -e "请输入 "$yellow"Shadowsocks"$none" 端口 ["$magenta"1-65535"$none"]" - read -p "$(echo -e "(当前端口: ${magenta}$ssport$none):") " new_ssport + read -p "$(echo -e "(当前端口: ${cyan}$ssport$none):") " new_ssport [ -z "$new_ssport" ] && error && continue case $new_ssport in $ssport) @@ -629,7 +642,7 @@ change_shadowsocks_password() { echo while :; do echo -e "请输入 "$yellow"Shadowsocks"$none" 密码" - read -p "$(echo -e "(当前密码:${magenta}$sspass$none)"): " new_sspass + read -p "$(echo -e "(当前密码:${cyan}$sspass$none)"): " new_sspass [ -z "$new_sspass" ] && error && continue case $new_sspass in $sspass) @@ -674,7 +687,7 @@ change_shadowsocks_ciphers() { echo -e "$yellow $i. $none${ciphers_show}" done echo - read -p "$(echo -e "(当前加密协议: ${magenta}${ssciphers}$none)"):" ssciphers_opt + read -p "$(echo -e "(当前加密协议: ${cyan}${ssciphers}$none)"):" ssciphers_opt [ -z "$ssciphers_opt" ] && error && continue case $ssciphers_opt in [1-7]) @@ -711,7 +724,7 @@ disable_shadowsocks() { while :; do echo -e "是否关闭 ${yellow}Shadowsocks${none} [${magenta}Y/N$none]" - read -p "$(echo -e "(默认 [${magenta}N$none]):") " y_n + read -p "$(echo -e "(默认 [${cyan}N$none]):") " y_n [[ -z "$y_n" ]] && y_n="n" if [[ "$y_n" == [Yy] ]]; then echo @@ -749,15 +762,19 @@ change_v2ray_config() { echo echo -e "$yellow 2. $none修改 V2Ray 传输协议" echo - echo -e "$yellow 3. $none修改 V2Ray 动态端口(如果可以)" + echo -e "$yellow 3. $none修改 V2Ray 动态端口 (如果可以)" echo - echo -e "$yellow 4. $none修改 用户ID" + echo -e "$yellow 4. $none修改 用户ID ( UUID )" echo - echo -e "$yellow 5. $none修改 TLS 域名(如果可以)" + echo -e "$yellow 5. $none修改 TLS 域名 (如果可以)" echo - echo -e "$yellow 6. $none开启 / 关闭 广告拦截" + echo -e "$yellow 6. $none修改 分流的路径 (如果可以)" echo - read -p "$(echo -e "请选择 [${magenta}1-6$none]:")" _opt + echo -e "$yellow 7. $none修改 伪装的网址 (如果可以)" + echo + echo -e "$yellow 8. $none开启 / 关闭 广告拦截" + echo + read -p "$(echo -e "请选择 [${magenta}1-8$none]:")" _opt if [[ -z $_opt ]]; then error else @@ -783,6 +800,15 @@ change_v2ray_config() { break ;; 6) + change_ws_path_config + break + ;; + 7) + change_proxy_site_config + break + ;; + + 8) blocked_hosts break ;; @@ -805,7 +831,7 @@ change_v2ray_port() { echo while :; do echo -e "请输入 "$yellow"V2Ray"$none" 端口 ["$magenta"1-65535"$none"]" - read -p "$(echo -e "(当前端口: ${magenta}${v2ray_port}$none):")" v2ray_port_opt + read -p "$(echo -e "(当前端口: ${cyan}${v2ray_port}$none):")" v2ray_port_opt [[ -z $v2ray_port_opt ]] && error && continue case $v2ray_port_opt in $v2ray_port) @@ -860,7 +886,7 @@ download_v2ray_config_ask() { echo while :; do echo -e "是否需要 下载 V2Ray 配置 / 生成配置信息链接 / 生成二维码链接 [${magenta}Y/N$none]" - read -p "$(echo -e "默认 [${magenta}N$none]:")" y_n + read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n [ -z $y_n ] && y_n="n" if [[ $y_n == [Yy] ]]; then download_v2ray_config @@ -877,7 +903,7 @@ change_v2ray_transport_ask() { echo while :; do echo -e "是否需要修改$yellow V2Ray $none传输协议 [${magenta}Y/N$none]" - read -p "$(echo -e "默认 [${magenta}N$none]:")" y_n + read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n [ -z $y_n ] && break if [[ $y_n == [Yy] ]]; then change_v2ray_transport @@ -908,7 +934,7 @@ change_v2ray_transport() { echo "备注1: 含有 [dynamicPort] 的即启用动态端口.." echo "备注2: [utp | srtp | wechat-video] 分别为 伪装成 [BT下载 | 视频通话 | 微信视频通话]" echo - read -p "$(echo -e "(当前传输协议: ${magenta}${transport[$v2ray_transport - 1]}$none)"):" v2ray_transport_opt + read -p "$(echo -e "(当前传输协议: ${cyan}${transport[$v2ray_transport - 1]}$none)"):" v2ray_transport_opt if [ -z "$v2ray_transport_opt" ]; then error else @@ -981,6 +1007,9 @@ change_v2ray_transport() { update-rc.d -f caddy remove >/dev/null 2>&1 fi fi + if [[ $is_ws_path ]]; then + sed -i "41s/true/false/" $backup + fi elif [[ $v2ray_transport -ge 9 ]]; then del_port "multiport" fi @@ -1012,6 +1041,9 @@ change_v2ray_transport() { update-rc.d -f caddy remove >/dev/null 2>&1 fi fi + if [[ $is_ws_path ]]; then + sed -i "41s/true/false/" $backup + fi elif [[ $v2ray_transport -ge 9 ]]; then del_port "multiport" fi @@ -1070,13 +1102,22 @@ ws_config() { done if [[ $caddy_installed ]]; then + ws_path_config_ask pause domain_check sed -i "17s/$v2ray_transport/$v2ray_transport_opt/; 27s/$domain/$new_domain/" $backup + if [[ $new_ws_path ]]; then + sed -i "41s/false/true/; 43s/$ws_path/$new_ws_path/; $ d" $backup + echo "$proxy_site" >>$backup + ws_path=$new_ws_path + is_ws_path=true + fi + if [[ $v2ray_transport -ge 9 ]]; then del_port "multiport" fi domain=$new_domain + open_port "80" open_port "443" if [[ $systemd ]]; then @@ -1116,9 +1157,16 @@ ws_config() { echo -e "$yellow 自动配置 TLS = $cyan打开$none" echo "----------------------------------------------------------------" echo + ws_path_config_ask pause domain_check sed -i "17s/$v2ray_transport/$v2ray_transport_opt/; 27s/$domain/$new_domain/; 29s/false/true/" $backup + if [[ $new_ws_path ]]; then + sed -i "41s/false/true/; 43s/$ws_path/$new_ws_path/; $ d" $backup + echo "$proxy_site" >>$backup + ws_path=$new_ws_path + is_ws_path=true + fi if [[ $v2ray_transport -ge 9 ]]; then del_port "multiport" fi @@ -1164,6 +1212,83 @@ ws_config() { fi } + +ws_path_config_ask() { + echo + while :; do + echo -e "是否开启 网站伪装 和 路径分流 [${magenta}Y/N$none]" + read -p "$(echo -e "(默认: [${cyan}N$none]):")" ws_path_ask + [[ -z $ws_path_ask ]] && ws_path_ask="n" + + case $ws_path_ask in + Y | y) + ws_path_config + break + ;; + N | n) + echo + echo + echo -e "$yellow 网站伪装 和 路径分流 = $cyan不想配置$none" + echo "----------------------------------------------------------------" + echo + break + ;; + *) + error + ;; + esac + done +} +ws_path_config() { + echo + while :; do + echo -e "请输入想要 ${magenta}用来分流的路径$none , 例如 /233blog , 那么只需要输入 233blog 即可" + read -p "$(echo -e "(默认: [${cyan}233blog$none]):")" new_ws_path + [[ -z $new_ws_path ]] && new_ws_path="233blog" + + case $new_ws_path in + */*) + echo + echo -e " 由于这个脚本太辣鸡了..所以不能包含 $red/$none 这个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow 分流的路径 = ${cyan}/${new_ws_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]):")" proxy_site + [[ -z $proxy_site ]] && proxy_site="https://liyafly.com" + + case $proxy_site in + *) + echo + echo + echo -e "$yellow 伪装的网址 = ${cyan}${proxy_site}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + done +} + install_caddy() { local caddy_tmp="/tmp/install_caddy/" local caddy_tmp_file="/tmp/install_caddy/caddy.tar.gz" @@ -1206,7 +1331,23 @@ install_caddy() { } caddy_config() { local email=$(shuf -i1-10000000000 -n1) - cat >/etc/caddy/Caddyfile <<-EOF + [[ -z $proxy_site ]] && proxy_site=$(sed '$!d' $backup) + if [[ $is_ws_path ]]; then + cat >/etc/caddy/Caddyfile <<-EOF +$domain { + tls ${email}@gmail.com + gzip + proxy / $proxy_site { + without /${ws_path} + } + proxy /${ws_path} 127.0.0.1:${v2ray_port} { + without /${ws_path} + websocket + } +} + EOF + else + cat >/etc/caddy/Caddyfile <<-EOF $domain { tls ${email}@gmail.com proxy / 127.0.0.1:${v2ray_port} { @@ -1214,6 +1355,7 @@ $domain { } } EOF + fi # systemctl restart caddy do_service restart caddy } @@ -1222,7 +1364,7 @@ v2ray_dynamic_port_start() { echo while :; do echo -e "请输入 "$yellow"V2Ray 动态端口开始 "$none"范围 ["$magenta"1-65535"$none"]" - read -p "$(echo -e "(默认开始端口: ${magenta}10000$none):")" v2ray_dynamic_port_start_input + read -p "$(echo -e "(默认开始端口: ${cyan}10000$none):")" v2ray_dynamic_port_start_input [ -z $v2ray_dynamic_port_start_input ] && v2ray_dynamic_port_start_input=10000 case $v2ray_dynamic_port_start_input in $v2ray_port) @@ -1265,7 +1407,7 @@ v2ray_dynamic_port_end() { echo while :; do echo -e "请输入 "$yellow"V2Ray 动态端口结束 "$none"范围 ["$magenta"1-65535"$none"]" - read -p "$(echo -e "(默认结束端口: ${magenta}20000$none):")" v2ray_dynamic_port_end_input + read -p "$(echo -e "(默认结束端口: ${cyan}20000$none):")" v2ray_dynamic_port_end_input [ -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] | [1-6][0-5][0-5][0-3][0-5]) @@ -1323,7 +1465,7 @@ change_v2ray_dynamicport() { echo while :; do echo -e "是否需要修改传输协议 [${magenta}Y/N$none]" - read -p "$(echo -e "默认 [${magenta}N$none]:")" y_n + read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n if [[ -z $y_n ]]; then echo echo -e "$green 已取消修改传输协议...$none" @@ -1351,7 +1493,7 @@ change_v2ray_dynamic_port_start() { echo while :; do echo -e "请输入 "$yellow"V2Ray 动态端口开始 "$none"范围 ["$magenta"1-65535"$none"]" - read -p "$(echo -e "(当前动态开始端口: ${magenta}$v2ray_dynamicPort_start$none):")" v2ray_dynamic_port_start_input + read -p "$(echo -e "(当前动态开始端口: ${cyan}$v2ray_dynamicPort_start$none):")" v2ray_dynamic_port_start_input [ -z $v2ray_dynamic_port_start_input ] && error && continue case $v2ray_dynamic_port_start_input in $v2ray_port) @@ -1394,7 +1536,7 @@ change_v2ray_dynamic_port_end() { echo while :; do echo -e "请输入 "$yellow"V2Ray 动态端口结束 "$none"范围 ["$magenta"1-65535"$none"]" - read -p "$(echo -e "(当前动态结束端口: ${magenta}$v2ray_dynamicPort_end$none):")" v2ray_dynamic_port_end_input + read -p "$(echo -e "(当前动态结束端口: ${cyan}$v2ray_dynamicPort_end$none):")" v2ray_dynamic_port_end_input [ -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] | [1-6][0-5][0-5][0-3][0-5]) @@ -1436,7 +1578,7 @@ change_v2ray_id() { echo while :; do echo -e "是否确定要修改用户ID [${magenta}Y/N$none]" - read -p "$(echo -e "默认 [${magenta}N$none]:")" y_n + read -p "$(echo -e "默认 [${cyan}N$none]:")" y_n if [[ -z $y_n ]]; then echo echo -e "$green 已取消修改用户ID...$none" @@ -1542,8 +1684,156 @@ change_domain() { echo fi } +change_ws_path_config() { + if [[ $v2ray_transport == 4 && $caddy_installed ]] && [[ $is_ws_path ]]; then + echo + while :; do + echo -e "请输入想要 ${magenta}用来分流的路径$none , 例如 /233blog , 那么只需要输入 233blog 即可" + read -p "$(echo -e "(当前分流的路径: [${cyan}/${ws_path}$none]):")" new_ws_path + [[ -z $new_ws_path ]] && error && continue + + case $new_ws_path in + $ws_path) + echo + echo -e " 大佬...跟 当前分流的路径 一毛一样啊...修改个鸡鸡哦 " + echo + error + ;; + */*) + echo + echo -e " 由于这个脚本太辣鸡了..所以不能包含 $red/$none 这个符号.... " + echo + error + ;; + *) + echo + echo + echo -e "$yellow 分流的路径 = ${cyan}/${new_ws_path}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + done + pause + sed -i "43s/$ws_path/$new_ws_path/" $backup + ws_path=$new_ws_path + caddy_config + config + clear + view_v2ray_config_info + download_v2ray_config_ask + elif [[ $v2ray_transport == 4 && $caddy_installed ]]; then + ws_path_config_ask + if [[ $new_ws_path ]]; then + sed -i "41s/false/true/; 43s/$ws_path/$new_ws_path/; $ d" $backup + echo "$proxy_site" >>$backup + ws_path=$new_ws_path + is_ws_path=true + caddy_config + config + clear + view_v2ray_config_info + download_v2ray_config_ask + else + echo + echo + echo " 给大佬点赞....好果断的放弃配置 网站伪装 和 路径分流" + echo + echo + fi + else + echo + echo -e "$red 抱歉...不支持修改...$none" + echo + echo -e " 备注..修改 分流的路径 仅支持传输协议为 ${yellow}WebSocket + TLS$none 并且$yellow 自动配置 TLS = 打开$none" + echo + echo -e " 当前传输协议为: ${cyan}${transport[$v2ray_transport - 1]}${none}" + echo + if [[ $caddy_installed ]]; then + echo -e " 自动配置 TLS = ${cyan}打开$none" + else + echo -e " 自动配置 TLS = $red关闭$none" + fi + echo + change_v2ray_transport_ask + fi + +} +change_proxy_site_config() { + if [[ $v2ray_transport == 4 && $caddy_installed ]] && [[ $is_ws_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}$(sed '$!d' $backup)$none]):")" proxy_site + [[ -z $proxy_site ]] && error && continue + + case $proxy_site in + *) + echo + echo + echo -e "$yellow 伪装的网址 = ${cyan}${proxy_site}$none" + echo "----------------------------------------------------------------" + echo + break + ;; + esac + done + pause + sed -i "$ d" $backup + echo "$proxy_site" >>$backup + caddy_config + echo + echo + echo " 哎哟...好像是修改成功了..." + echo + echo -e " 赶紧打开你的域名 ${cyan}https://${domain}$none 检查一下看看" + echo + echo + elif [[ $v2ray_transport == 4 && $caddy_installed ]]; then + ws_path_config_ask + if [[ $new_ws_path ]]; then + sed -i "41s/false/true/; 43s/$ws_path/$new_ws_path/; $ d" $backup + echo "$proxy_site" >>$backup + ws_path=$new_ws_path + is_ws_path=true + caddy_config + config + clear + view_v2ray_config_info + download_v2ray_config_ask + else + echo + echo + echo " 给大佬点赞....好果断的放弃配置 网站伪装 和 路径分流" + echo + echo + fi + else + echo + echo -e "$red 抱歉...不支持修改...$none" + echo + echo -e " 备注..修改 伪装的网址 仅支持传输协议为 ${yellow}WebSocket + TLS$none 并且$yellow 自动配置 TLS = 打开$none" + echo + echo -e " 当前传输协议为: ${cyan}${transport[$v2ray_transport - 1]}${none}" + echo + if [[ $caddy_installed ]]; then + echo -e " 自动配置 TLS = ${cyan}打开$none" + else + echo -e " 自动配置 TLS = $red关闭$none" + fi + echo + change_v2ray_transport_ask + fi + +} domain_check() { - test_domain=$(dig $new_domain +short) + # test_domain=$(dig $new_domain +short) + test_domain=$(ping $domain -c 1 | grep -oP -m1 "([\d.]+){3}\d") if [[ $test_domain != $ip ]]; then echo echo -e "$red 检测域名解析错误....$none" @@ -1864,6 +2154,10 @@ create_v2ray_config_text() { echo echo "伪装类型 (header type) = ${header}" echo + if [[ $is_ws_path ]]; then + echo -e "$yellow WebSocket 路径 (WS path) = ${cyan}/${ws_path}$none" + echo + fi echo "TLS (Enable TLS) = 打开" echo echo -e " 请将 Obfs 设置为 $obfs ...并忽略 传输协议... (如果你使用 Pepi / ShadowRay) " @@ -1894,16 +2188,16 @@ create_v2ray_config_text() { echo -e "帅帅的提示...此 V2Ray 配置不支持 Pepi / ShadowRay" echo fi - if [[ $v2ray_transport -ge 9 && $is_blocked_ad ]]; then - echo "备注: 动态端口已启用...广告拦截已开启..." - echo - elif [[ $v2ray_transport -ge 9 ]]; then - echo "备注: 动态端口已启用..." - echo - elif [[ $is_blocked_ad ]]; then - echo "备注: 广告拦截已开启.." - echo - fi + fi + if [[ $v2ray_transport -ge 9 && $is_blocked_ad ]]; then + echo "备注: 动态端口已启用...广告拦截已开启..." + echo + elif [[ $v2ray_transport -ge 9 ]]; then + echo "备注: 动态端口已启用..." + echo + elif [[ $is_blocked_ad ]]; then + echo "备注: 广告拦截已开启.." + echo fi echo "---------- END -------------" echo @@ -2015,7 +2309,7 @@ get_v2ray_vmess_URL_link() { echo echo $vmess echo - rm -rf /etc/v2ray/vmess_qr.json + rm -rf /etc/v2ray/vmess_qr.json } other() { while :; do @@ -2993,6 +3287,11 @@ config() { if [[ $v2ray_transport_opt -eq 4 || $v2ray_transport -eq 4 ]]; then sed -i "s/233blog.com/$domain/; 22s/2333/443/; 25s/$old_id/$v2ray_id/" $v2ray_client_config + if [[ $is_ws_path ]]; then + sed -i "41s/233blog/$ws_path/" $v2ray_client_config + else + sed -i "41s/233blog//" $v2ray_client_config + fi else [[ -z $ip ]] && get_ip sed -i "s/233blog.com/$ip/; 22s/2333/$v2ray_port/; 25s/$old_id/$v2ray_id/" $v2ray_client_config @@ -3050,7 +3349,7 @@ _boom_() { echo echo -e "$yellow 配置信息链接: $cyan$link2$none" echo - echo -e "$yellow V2RayN 二维码链接: $cyan$link3$none" + echo -e "$yellow V2RayN / Kitsunebi 二维码链接: $cyan$link3$none" echo echo -e "$yellow Pepi / ShadowRay 二维码链接: $cyan$link$none" echo @@ -3219,28 +3518,28 @@ case $args in menu) menu ;; -info) +i | info) view_v2ray_config_info ;; -config) +c | config) change_v2ray_config ;; -link) +l | link) get_v2ray_config_link ;; -infolink) +L | infolink) get_v2ray_config_info_link ;; -qr) +q | qr) get_v2ray_config_qr_link ;; -ss) +s | ss) change_shadowsocks_config ;; -ssinfo) +S | ssinfo) view_shadowsocks_config_info ;; -ssqr) +Q | ssqr) get_shadowsocks_config_qr_link ;; status) @@ -3263,14 +3562,14 @@ log) url | URL) get_v2ray_vmess_URL_link ;; -update) +u | update) update_v2ray ;; -update.sh) +U | update.sh) update_v2ray.sh exit ;; -uninstall) +un | uninstall) uninstall_v2ray ;; 233 | 2333 | 233boy | 233blog | 233blog.com)