diff --git a/CHANGELOG.md b/CHANGELOG.md index 798725a..61681be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,22 @@ +## 2020-2-16 +1.1.0 +* 修复 证书更新后未正确应用的问题 +* 添加 旧配置文件保留 +* 添加 安装流程 TLS 版本选择 +* 变更 v2ray_qr_config_file位置 +* 修复 v2ray daemon判断逻辑错误 +* 添加 Nginx 冲突检测 + +## 2020-2-7 +1.0.7 +* 修复 自动更新证书 Nginx 重启异常 +* 修复 bbr4合1 403 forbidden 问题 +* 修复 部分临时文件清理异常 问题 +* 变更 默认仅保留 TLS1.3 +* 添加 卸载提供 Nginx 保留选项 +* 添加 Nginx配置文件 XFF 感谢 tg:@Cliwired +* 添加 ws DOH配置 感谢 tg:@auth_chain_b + ## 2020-01-25 * 修复 curl依赖确实 * 添加 MT-proxy-go 安装代码,在此感谢 whunt1 的贡献 diff --git a/README.md b/README.md index 7396844..4c3fca9 100644 --- a/README.md +++ b/README.md @@ -3,20 +3,30 @@ > 感谢 JetBrains 提供的非商业开源软件开发授权 > Thanks for non-commercial open source development authorization by JetBrains +### Telegram 群组 +* telegram 交流群:https://t.me/wulabing_v2ray +* telegram 更新公告频道:https://t.me/wulabing_channel + +### 准备工作 +* 准备一个域名,并将A记录添加好。 +* [V2ray官方说明](https://www.v2ray.com/),了解 TLS WebSocket 及 V2ray 相关信息 +* 安装好 wget + +### 安装/更新方式(h2 和 ws 版本已合并) +Vmess+websocket+TLS+Nginx+Website +``` +wget -N --no-check-certificate -q -O install.sh "https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/master/install.sh" && chmod +x install.sh && bash install.sh +``` + ### 注意事项 * 如果你不了解脚本中各项设置的具体含义,除域名外,请使用脚本提供的默认值 * 使用本脚本需要你拥有 Linux 基础及使用经验,了解计算机网络部分知识,计算机基础操作 * 目前支持Debian 9+ / Ubuntu 18.04+ / Centos7+ ,部分Centos模板可能存在难以处理的编译问题,建议遇到编译问题时,请更换至其他系统模板 -* telegram 交流群:https://t.me/wulabing_v2ray * 群主仅提供极其有限的支持,如有问题可以询问群友 * 每周日的凌晨3点,Nginx 会自动重启以配合证书的签发定时任务进行,在此期间,节点无法正常连接,预计持续时间为若干秒至两分钟 ### 更新日志 -> 更多内容请查看 CHANGELOG.md -## 2020-01-25 -* 修复 curl依赖确实 -* 添加 MT-proxy-go 安装代码,在此感谢 whunt1 的贡献 -* 修复 测试签发成功,正式签发失败,后续重装导致的跳过证书签发问题 +> 更新内容请查看 CHANGELOG.md ### 鸣谢 * ~~本脚本的另一个分支版本(Use Host)地址: https://github.com/dylanbai8/V2Ray_ws-tls_Website_onekey 请根据需求进行选择~~ 该作者可能已停止维护 @@ -27,7 +37,7 @@ ### 证书 > 如果你已经拥有了你所使用域名的证书文件,可以将 crt 和 key 文件命名为 v2ray.crt v2ray.key 放在 /data 目录下(若目录不存在请先建目录),请注意证书文件权限及证书有效期,自定义证书有效期过期后请自行续签 -脚本支持自动生成 let's encrypted 证书,有效期3个月,理论上自动生成的证书支持自动续签,自动续签功能有待检验 +脚本支持自动生成 let's encrypted 证书,有效期3个月,理论上自动生成的证书支持自动续签 ### 查看客户端配置 `cat ~/v2ray_info.txt` @@ -35,23 +45,14 @@ ### V2ray 简介 * V2Ray是一个优秀的开源网络代理工具,可以帮助你畅爽体验互联网,目前已经全平台支持Windows、Mac、Android、IOS、Linux等操作系统的使用。 -* ~~本脚本的另一个分支版本(Use Host)地址: https://github.com/dylanbai8/V2Ray_ws-tls_Website_onekey 请根据需求进行选择~~ 该作者可能已停止维护 * 本脚本为一键完全配置脚本,在所有流程正常运行完毕后,直接按照输出结果设置客户端即可使用 * 请注意:我们依然强烈建议你全方面的了解整个程序的工作流程及原理 - ### 建议单服务器仅搭建单个代理 * 本脚本默认安装最新版本的V2ray core -* V2ray core 目前最新版本为 4.21.3(同时请注意客户端 core 的同步更新,需要保证客户端内核版本 >= 服务端内核版本) +* V2ray core 目前最新版本为 4.22.1(同时请注意客户端 core 的同步更新,需要保证客户端内核版本 >= 服务端内核版本) * 建议使用默认的443端口作为连接端口 * 伪装内容可自行替换。 -### V2ray core 更新方式 -执行: -`bash <(curl -L -s https://install.direct/go.sh)` - -( 来源参考 :[V2ray官方说明](https://www.v2ray.com/chapter_00/install.html)) -* 如果为最新版本,会输出提示并停止安装。否则会自动更新 -* 未来会将相关内容集成到本脚本中并进行交互式操作更新 ### 注意事项 * 推荐在纯净环境下使用本脚本,如果你是新手,请不要使用Centos系统。 @@ -60,15 +61,8 @@ * V2Ray 的部分功能依赖于系统时间,请确保您使用V2RAY程序的系统 UTC 时间误差在三分钟之内,时区无关。 * 本 bash 依赖于 [V2ray 官方安装脚本](https://install.direct/go.sh) 及 [acme.sh](https://github.com/Neilpang/acme.sh) 工作。 * Centos 系统用户请预先在防火墙中放行程序相关端口(默认:80,443) -### 准备工作 -* 准备一个域名,并将A记录添加好。 -* [V2ray官方说明](https://www.v2ray.com/),了解 TLS WebSocket 及 V2ray 相关信息 -* 安装好 curl -### 安装/更新方式(h2 和 ws 版本已合并) -Vmess+websocket+TLS+Nginx+Website -``` -wget -N --no-check-certificate -q -O install.sh "https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/master/install.sh" && chmod +x install.sh && bash install.sh -``` + + ### 启动方式 启动 V2ray:`systemctl start v2ray` @@ -89,7 +83,16 @@ V2ray 客户端配置: `~/v2ray_info.txt` Nginx 目录: `/etc/nginx` -证书文件: `/data/v2ray.key 和 /data/v2ray.crt` - +证书文件: `/data/v2ray.key 和 /data/v2ray.crt` 请注意证书权限设置 + +### 捐赠 + +目前支持通过 MugglePay 接受虚拟货币捐赠 + +𝒘𝒖𝒍𝒂𝒃𝒊𝒏𝒈 邀请您使用麻瓜宝,基于Telegram的电子钱包,匿名支付0手续费秒级到账。https://telegram.me/MugglePayBot?start=T3Y78AZ3 + +您可以通过Telegram向我匿名捐赠:发送 /pay @wulabing xxx 到 @MugglePayBot 即可 默认货币为 USDT + +如需要通过支付宝/微信捐赠,请Telegram私聊 @wulabing 感谢您的支持 diff --git a/install.sh b/install.sh index 168e7c4..e0d1082 100644 --- a/install.sh +++ b/install.sh @@ -1,4 +1,6 @@ #!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH cd $(cd "$(dirname "$0")"; pwd) #==================================================== @@ -24,8 +26,9 @@ OK="${Green}[OK]${Font}" Error="${Red}[错误]${Font}" # 版本 -shell_version="1.0.6" +shell_version="1.1.0" shell_mode="None" +github_branch="master" version_cmp="/tmp/version_cmp.tmp" v2ray_conf_dir="/etc/v2ray" nginx_conf_dir="/etc/nginx/conf/conf.d" @@ -36,17 +39,24 @@ web_dir="/home/wwwroot" nginx_openssl_src="/usr/local/src" v2ray_bin_file="/usr/bin/v2ray" v2ray_info_file="$HOME/v2ray_info.inf" -v2ray_qr_config_file="/etc/v2ray/vmess_qr.json" +v2ray_qr_config_file="/usr/local/vmess_qr.json" nginx_systemd_file="/etc/systemd/system/nginx.service" v2ray_systemd_file="/etc/systemd/system/v2ray.service" v2ray_access_log="/var/log/v2ray/access.log" v2ray_error_log="/var/log/v2ray/error.log" amce_sh_file="/root/.acme.sh/acme.sh" +ssl_update_file="/usr/bin/ssl_update.sh" nginx_version="1.16.1" openssl_version="1.1.1d" +jemalloc_version="5.2.1" +old_config_status="off" +v2ray_plugin_version="$(wget -qO- "https://github.com/shadowsocks/v2ray-plugin/tags" |grep -E "/shadowsocks/v2ray-plugin/releases/tag/" |head -1|sed -r 's/.*tag\/v(.+)\">.*/\1/')" + +#移动旧版本配置信息 对小于 1.1.0 版本适配 +[[ -f "/etc/v2ray/vmess_qr.json" ]] && mv /etc/v2ray/vmess_qr.json $v2ray_qr_config_file #生成伪装路径 -camouflage=`cat /dev/urandom | head -n 10 | md5sum | head -c 8` +camouflage="/`cat /dev/urandom | head -n 10 | md5sum | head -c 8`/" source /etc/os-release @@ -72,10 +82,13 @@ check_system(){ fi $INS install dbus - systemctl stop firewalld && systemctl disable firewalld + + systemctl stop firewalld + systemctl disable firewalld echo -e "${OK} ${GreenBG} firewalld 已关闭 ${Font}" - systemctl stop ufw && systemctl disable ufw + systemctl stop ufw + systemctl disable ufw echo -e "${OK} ${GreenBG} ufw 已关闭 ${Font}" } @@ -186,7 +199,7 @@ dependency_install(){ ${INS} -y install haveged # judge "haveged 安装" - sed -i -r '/^HRNGDEVICE/d;/#HRNGDEVICE=\/dev\/null/a HRNGDEVICE=/dev/urandom' /etc/default/rng-tools +# sed -i -r '/^HRNGDEVICE/d;/#HRNGDEVICE=\/dev\/null/a HRNGDEVICE=/dev/urandom' /etc/default/rng-tools if [[ "${ID}" == "centos" ]];then # systemctl start rngd && systemctl enable rngd @@ -215,22 +228,37 @@ basic_optimization(){ } port_alterid_set(){ - read -p "请输入连接端口(default:443):" port - [[ -z ${port} ]] && port="443" - read -p "请输入alterID(default:2 仅允许填数字):" alterID - [[ -z ${alterID} ]] && alterID="2" + if [[ "on" != "$old_config_status" ]] + then + read -p "请输入连接端口(default:443):" port + [[ -z ${port} ]] && port="443" + read -p "请输入alterID(default:2 仅允许填数字):" alterID + [[ -z ${alterID} ]] && alterID="2" + fi } modify_path(){ - sed -i "/\"path\"/c \\\t \"path\":\"\/${camouflage}\/\"" ${v2ray_conf} + if [[ "on" == "$old_config_status" ]] + then + camouflage="$(cat $v2ray_qr_config_file | grep '\"path\"' | awk -F '"' '{print $4}')" + fi + sed -i "/\"path\"/c \\\t \"path\":\"${camouflage}\"" ${v2ray_conf} judge "V2ray 伪装路径 修改" } modify_alterid(){ + if [[ "on" == "$old_config_status" ]] + then + alterID="$(cat $v2ray_qr_config_file | grep '\"aid\"' | awk -F '"' '{print $4}')" + fi sed -i "/\"alterId\"/c \\\t \"alterId\":${alterID}" ${v2ray_conf} judge "V2ray alterid 修改" [ -f ${v2ray_qr_config_file} ] && sed -i "/\"aid\"/c \\ \"aid\": \"${alterID}\"," ${v2ray_qr_config_file} echo -e "${GreenBG} alterID:${alterID} ${Font}" } modify_inbound_port(){ + if [[ "on" == "$old_config_status" ]] + then + port="$(info_extraction '\"port\"')" + fi if [[ "$shell_mode" != "h2" ]] then let PORT=$RANDOM+10000 @@ -242,12 +270,20 @@ modify_inbound_port(){ } modify_UUID(){ [ -z $UUID ] && UUID=$(cat /proc/sys/kernel/random/uuid) + if [[ "on" == "$old_config_status" ]] + then + UUID="$(info_extraction '\"id\"')" + fi sed -i "/\"id\"/c \\\t \"id\":\"${UUID}\"," ${v2ray_conf} judge "V2ray UUID 修改" [ -f ${v2ray_qr_config_file} ] && sed -i "/\"id\"/c \\ \"id\": \"${UUID}\"," ${v2ray_qr_config_file} echo -e "${GreenBG} UUID:${UUID} ${Font}" } modify_nginx_port(){ + if [[ "on" == "$old_config_status" ]] + then + port="$(info_extraction '\"port\"')" + fi sed -i "/ssl http2;$/c \\\tlisten ${port} ssl http2;" ${nginx_conf} judge "V2ray port 修改" [ -f ${v2ray_qr_config_file} ] && sed -i "/\"port\"/c \\ \"port\": \"${port}\"," ${v2ray_qr_config_file} @@ -255,7 +291,7 @@ modify_nginx_port(){ } modify_nginx_other(){ sed -i "/server_name/c \\\tserver_name ${domain};" ${nginx_conf} - sed -i "/location/c \\\tlocation \/${camouflage}\/" ${nginx_conf} + sed -i "/location/c \\\tlocation ${camouflage}" ${nginx_conf} sed -i "/proxy_pass/c \\\tproxy_pass http://127.0.0.1:${PORT};" ${nginx_conf} sed -i "/return/c \\\treturn 301 https://${domain}\$request_uri;" ${nginx_conf} #sed -i "27i \\\tproxy_intercept_errors on;" ${nginx_dir}/conf/nginx.conf @@ -279,6 +315,8 @@ v2ray_install(){ ## wget http://install.direct/go.sh if [[ -f go.sh ]];then + rm -rf $v2ray_systemd_file + systemctl daemon-reload bash go.sh --force judge "安装 V2ray" else @@ -292,6 +330,10 @@ nginx_exist_check(){ if [[ -f "/etc/nginx/sbin/nginx" ]];then echo -e "${OK} ${GreenBG} Nginx已存在,跳过编译安装过程 ${Font}" sleep 2 + elif [[ -d "/usr/local/nginx/" ]] + then + echo -e "${OK} ${GreenBG} 检测到其他套件安装的Nginx,继续安装会造成冲突,请处理后安装${Font}" + exit 1 else nginx_install fi @@ -301,10 +343,12 @@ nginx_install(){ # rm -rf /etc/nginx # fi - wget -nc http://nginx.org/download/nginx-${nginx_version}.tar.gz -P ${nginx_openssl_src} + wget -nc --no-check-certificate http://nginx.org/download/nginx-${nginx_version}.tar.gz -P ${nginx_openssl_src} judge "Nginx 下载" - wget -nc https://www.openssl.org/source/openssl-${openssl_version}.tar.gz -P ${nginx_openssl_src} + wget -nc --no-check-certificate https://www.openssl.org/source/openssl-${openssl_version}.tar.gz -P ${nginx_openssl_src} judge "openssl 下载" + wget -nc --no-check-certificate https://github.com/jemalloc/jemalloc/releases/download/${jemalloc_version}/jemalloc-${jemalloc_version}.tar.bz2 -P ${nginx_openssl_src} + judge "jemalloc 下载" cd ${nginx_openssl_src} @@ -314,15 +358,28 @@ nginx_install(){ [[ -d openssl-"$openssl_version" ]] && rm -rf openssl-"$openssl_version" tar -zxvf openssl-"$openssl_version".tar.gz + [[ -d jemalloc-"${jemalloc_version}" ]] && rm -rf jemalloc-"${jemalloc_version}" + tar -xvf jemalloc-"${jemalloc_version}".tar.bz2 + [[ -d "$nginx_dir" ]] && rm -rf ${nginx_dir} + + echo -e "${OK} ${GreenBG} 即将开始编译安装 jemalloc ${Font}" + sleep 2 + + cd jemalloc-${jemalloc_version} + ./configure + judge "编译检查" + make && make install + judge "jemalloc 编译安装" + echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf + ldconfig + echo -e "${OK} ${GreenBG} 即将开始编译安装 Nginx, 过程稍久,请耐心等待 ${Font}" sleep 4 - # 关闭debug模式,减小编译后的文件大小 - sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc + cd ../nginx-${nginx_version} - cd nginx-${nginx_version} ./configure --prefix="${nginx_dir}" \ --with-http_ssl_module \ --with-http_gzip_static_module \ @@ -334,6 +391,8 @@ nginx_install(){ --with-http_secure_link_module \ --with-http_v2_module \ --with-cc-opt='-O3' \ + --with-ld-opt="-ljemalloc" \ + --with-openssl=../openssl-"$openssl_version" judge "编译检查" make && make install @@ -348,8 +407,8 @@ nginx_install(){ # 删除临时文件 - rm -rf nginx-"${nginx_version}" - rm -rf openssl-"${openssl_version}" + rm -rf ../nginx-"${nginx_version}" + rm -rf ../openssl-"${openssl_version}" rm -rf ../nginx-"${nginx_version}".tar.gz rm -rf ../openssl-"${openssl_version}".tar.gz @@ -409,35 +468,35 @@ port_exist_check(){ fi } acme(){ - ~/.acme.sh/acme.sh --issue -d ${domain} --standalone -k ec-256 --force --test + $HOME/.acme.sh/acme.sh --issue -d ${domain} --standalone -k ec-256 --force --test if [[ $? -eq 0 ]];then echo -e "${OK} ${GreenBG} SSL 证书测试签发成功,开始正式签发 ${Font}" sleep 2 else echo -e "${Error} ${RedBG} SSL 证书测试签发失败 ${Font}" - rm -rf "~/.acme.sh/${domain}_ecc/${domain}.key" && rm -rf "~/.acme.sh/${domain}_ecc/${domain}.cer" + rm -rf "$HOME/.acme.sh/${domain}_ecc/${domain}.key" && rm -rf "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" exit 1 fi - ~/.acme.sh/acme.sh --issue -d ${domain} --standalone -k ec-256 --force + $HOME/.acme.sh/acme.sh --issue -d ${domain} --standalone -k ec-256 --force if [[ $? -eq 0 ]];then echo -e "${OK} ${GreenBG} SSL 证书生成成功 ${Font}" sleep 2 mkdir /data - ~/.acme.sh/acme.sh --installcert -d ${domain} --fullchainpath /data/v2ray.crt --keypath /data/v2ray.key --ecc + $HOME/.acme.sh/acme.sh --installcert -d ${domain} --fullchainpath /data/v2ray.crt --keypath /data/v2ray.key --ecc if [[ $? -eq 0 ]];then echo -e "${OK} ${GreenBG} 证书配置成功 ${Font}" sleep 2 fi else echo -e "${Error} ${RedBG} SSL 证书生成失败 ${Font}" - rm -rf "~/.acme.sh/${domain}_ecc/${domain}.key" && rm -rf "~/.acme.sh/${domain}_ecc/${domain}.cer" + rm -rf "$HOME/.acme.sh/${domain}_ecc/${domain}.key" && rm -rf "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" exit 1 fi } v2ray_conf_add_tls(){ cd /etc/v2ray - wget https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/master/tls/config.json -O config.json + wget --no-check-certificate https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/${github_branch}/tls/config.json -O config.json modify_path modify_alterid modify_inbound_port @@ -445,12 +504,30 @@ v2ray_conf_add_tls(){ } v2ray_conf_add_h2(){ cd /etc/v2ray - wget https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/master/http2/config.json -O config.json + wget --no-check-certificate https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/${github_branch}/http2/config.json -O config.json modify_path modify_alterid modify_inbound_port modify_UUID } +old_config_exist_check(){ + if [[ -f $v2ray_qr_config_file ]] + then + echo -e "${OK} ${Green} 检测到旧配置文件,是否读取旧文件配置 [Y/N]? ${Font}" + read -r ssl_delete + case $ssl_delete in + [yY][eE][sS]|[yY]) + echo -e "${OK} ${Green} 已保留旧配置 ${Font}" + old_config_status="on" + port=$(info_extraction '\"port\"') + ;; + *) + rm -rf $v2ray_qr_config_file + echo -e "${OK} ${Green} 已删除旧配置 ${Font}" + ;; + esac + fi +} nginx_conf_add(){ touch ${nginx_conf_dir}/v2ray.conf cat>${nginx_conf_dir}/v2ray.conf< /dev/null" /var/spool/cron/root +# sed -i "/acme.sh/c 0 3 * * 0 \"/root/.acme.sh\"/acme.sh --cron --home \"/root/.acme.sh\" \ +# &> /dev/null" /var/spool/cron/root + sed -i "/acme.sh/c 0 3 * * 0 bash ${ssl_update_file}" /var/spool/cron/root else - sed -i "/acme.sh/c 0 3 * * 0 \"/root/.acme.sh\"/acme.sh --cron --home \"/root/.acme.sh\" \ - &> /dev/null" /var/spool/cron/crontabs/root +# sed -i "/acme.sh/c 0 3 * * 0 \"/root/.acme.sh\"/acme.sh --cron --home \"/root/.acme.sh\" \ +# &> /dev/null" /var/spool/cron/crontabs/root + sed -i "/acme.sh/c 0 3 * * 0 bash ${ssl_update_file}" /var/spool/cron/crontabs/root fi judge "cron 计划任务更新" } @@ -555,7 +637,7 @@ vmess_qr_config_tls_ws(){ "net": "ws", "type": "none", "host": "${domain}", - "path": "/${camouflage}/", + "path": "${camouflage}", "tls": "tls" } EOF @@ -572,7 +654,7 @@ vmess_qr_config_h2(){ "aid": "${alterID}", "net": "h2", "type": "none", - "path": "/${camouflage}/", + "path": "${camouflage}", "tls": "tls" } EOF @@ -580,9 +662,9 @@ EOF vmess_qr_link_image(){ vmess_link="vmess://$(cat $v2ray_qr_config_file | base64 -w 0)" - echo -e "${Red} URL导入链接:${vmess_link} ${Font}" >> ${v2ray_info_file} echo -e "${Red} 二维码: ${Font}" >> ${v2ray_info_file} echo -n "${vmess_link}"| qrencode -o - -t utf8 >> ${v2ray_info_file} + echo -e "${Red} URL导入链接:${vmess_link} ${Font}" >> ${v2ray_info_file} } info_extraction(){ @@ -605,11 +687,25 @@ show_information(){ cat ${v2ray_info_file} } ssl_judge_and_install(){ -# if [[ -f "/data/v2ray.key" && -f "/data/v2ray.crt" ]];then -# echo "证书文件已存在" - if [[ -f "~/.acme.sh/${domain}_ecc/${domain}.key" && -f "~/.acme.sh/${domain}_ecc/${domain}.cer" ]];then + if [[ -f "/data/v2ray.key" || -f "/data/v2ray.crt" ]];then + echo "/data 目录下证书文件已存在" + echo -e "${OK} ${GreenBG} 是否删除 [Y/N]? ${Font}" + read -r ssl_delete + case $ssl_delete in + [yY][eE][sS]|[yY]) + rm -rf /data/* + echo -e "${OK} ${GreenBG} 已删除 ${Font}" + ;; + *) + ;; + esac + fi + + if [[ -f "/data/v2ray.key" || -f "/data/v2ray.crt" ]];then echo "证书文件已存在" - ~/.acme.sh/acme.sh --installcert -d ${domain} --fullchainpath /data/v2ray.crt --keypath /data/v2ray.key --ecc + elif [[ -f "$HOME/.acme.sh/${domain}_ecc/${domain}.key" && -f "$HOME/.acme.sh/${domain}_ecc/${domain}.cer" ]];then + echo "证书文件已存在" + $HOME/.acme.sh/acme.sh --installcert -d ${domain} --fullchainpath /data/v2ray.crt --keypath /data/v2ray.key --ecc judge "证书应用" else ssl_install @@ -637,16 +733,18 @@ WantedBy=multi-user.target EOF judge "Nginx systemd ServerFile 添加" +systemctl daemon-reload } tls_type(){ if [[ -f "/etc/nginx/sbin/nginx" ]] && [[ -f "$nginx_conf" ]] && [[ "$shell_mode" == "ws" ]];then - echo "请选择支持的 TLS 版本(default:1):" - echo "1: TLS1.1 TLS1.2 and TLS1.3" - echo "2: TLS1.2 and TLS1.3" + echo "请选择支持的 TLS 版本(default:3):" + echo "请注意,如果你使用 Quantaumlt X / 路由器 / 旧版 Shadowrocket / 低于 4.18.1 版本的 V2ray core 请选择 兼容模式" + echo "1: TLS1.1 TLS1.2 and TLS1.3(兼容模式)" + echo "2: TLS1.2 and TLS1.3 (兼容模式)" echo "3: TLS1.3 only" read -p "请输入:" tls_version - [[ -z ${tls_version} ]] && tls_version=2 + [[ -z ${tls_version} ]] && tls_version=3 if [[ $tls_version == 3 ]];then sed -i 's/ssl_protocols.*/ssl_protocols TLSv1.3;/' $nginx_conf echo -e "${OK} ${GreenBG} 已切换至 TLS1.3 only ${Font}" @@ -671,12 +769,16 @@ show_error_log(){ } ssl_update_manuel(){ [ -f ${amce_sh_file} ] && "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" || echo -e "${RedBG}证书签发工具不存在,请确认你是否使用了自己的证书${Font}" + domain="$(info_extraction '\"add\"')" + $HOME/.acme.sh/acme.sh --installcert -d ${domain} --fullchainpath /data/v2ray.crt --keypath /data/v2ray.key --ecc } bbr_boost_sh(){ + [ -f "tcp.sh" ] && rm -rf ./tcp.sh wget -N --no-check-certificate "https://github.com/ylx2016/Linux-NetSpeed/releases/download/sh/tcp.sh" && chmod +x tcp.sh && ./tcp.sh } mtproxy_sh(){ - wget -N --no-check-certificate https://github.com/whunt1/onekeymakemtg/raw/master/mtproxy_go.sh && chmod +x mtproxy_go.sh && bash mtproxy_go.sh + [ -f "mtproxy_go.sh" ] && rm -rf ./mtproxy_go.sh + wget -N --no-check-certificate https://github.com/whunt1/onekeymakemtg/raw/master/mtproxy_go.sh && chmod +x mtproxy_go.sh && ./mtproxy_go.sh } uninstall_all(){ @@ -684,7 +786,19 @@ uninstall_all(){ [[ -f $nginx_systemd_file ]] && rm -f $nginx_systemd_file [[ -f $v2ray_systemd_file ]] && rm -f $v2ray_systemd_file [[ -d $v2ray_bin_file ]] && rm -rf $v2ray_bin_file - [[ -d $nginx_dir ]] && rm -rf $nginx_dir + if [[ -d $nginx_dir ]] + then + echo -e "${OK} ${Green} 是否卸载 Nginx [Y/N]? ${Font}" + read -r uninstall_nginx + case $uninstall_nginx in + [yY][eE][sS]|[yY]) + rm -rf $nginx_dir + echo -e "${OK} ${Green} 已卸载 Nginx ${Font}" + ;; + *) + ;; + esac + fi [[ -d $v2ray_conf_dir ]] && rm -rf $v2ray_conf_dir [[ -d $web_dir ]] && rm -rf $web_dir systemctl daemon-reload @@ -709,6 +823,7 @@ install_v2ray_ws_tls(){ dependency_install basic_optimization domain_check + old_config_exist_check port_alterid_set v2ray_install port_exist_check 80 @@ -722,6 +837,7 @@ install_v2ray_ws_tls(){ vmess_qr_config_tls_ws basic_information vmess_qr_link_image + tls_type show_information start_process_systemd enable_process_systemd @@ -734,6 +850,7 @@ install_v2_h2(){ dependency_install basic_optimization domain_check + old_config_exist_check port_alterid_set v2ray_install port_exist_check 80 @@ -749,7 +866,7 @@ install_v2_h2(){ } update_sh(){ - ol_version=$(curl -L -s https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/master/install.sh | grep "shell_version=" | head -1 |awk -F '=|"' '{print $3}') + ol_version=$(curl -L -s https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/${github_branch}/install.sh | grep "shell_version=" | head -1 |awk -F '=|"' '{print $3}') echo "$ol_version" > $version_cmp echo "$shell_version" >> $version_cmp if [[ "$shell_version" < "$(sort -rV $version_cmp | head -1)" ]] @@ -758,11 +875,11 @@ update_sh(){ read -r update_confirm case $update_confirm in [yY][eE][sS]|[yY]) - wget -N --no-check-certificate https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/master/install.sh + wget -N --no-check-certificate https://raw.githubusercontent.com/wulabing/V2Ray_ws-tls_bash_onekey/${github_branch}/install.sh echo -e "${OK} ${Green} 更新完成 ${Font}" + exit 0 ;; *) - exit 0 ;; esac else @@ -796,6 +913,7 @@ list(){ } menu(){ + update_sh echo -e "\t V2ray 安装管理脚本 ${Red}[${shell_version}]${Font}" echo -e "\t---authored by wulabing---" echo -e "\thttps://github.com/wulabing\n" @@ -823,7 +941,6 @@ menu(){ echo -e "${Green}15.${Font} 更新 证书crontab计划任务" echo -e "${Green}16.${Font} 退出 \n" - update_sh read -p "请输入数字:" menu_num case $menu_num in 0) diff --git a/ssl_update.sh b/ssl_update.sh new file mode 100644 index 0000000..607baec --- /dev/null +++ b/ssl_update.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +v2ray_qr_config_file="/usr/local/vmess_qr.json" +domain=$(grep '\"add\"' $v2ray_qr_config_file | awk -F '"' '{print $4}') + +systemctl stop nginx &> /dev/null +sleep 1 +"/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" &> /dev/null +"/root/.acme.sh"/acme.sh --installcert -d ${domain} --fullchainpath /data/v2ray.crt --keypath /data/v2ray.key --ecc +sleep 1 +systemctl start nginx &> /dev/null diff --git a/tls/config.json b/tls/config.json index 2242c68..febee14 100644 --- a/tls/config.json +++ b/tls/config.json @@ -41,23 +41,23 @@ "dns": { "servers": [ "https+local://1.1.1.1/dns-query", - "1.1.1.1", - "1.0.0.1", - "8.8.8.8", - "8.8.4.4", - "localhost" + "1.1.1.1", + "1.0.0.1", + "8.8.8.8", + "8.8.4.4", + "localhost" ] }, "routing": { - "domainStrategy": "AsIs", + "domainStrategy": "AsIs", "rules": [ { - "type": "field", + "type": "field", "inboundTag": [ "vmess-in" - ], + ], "outboundTag": "direct" } ] } -} +} \ No newline at end of file