diff --git a/install.sh b/install.sh old mode 100644 new mode 100755 index fa5ae20..4bb5aa2 --- a/install.sh +++ b/install.sh @@ -6,6 +6,11 @@ yellow='\e[93m' magenta='\e[95m' cyan='\e[96m' none='\e[0m' +_red() { echo -e ${red}$*${none}; } +_green() { echo -e ${green}$*${none}; } +_yellow() { echo -e ${yellow}$*${none}; } +_magenta() { echo -e ${magenta}$*${none}; } +_cyan() { echo -e ${cyan}$*${none}; } # Root [[ $(id -u) != 0 ]] && echo -e "\n 哎呀……请使用 ${red}root ${none}用户运行 ${yellow}~(^_^) ${none}\n" && exit 1 @@ -108,6 +113,33 @@ _load() { . "${_dir}$@" } + +_sys_timezone() { + IS_OPENVZ= + if hostnamectl status | grep -q openvz; then + IS_OPENVZ=1 + fi + + echo + timedatectl set-timezone Asia/Shanghai + timedatectl set-ntp true + echo "已将你的主机设置为Asia/Shanghai时区并通过systemd-timesyncd自动同步时间。" + echo + + if [[ $IS_OPENVZ ]]; then + echo + echo -e "你的主机环境为 ${yellow}Openvz${none} ,建议使用${yellow}v2ray mkcp${none}系列协议。" + echo -e "注意:${yellow}Openvz${none} 系统时间无法由虚拟机内程序控制同步。" + echo -e "如果主机时间跟实际相差${yellow}超过90秒${none},v2ray将无法正常通信,请发ticket联系vps主机商调整。" + fi +} + +_sys_time() { + echo -e "\n主机时间:${yellow}" + timedatectl status | sed -n '1p;4p' + echo -e "${none}" +} + v2ray_config() { # clear echo @@ -738,9 +770,7 @@ install_v2ray() { # $cmd install -y lrzsz git zip unzip curl wget qrencode libcap iptables-services $cmd install -y socat lrzsz git zip unzip curl wget qrencode libcap patch diffutils fi - ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime [ -d /etc/v2ray ] && rm -rf /etc/v2ray - date -s "$(curl -sI g.cn | grep Date | cut -d' ' -f3-6)Z" if [[ $local_install ]]; then if [[ ! -d $(pwd)/config ]]; then @@ -752,7 +782,7 @@ install_v2ray() { exit 1 fi mkdir -p /etc/v2ray/233boy/v2ray - cp -rf $(pwd)/* /etc/v2ray/233boy/v2ray + cp -rf $(pwd) /etc/v2ray/233boy/v2ray/ else pushd /tmp git clone --depth=1 https://github.com/233boy/v2ray -b "$_gitbranch" /etc/v2ray/233boy/v2ray @@ -923,6 +953,11 @@ _install() { exit 1 fi _disableselinux + _sys_timezone + _sys_time + echo + echo + pause v2ray_config blocked_hosts shadowsocks_config diff --git a/src/client_file.sh b/src/client_file.sh new file mode 100644 index 0000000..ea2c5cb --- /dev/null +++ b/src/client_file.sh @@ -0,0 +1,12 @@ +_get_client_file() { + local _link="$(cat $v2ray_client_config | tr -d [:space:] | base64 -w0)" + local link="https://233boy.github.io/tools/json.html#${_link}" + echo + echo "---------- V2Ray 客户端配置文件链接 -------------" + echo + echo -e ${cyan}$link${none} + echo + echo " V2Ray 客户端使用教程: https://v2ray6.com/post/4/" + echo + echo +} diff --git a/src/jqcmd.sh b/src/jqcmd.sh index cd20c8a..d1d1f80 100644 --- a/src/jqcmd.sh +++ b/src/jqcmd.sh @@ -92,7 +92,7 @@ jq_printvmess() { local _HOST=\"\" local _PATH=\"\" local _TLS=\"\" - local _NET=$(echo $IN | jq '.streamSettings.network') + local _NET=$(echo $IN | jq '.streamSettings.network|"tcp"') local _PORT=$(echo $IN | jq '.port') local _NETTRIM=${_NET//\"/} echo @@ -112,14 +112,19 @@ jq_printvmess() { _TLS="tls" ;; tcp) - _TYPE='if .streamSettings.tcpSettings.header.type then .streamSettings.tcpSettings.header.type else "none" end' + _TYPE='.streamSettings.tcpSettings.header.type|"none"' + ;; + quic) + _TYPE='.streamSettings.quicSettings.header.type|"none"' + _HOST='.streamSettings.quicSettings.security' + _PATH='.streamSettings.quicSettings.key' ;; esac local CLTLEN=$(echo $IN | jq '.settings.clients|length - 1') for CLINTIDX in $( seq 0 $CLTLEN ); do local EMAIL=$(echo $IN | jq 'if .settings.clients['${CLINTIDX}'].email then .settings.clients['${CLINTIDX}'].email else "DEFAULT" end') local _ps="${_MAKPREFIX}${ADDRESS}/${_NETTRIM}" - local _VMESS=$(echo "vmess://"$(echo $IN | jq -c '{"v":"2","ps":"'${_ps}'","add":"'${ADDRESS}'","port":.port,"id":.settings.clients['${CLINTIDX}'].id,"aid":.settings.clients['${CLINTIDX}'].alterId,"net":.streamSettings.network,"type":'${_TYPE}',"host":'${_HOST}',"path":'${_PATH}',"tls":'${_TLS}'}' | base64 -w0)) + local _VMESS=$(echo "vmess://"$(echo $IN | jq -c '{"v":"2","ps":"'${_ps}'","add":"'${ADDRESS}'","port":.port,"id":.settings.clients['${CLINTIDX}'].id,"aid":.settings.clients['${CLINTIDX}'].alterId,"net":.streamSettings.network|"tcp","type":'${_TYPE}',"host":'${_HOST}',"path":'${_PATH}',"tls":'${_TLS}'}' | base64 -w0)) _green "VMESS链接(v2rayN/v2rayNG): ${EMAIL//\"/}" echo ${_VMESS} _green "二维码链接【浏览器打开】(v2rayN/v2rayNG)" diff --git a/src/qr.sh b/src/qr.sh index b1443ed..24383a7 100644 --- a/src/qr.sh +++ b/src/qr.sh @@ -15,3 +15,15 @@ _qr_create() { echo rm -rf /etc/v2ray/vmess_qr.json } +_ss_qr() { + local ss_link="ss://$(echo -n "${ssciphers}:${sspass}@${ip}:${ssport}" | base64 -w 0)#v2ray6.com_ss_${ip}" + local link="https://233boy.github.io/tools/qr.html#${ss_link}" + echo + echo "---------- Shadowsocks 二维码链接 -------------" + echo + echo -e "$yellow 链接 = $cyan$link$none" + echo + echo -e " 温馨提示...$red Shadowsocks Win 4.0.6 $none客户端可能无法识别该二维码" + echo + echo +} diff --git a/src/sys-info.sh b/src/sys-info.sh new file mode 100644 index 0000000..17cbf0c --- /dev/null +++ b/src/sys-info.sh @@ -0,0 +1,26 @@ +#!/bin/bash +_sys_timezone() { + IS_OPENVZ= + if hostnamectl status | grep -q openvz; then + IS_OPENVZ=1 + fi + + echo + timedatectl set-timezone Asia/Shanghai + timedatectl set-ntp true + echo "已将你的主机设置为Asia/Shanghai时区并通过systemd-timesyncd自动同步时间。" + echo + + if [[ $IS_OPENVZ ]]; then + echo + echo -e "你的主机环境为 ${yellow}Openvz${none} ,建议使用${yellow}v2ray mkcp${none}系列协议。" + echo -e "注意:${yellow}Openvz${none} 系统时间无法由虚拟机内程序控制同步。" + echo -e "如果主机时间跟实际相差${yellow}超过90秒${none},v2ray将无法正常通信,请发ticket联系vps主机商调整。" + fi +} + +_sys_time() { + echo -e "主机时间:${yellow}" + timedatectl status | sed -n '1p;4p' + echo -e "${none}" +} diff --git a/v2ray.sh b/v2ray.sh old mode 100644 new mode 100755 index 62a09b2..492a6f2 --- 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="v3.08" +_version="v3.09" cmd="apt-get" @@ -77,12 +77,18 @@ _site="ddog.xyz" 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 + [[ -f /usr/local/bin/v2ray ]] && rm -f /usr/local/bin/v2ray + ln -s /etc/v2ray/233boy/v2ray/v2ray.sh $_v2ray_sh echo -e "\n $yellow 警告: 请重新登录 SSH 以避免出现 v2ray 命令未找到的情况。$none \n" && exit 1 fi +if [[ ! -L $_v2ray_sh ]]; then + rm -f $_v2ray_sh + ln -s /etc/v2ray/233boy/v2ray/v2ray.sh $_v2ray_sh +fi + if [ $v2ray_pid ]; then v2ray_status="$green正在运行$none" else @@ -226,35 +232,9 @@ view_shadowsocks_config_info() { } get_shadowsocks_config_qr_link() { if [[ $shadowsocks ]]; then - echo - echo -e "$green 正在生成链接.... 稍等片刻即可....$none" - echo get_ip - local ss="ss://$(echo -n "${ssciphers}:${sspass}@${ip}:${ssport}" | base64 -w 0)#${_site}_ss_${ip}" - echo "${ss}" >/tmp/233blog_shadowsocks.txt - cat /tmp/233blog_shadowsocks.txt | qrencode -s 50 -o /tmp/233blog_shadowsocks.png - - local random=$(echo $RANDOM-$RANDOM-$RANDOM | base64 -w 0) - local link=$(curl -s --upload-file /tmp/233blog_shadowsocks.png "https://transfer.sh/${random}_v2ray6_shadowsocks.png") - if [[ $link ]]; then - echo - echo "---------- Shadowsocks 二维码链接 -------------" - echo - echo -e "$yellow 链接 = $cyan$link$none" - echo - echo -e " 温馨提示...$red Shadowsocks Win 4.0.6 $none客户端可能无法识别该二维码" - echo - echo "备注...链接将在 14 天后失效" - echo - echo "提醒...请不要把链接分享出去...除非你有特别的理由...." - echo - else - echo - echo -e "$red 哎呀呀呀...出错咯...请重试$none" - echo - fi - rm -rf /tmp/233blog_shadowsocks.png - rm -rf /tmp/233blog_shadowsocks.txt + _load qr.sh + _ss_qr else shadowsocks_config fi @@ -2474,32 +2454,8 @@ get_v2ray_config() { } get_v2ray_config_link() { - echo - echo -e "$green 正在生成链接.... 稍等片刻即可....$none" - echo - local random=$(echo $RANDOM-$RANDOM-$RANDOM | base64 -w 0) - local link=$(curl -s --upload-file $v2ray_client_config "https://transfer.sh/${random}_v2ray6_v2ray.json") - if [[ $link ]]; then - echo - echo "---------- V2Ray 客户端配置文件链接 -------------" - echo - echo -e "$yellow 链接 = $cyan$link$none" - echo - echo -e "$yellow SOCKS 监听端口 = ${cyan}2333${none}" - echo - echo -e "${yellow} HTTP 监听端口 = ${cyan}6666$none" - echo - echo " V2Ray 客户端使用教程: https://${_site}/post/4/" - echo - echo "备注...链接将在 14 天后失效" - echo - echo "提醒...请不要把链接分享出去...除非你有特别的理由...." - echo - else - echo - echo -e "$red 哎呀呀呀...出错咯...请重试$none" - echo - fi + _load client_file.sh + _get_client_file } create_v2ray_config_text() { @@ -2906,6 +2862,11 @@ menu() { fi done echo + echo + echo -e "注意: 如果主机时间跟实际相差${yellow}超过90秒${none},v2ray将无法正常通信。" + _load sys-info.sh + _sys_time + echo echo -e "温馨提示...如果你不想执行选项...按$yellow Ctrl + C $none即可退出" echo read -p "$(echo -e "请选择菜单 [${magenta}1-${#_lists[*]}$none]:")" choose @@ -3049,7 +3010,10 @@ reload) view_v2ray_config_info ;; time) - date -s "$(curl -sI g.cn | grep Date | cut -d' ' -f3-6)Z" + _load sys-info.sh + _sys_timezone + date --utc -s "$(curl -sI g.cn | grep Date | cut -d' ' -f3-6)Z" + _sys_time ;; log) view_v2ray_log