From 25dde1da5000113f4162d5f129eb85c88c6c9c58 Mon Sep 17 00:00:00 2001 From: Jrohy Date: Sun, 17 Mar 2019 00:53:37 +0800 Subject: [PATCH] clean code --- v2ray | 431 ---------------------------------------------------------- 1 file changed, 431 deletions(-) delete mode 100755 v2ray diff --git a/v2ray b/v2ray deleted file mode 100755 index 39f47247..00000000 --- a/v2ray +++ /dev/null @@ -1,431 +0,0 @@ -#!/bin/bash - -SHELL_V2RAY="v2.6.3.1" - -#######color code######## -RED="31m" # Error message -GREEN="32m" # Success message -YELLOW="33m" # Warning message -BLUE="36m" # Info message - -APP_PATH="/usr/local/multi-v2ray" - -colorEcho(){ - COLOR=$1 - echo -e "\033[${COLOR}${@:2}\033[0m" -} - -showVersion(){ - echo "" - echo -e "multi-v2ray: $(colorEcho $GREEN $SHELL_V2RAY)\n" - V2RAY_VERSION=$(/usr/bin/v2ray/v2ray -version | head -n 1 | cut -d " " -f2-4) - echo -e "v2ray: $(colorEcho $GREEN $V2RAY_VERSION)\n" -} - -cleanLog() { - cat /dev/null > /var/log/v2ray/access.log - cat /dev/null > /var/log/v2ray/error.log - colorEcho ${GREEN} "清理v2ray日志成功!\n" -} - -#Check Root -[ $(id -u) != "0" ] && { colorEcho ${RED} "Error: You must be root to run this script"; exit 1; } - -help(){ - echo "v2ray [-h|--help] [-v|--version] [options]" - echo " -h, --help 查看帮助" - echo " -v, --version 查看版本信息" - echo " start 启动 V2Ray" - echo " stop 停止 V2Ray" - echo " restart 重启 V2Ray" - echo " status 查看 V2Ray 运行状态" - echo " log 查看 V2Ray 运行日志" - echo " update 更新 V2Ray 到最新Release版本" - echo " update [version] 更新 V2Ray 到特定版本" - echo " update.sh 更新 multi-v2ray" - echo " update.sh [version] 更新 multi-v2ray 到特定版本" - echo " add 新增mkcp + 随机一种 (srtp | wechat-video | utp | dtls) header伪装的端口(Group)" - echo " add [wechat|utp|srtp|dtls|wireguard|socks|mtproto|ss] 新增一种协议的组,端口随机,如 v2ray add utp 为新增utp协议" - echo " del 删除端口组" - echo " info 查看配置" - echo " port 修改端口" - echo " tls 修改tls" - echo " tfo 修改tcpFastOpen" - echo " stream 修改传输协议" - echo " stats iptables流量统计" - echo " clean 清理日志" - echo " 更多功能 请输入 v2ray 回车进入服务管理程序" - return 0 -} - -PARAMS_NUM=$# - -#######get params######### -while [[ $# > 0 ]];do - key="$1" - case $key in - -h|--help) - help - ;; - -v|--version) - showVersion - ;; - start) - service v2ray start - colorEcho ${GREEN} "v2ray启动成功!" - ;; - stop) - service v2ray stop - colorEcho ${GREEN} "v2ray已停止!" - ;; - restart) - service v2ray restart - colorEcho ${GREEN} "v2ray重启成功!" - ;; - status) - service v2ray status - ;; - log) - colorEcho ${BLUE} "按Ctrl + C 可以退出日志功能\n" - tail -f /var/log/v2ray/access.log - ;; - update) - V2RAY_VERSION="$2" - if [[ -z $V2RAY_VERSION ]];then - bash <(curl -L -s https://install.direct/go.sh) - else - bash <(curl -L -s https://install.direct/go.sh) --version $V2RAY_VERSION - fi - shift - ;; - update.sh) - SHELL_VERSION="$2" - if [[ -z $SHELL_VERSION ]];then - source <(curl -sL https://git.io/fNgqx) -k - else - source <(curl -sL https://git.io/fNgqx) -k -v $SHELL_VERSION - fi - shift - ;; - info) - python3 -c "from loader import Loader; print(Loader().profile);" - ;; - port) - python3 $APP_PATH/config_modify/port.py - python3 -c "from utils import open_port; open_port();" - - service v2ray restart - ;; - tls) - python3 $APP_PATH/config_modify/tls.py - service v2ray restart - ;; - tfo) - python3 $APP_PATH/config_modify/tfo.py - service v2ray restart - ;; - stream) - python3 $APP_PATH/config_modify/stream.py - service v2ray restart - ;; - stats) - python3 $APP_PATH/global_setting/iptables_ctr.py - ;; - clean) - cleanLog - ;; - del) - python3 $APP_PATH/user_manage/del_port.py - service v2ray restart - ;; - add) - EXTRA="$2" - python3 $APP_PATH/user_manage/create_new_port.py $EXTRA - python3 -c "from utils import open_port; open_port();" - service v2ray restart - shift - ;; - *) - colorEcho ${YELLOW} "传参有误! 输入-h 或者--help查看帮助" # unknown option - ;; - esac - shift # past argument or value -done -############################# - -##有参数输入操作一波后就结束 -[[ $PARAMS_NUM > 0 ]] && exit - -echo "" -colorEcho ${BLUE} "欢迎使用 multi-v2ray 管理程序" -echo -e "" -echo -e "1.服务管理 2.用户管理\n" -echo -e "3.更改配置 4.查看配置\n" -echo -e "5.全局功能 6.更新V2Ray\n" -echo -e "7.生成客户端配置文件" - -while :; do echo - read -n1 -p "请输入数字选择功能(按回车键退出): " CHOICE - if [[ ! $CHOICE =~ ^[1-7]$ ]]; then - if [[ -z ${CHOICE} ]];then - exit 0 - fi - colorEcho ${RED} "输入错误! 请输入正确的数字!" - else - echo -e "\n" - break - fi -done - -if [[ ${CHOICE} == 1 ]]; then - echo -e "1.启动服务" - echo -e "2.停止服务" - echo -e "3.重启服务" - echo -e "4.运行状态" - echo -e "5.运行日志" - while :; do echo - read -n1 -p "请选择: " SERVICE_CHOICE - if [[ ! $SERVICE_CHOICE =~ ^[1-5]$ ]]; then - if [[ -z ${SERVICE_CHOICE} ]];then - bash /usr/local/bin/v2ray - exit 0 - fi - colorEcho ${RED} "输入错误! 请输入正确的数字!" - else - echo -e "\n" - break - fi - done - if [[ ${SERVICE_CHOICE} == 1 ]]; then - service v2ray start - python3 -c "from utils import open_port; open_port();" - echo "服务启动成功!" - bash /usr/local/bin/v2ray - - elif [[ ${SERVICE_CHOICE} == 2 ]]; then - service v2ray stop - echo "服务停止成功!" - bash /usr/local/bin/v2ray - - elif [[ ${SERVICE_CHOICE} == 3 ]]; then - service v2ray restart - python3 -c "from utils import open_port; open_port();" - echo "服务已重启!" - bash /usr/local/bin/v2ray - - elif [[ ${SERVICE_CHOICE} == 4 ]]; then - service v2ray status - bash /usr/local/bin/v2ray - - elif [[ ${SERVICE_CHOICE} == 5 ]]; then - echo "按Ctrl + C 可以退出日志功能" - echo "" - tail -f /var/log/v2ray/access.log - bash /usr/local/bin/v2ray - fi -fi - -if [[ ${CHOICE} == 2 ]]; then - echo -e "1.新增用户\n" - echo -e "2.新增端口\n" - echo -e "3.删除用户\n" - echo -e "4.删除端口\n" - while :; do echo - read -n1 -p "请输入数字选择功能: " USER_CHOICE - if [[ ! $USER_CHOICE =~ ^[1-4]$ ]]; then - if [[ -z ${USER_CHOICE} ]];then - bash /usr/local/bin/v2ray - exit 0 - fi - colorEcho ${RED} "输入错误! 请输入正确的数字!" - else - echo -e "\n" - break - fi - done - - if [[ ${USER_CHOICE} == 1 ]]; then - python3 $APP_PATH/user_manage/create_new_user.py - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${USER_CHOICE} == 2 ]]; then - python3 $APP_PATH/user_manage/create_new_port.py - python3 -c "from utils import open_port; open_port();" - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${USER_CHOICE} == 3 ]]; then - python3 $APP_PATH/user_manage/del_user.py - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${USER_CHOICE} == 4 ]]; then - python3 $APP_PATH/user_manage/del_port.py - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - fi -fi - -if [[ ${CHOICE} == 3 ]]; then - echo "" - echo -e "1.更改email\n" - echo -e "2.更改UUID\n" - echo -e "3.更改alterID\n" - echo -e "4.更改主端口\n" - echo -e "5.更改传输方式\n" - echo -e "6.更改TLS设置\n" - echo -e "7.更改tcpFastOpen设置\n" - echo -e "8.更改动态端口\n" - echo -e "9.更改Shadowsocks加密方式\n" - echo -e "10.更改Shadowsocks密码\n" - - while :; do echo - read -p "请输入数字选择功能: " CONFIG_CHOICE - if [[ ! $CONFIG_CHOICE =~ (^[1-9]$|10) ]]; then - if [[ -z ${CONFIG_CHOICE} ]];then - bash /usr/local/bin/v2ray - exit 0 - fi - colorEcho ${RED} "输入错误! 请输入正确的数字!" - else - echo -e "\n" - break - fi - done - - if [[ ${CONFIG_CHOICE} == 1 ]]; then - python3 $APP_PATH/config_modify/n_email.py - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${CONFIG_CHOICE} == 2 ]]; then - python3 $APP_PATH/config_modify/n_uuid.py - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${CONFIG_CHOICE} == 3 ]]; then - python3 $APP_PATH/config_modify/alterid.py - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${CONFIG_CHOICE} == 4 ]]; then - python3 $APP_PATH/config_modify/port.py - python3 -c "from utils import open_port; open_port();" - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${CONFIG_CHOICE} == 5 ]]; then - python3 $APP_PATH/config_modify/stream.py - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${CONFIG_CHOICE} == 6 ]]; then - python3 $APP_PATH/config_modify/tls.py - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${CONFIG_CHOICE} == 7 ]]; then - python3 $APP_PATH/config_modify/tfo.py - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${CONFIG_CHOICE} == 8 ]]; then - python3 $APP_PATH/config_modify/dyn_port.py - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${CONFIG_CHOICE} == 9 ]]; then - python3 $APP_PATH/config_modify/ss.py method - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${CONFIG_CHOICE} == 10 ]]; then - python3 $APP_PATH/config_modify/ss.py password - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - fi -fi - -if [[ ${CHOICE} == 4 ]]; then - python3 -c "from loader import Loader; print(Loader().profile);" - bash /usr/local/bin/v2ray -fi - -if [[ ${CHOICE} == 5 ]]; then - echo -e "" - echo -e "1.流量统计(v2ray)\n" - echo -e "2.流量统计(iptables)\n" - echo -e "3.禁止bittorrent\n" - echo -e "4.定时更新V2ray\n" - echo -e "5.清理v2ray日志\n" - echo -e "6.脚本升级\n" - echo -e "请输入数字选择功能" - - while :; do echo - read -n1 -p "请选择: " EXTRA_CHOICE - if [[ ! $EXTRA_CHOICE =~ ^[1-6]$ ]]; then - if [[ -z ${EXTRA_CHOICE} ]];then - bash /usr/local/bin/v2ray - exit 0 - fi - colorEcho ${RED} "输入错误! 请输入正确的数字!" - else - echo -e "\n" - break - fi - done - - if [[ ${EXTRA_CHOICE} == 1 ]]; then - python3 $APP_PATH/global_setting/stats_ctr.py - bash /usr/local/bin/v2ray - - elif [[ ${EXTRA_CHOICE} == 2 ]]; then - python3 $APP_PATH/global_setting/iptables_ctr.py - bash /usr/local/bin/v2ray - - elif [[ ${EXTRA_CHOICE} == 3 ]]; then - python3 $APP_PATH/global_setting/ban_bt.py - service v2ray restart - echo "" - bash /usr/local/bin/v2ray - - elif [[ ${EXTRA_CHOICE} == 4 ]]; then - bash $APP_PATH/global_setting/update_timer.sh - bash /usr/local/bin/v2ray - - elif [[ ${EXTRA_CHOICE} == 5 ]]; then - cleanLog - bash /usr/local/bin/v2ray - - elif [[ ${EXTRA_CHOICE} == 6 ]]; then - echo -e "脚本正在以保留配置文件形式升级, 若失败请自行手动全新安装..\n" - source <(curl -sL https://git.io/fNgqx) -k - echo -e "\n脚本升级成功!!\n" - bash /usr/local/bin/v2ray - fi -fi - -if [[ ${CHOICE} == 6 ]]; then - bash <(curl -L -s https://install.direct/go.sh) - bash /usr/local/bin/v2ray -fi - -if [[ ${CHOICE} == 7 ]]; then - python3 $APP_PATH/client.py - bash /usr/local/bin/v2ray -fi \ No newline at end of file