From 4266421c4f26e79fa9f88b00b5d7861baf325341 Mon Sep 17 00:00:00 2001 From: jiulingyun Date: Sun, 10 Mar 2024 22:29:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8F=8F=E8=BF=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6&=E6=B1=89=E5=8C=96=E5=AE=89=E8=A3=85=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E5=92=8C=20x-ui=20=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 439 ++------------------------------------------------- install.sh | 112 ++++++------- main.go | 22 +-- x-ui.sh | 452 ++++++++++++++++++++++++++--------------------------- 4 files changed, 305 insertions(+), 720 deletions(-) diff --git a/README.md b/README.md index 14d569db..644f6c1b 100644 --- a/README.md +++ b/README.md @@ -1,395 +1,26 @@ # 3X-UI -

Image

-**An Advanced Web Panel • Built on Xray Core** - -[![](https://img.shields.io/github/v/release/mhsanaei/3x-ui.svg)](https://github.com/MHSanaei/3x-ui/releases) -[![](https://img.shields.io/github/actions/workflow/status/mhsanaei/3x-ui/release.yml.svg)](#) -[![GO Version](https://img.shields.io/github/go-mod/go-version/mhsanaei/3x-ui.svg)](#) -[![Downloads](https://img.shields.io/github/downloads/mhsanaei/3x-ui/total.svg)](#) -[![License](https://img.shields.io/badge/license-GPL%20V3-blue.svg?longCache=true)](https://www.gnu.org/licenses/gpl-3.0.en.html) - -> **Disclaimer:** This project is only for personal learning and communication, please do not use it for illegal purposes, please do not use it in a production environment - -**If this project is helpful to you, you may wish to give it a**:star2: - -

Image

- -- USDT (TRC20): `TXncxkvhkDWGts487Pjqq1qT9JmwRUz8CC` - -## Install & Upgrade +## 安装 & 更新 ``` -bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) +bash <(curl -Ls https://raw.githubusercontent.com/jiulingyun/3x-ui/tree/dev/install.sh) ``` -## Install Custom Version +## 安装指定版本 -To install your desired version, add the version to the end of the installation command. e.g., ver `v2.2.1`: +要安装所需的版本,请将该版本添加到安装命令的末尾。例如: `v2.2.1`: ``` -bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) v2.2.1 +bash <(curl -Ls https://raw.githubusercontent.com/jiulingyun/3x-ui/tree/dev/install.sh) v2.2.1 ``` -## SSL Certificate +## API 路由
- Click for SSL Certificate + 点击查看 API 路由详情 -### Cloudflare - -The Management script has a built-in SSL certificate application for Cloudflare. To use this script to apply for a certificate, you need the following: - -- Cloudflare registered email -- Cloudflare Global API Key -- The domain name has been resolved to the current server through cloudflare - -**1:** Run the`x-ui`command on the terminal, then choose `Cloudflare SSL Certificate`. - - -### Certbot -``` -apt-get install certbot -y -certbot certonly --standalone --agree-tos --register-unsafely-without-email -d yourdomain.com -certbot renew --dry-run -``` - -***Tip:*** *Certbot is also built into the Management script. You can run the `x-ui` command, then choose `SSL Certificate Management`.* - -
- -## Manual Install & Upgrade - -
- Click for manual install details - -#### Usage - -1. To download the latest version of the compressed package directly to your server, run the following command: - -```sh -ARCH=$(uname -m) -case "${ARCH}" in - x86_64 | x64 | amd64) XUI_ARCH="amd64" ;; - i*86 | x86) XUI_ARCH="386" ;; - armv8* | armv8 | arm64 | aarch64) XUI_ARCH="arm64" ;; - armv7* | armv7) XUI_ARCH="armv7" ;; - armv6* | armv6) XUI_ARCH="armv6" ;; - armv5* | armv5) XUI_ARCH="armv5" ;; - *) XUI_ARCH="amd64" ;; -esac - - -wget https://github.com/MHSanaei/3x-ui/releases/latest/download/x-ui-linux-${XUI_ARCH}.tar.gz -``` - -2. Once the compressed package is downloaded, execute the following commands to install or upgrade x-ui: - -```sh -ARCH=$(uname -m) -case "${ARCH}" in - x86_64 | x64 | amd64) XUI_ARCH="amd64" ;; - i*86 | x86) XUI_ARCH="386" ;; - armv8* | armv8 | arm64 | aarch64) XUI_ARCH="arm64" ;; - armv7* | armv7) XUI_ARCH="armv7" ;; - armv6* | armv6) XUI_ARCH="armv6" ;; - armv5* | armv5) XUI_ARCH="armv5" ;; - *) XUI_ARCH="amd64" ;; -esac - -cd /root/ -rm -rf x-ui/ /usr/local/x-ui/ /usr/bin/x-ui -tar zxvf x-ui-linux-${XUI_ARCH}.tar.gz -chmod +x x-ui/x-ui x-ui/bin/xray-linux-* x-ui/x-ui.sh -cp x-ui/x-ui.sh /usr/bin/x-ui -cp -f x-ui/x-ui.service /etc/systemd/system/ -mv x-ui/ /usr/local/ -systemctl daemon-reload -systemctl enable x-ui -systemctl restart x-ui -``` - -
- -## Install with Docker - -
- Click for Docker details - -#### Usage - -1. Install Docker: - - ```sh - bash <(curl -sSL https://get.docker.com) - ``` - -2. Clone the Project Repository: - - ```sh - git clone https://github.com/MHSanaei/3x-ui.git - cd 3x-ui - ``` - -3. Start the Service - - ```sh - docker compose up -d - ``` - - OR - - ```sh - docker run -itd \ - -e XRAY_VMESS_AEAD_FORCED=false \ - -v $PWD/db/:/etc/x-ui/ \ - -v $PWD/cert/:/root/cert/ \ - --network=host \ - --restart=unless-stopped \ - --name 3x-ui \ - ghcr.io/mhsanaei/3x-ui:latest - ``` - -update to latest version - - ```sh - cd 3x-ui - docker compose down - docker compose pull 3x-ui - docker compose up -d - ``` - -remove 3x-ui from docker - - ```sh - docker stop 3x-ui - docker rm 3x-ui - cd -- - rm -r 3x-ui - ``` - -
- - -## Recommended OS - -- Ubuntu 20.04+ -- Debian 11+ -- CentOS 8+ -- Fedora 36+ -- Arch Linux -- Manjaro -- Armbian -- AlmaLinux 9+ -- Rockylinux 9+ - -## Supported Architectures and Devices - -
- Click for Supported Architectures and devices details - -Our platform offers compatibility with a diverse range of architectures and devices, ensuring flexibility across various computing environments. The following are key architectures that we support: - -- **amd64**: This prevalent architecture is the standard for personal computers and servers, accommodating most modern operating systems seamlessly. - -- **x86 / i386**: Widely adopted in desktop and laptop computers, this architecture enjoys broad support from numerous operating systems and applications, including but not limited to Windows, macOS, and Linux systems. - -- **armv8 / arm64 / aarch64**: Tailored for contemporary mobile and embedded devices, such as smartphones and tablets, this architecture is exemplified by devices like Raspberry Pi 4, Raspberry Pi 3, Raspberry Pi Zero 2/Zero 2 W, Orange Pi 3 LTS, and more. - -- **armv7 / arm / arm32**: Serving as the architecture for older mobile and embedded devices, it remains widely utilized in devices like Orange Pi Zero LTS, Orange Pi PC Plus, Raspberry Pi 2, among others. - -- **armv6 / arm / arm32**: Geared towards very old embedded devices, this architecture, while less prevalent, is still in use. Devices such as Raspberry Pi 1, Raspberry Pi Zero/Zero W, rely on this architecture. - -- **armv5 / arm / arm32**: An older architecture primarily associated with early embedded systems, it is less common today but may still be found in legacy devices like early Raspberry Pi versions and some older smartphones. -
- -## Languages - -- English -- Farsi -- Chinese -- Russian -- Vietnamese -- Spanish -- Indonesian -- Ukrainian - - -## Features - -- System Status Monitoring -- Search within all inbounds and clients -- Dark/Light theme -- Supports multi-user and multi-protocol -- Supports protocols, including VMess, VLESS, Trojan, Shadowsocks, Dokodemo-door, Socks, HTTP, wireguard -- Supports XTLS native Protocols, including RPRX-Direct, Vision, REALITY -- Traffic statistics, traffic limit, expiration time limit -- Customizable Xray configuration templates -- Supports HTTPS access panel (self-provided domain name + SSL certificate) -- Supports One-Click SSL certificate application and automatic renewal -- For more advanced configuration items, please refer to the panel -- Fixes API routes (user setting will be created with API) -- Supports changing configs by different items provided in the panel. -- Supports export/import database from the panel - - -## Default Settings - -
- Click for default settings details - - ### Information - -- **Port:** 2053 -- **Username & Password:** It will be generated randomly if you skip modifying. -- **Database Path:** - - /etc/x-ui/x-ui.db -- **Xray Config Path:** - - /usr/local/x-ui/bin/config.json -- **Web Panel Path w/o Deploying SSL:** - - http://ip:2053/panel - - http://domain:2053/panel -- **Web Panel Path w/ Deploying SSL:** - - https://domain:2053/panel - -
- -## [WARP Configuration](https://gitlab.com/fscarmen/warp) - -
- Click for WARP configuration details - -#### Usage - -If you want to use routing to WARP before v2.1.0 follow steps as below: - -**1.** Install WARP on **SOCKS Proxy Mode**: - - ```sh - bash <(curl -sSL https://raw.githubusercontent.com/hamid-gh98/x-ui-scripts/main/install_warp_proxy.sh) - ``` - -**2.** If you already installed warp, you can uninstall using below command: - - ```sh - warp u - ``` - -**3.** Turn on the config you need in panel - - Config Features: - - - Block Ads - - Route Google + Netflix + Spotify + OpenAI (ChatGPT) to WARP - - Fix Google 403 error - -
- -## IP Limit - -
- Click for IP limit details - -#### Usage - -**Note:** IP Limit won't work correctly when using IP Tunnel - -- For versions up to `v1.6.1`: - - - IP limit is built-in into the panel. - -- For versions `v1.7.0` and newer: - - - To make IP Limit work properly, you need to install fail2ban and its required files by following these steps: - - 1. Use the `x-ui` command inside the shell. - 2. Select `IP Limit Management`. - 3. Choose the appropriate options based on your needs. - - - make sure you have ./access.log on your Xray Configuration after v2.1.3 we have an option for it - - ```sh - "log": { - "access": "./access.log", - "dnsLog": false, - "loglevel": "warning" - }, - ``` - -
- -## Telegram Bot - -
- Click for Telegram bot details - -#### Usage - -The web panel supports daily traffic, panel login, database backup, system status, client info, and other notification and functions through the Telegram Bot. To use the bot, you need to set the bot-related parameters in the panel, including: - -- Telegram Token -- Admin Chat ID(s) -- Notification Time (in cron syntax) -- Expiration Date Notification -- Traffic Cap Notification -- Database Backup -- CPU Load Notification - - -**Reference syntax:** - -- `30 \* \* \* \* \*` - Notify at the 30s of each point -- `0 \*/10 \* \* \* \*` - Notify at the first second of each 10 minutes -- `@hourly` - Hourly notification -- `@daily` - Daily notification (00:00 in the morning) -- `@weekly` - weekly notification -- `@every 8h` - Notify every 8 hours - -### Telegram Bot Features - -- Report periodic -- Login notification -- CPU threshold notification -- Threshold for Expiration time and Traffic to report in advance -- Support client report menu if client's telegram username added to the user's configurations -- Support telegram traffic report searched with UUID (VMESS/VLESS) or Password (TROJAN) - anonymously -- Menu based bot -- Search client by email ( only admin ) -- Check all inbounds -- Check server status -- Check depleted users -- Receive backup by request and in periodic reports -- Multi language bot - -### Setting up Telegram bot - -- Start [Botfather](https://t.me/BotFather) in your Telegram account: - ![Botfather](./media/botfather.png) - -- Create a new Bot using /newbot command: It will ask you 2 questions, A name and a username for your bot. Note that the username has to end with the word "bot". - ![Create new bot](./media/newbot.png) - -- Start the bot you've just created. You can find the link to your bot here. - ![token](./media/token.png) - -- Enter your panel and config Telegram bot settings like below: -![Panel Config](./media/panel-bot-config.png) - -Enter your bot token in input field number 3. -Enter the user ID in input field number 4. The Telegram accounts with this id will be the bot admin. (You can enter more than one, Just separate them with ,) - -- How to get Telegram user ID? Use this [bot](https://t.me/useridinfobot), Start the bot and it will give you the Telegram user ID. -![User ID](./media/user-id.png) - -
- -## API Routes - -
- Click for API routes details - -#### Usage +#### 使用 - `/login` with `POST` user data: `{username: '', password: ''}` for login - `/panel/api/inbounds` base for following actions: @@ -414,59 +45,13 @@ Enter the user ID in input field number 4. The Telegram accounts with this id wi | `POST` | `"/delDepletedClients/:id"` | Delete inbound depleted clients (-1: all) | | `POST` | `"/onlines"` | Get Online users ( list of emails ) | -\*- The field `clientId` should be filled by: +\*- 字段“clientId”应由: -- `client.id` for VMESS and VLESS -- `client.password` for TROJAN -- `client.email` for Shadowsocks +- `client.id` 适用于 VMESS 和 VLESS +- `client.password` 对于 TROJAN +- `client.email` 用于 Shadowsocks - [API Documentation](https://documenter.getpostman.com/view/16802678/2s9YkgD5jm) - [Run In Postman](https://app.getpostman.com/run-collection/16802678-1a4c9270-ac77-40ed-959a-7aa56dc4a415?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D16802678-1a4c9270-ac77-40ed-959a-7aa56dc4a415%26entityType%3Dcollection%26workspaceId%3D2cd38c01-c851-4a15-a972-f181c23359d9)
- -## Environment Variables - -
- Click for environment variables details - -#### Usage - -| Variable | Type | Default | -| -------------- | :--------------------------------------------: | :------------ | -| XUI_LOG_LEVEL | `"debug"` \| `"info"` \| `"warn"` \| `"error"` | `"info"` | -| XUI_DEBUG | `boolean` | `false` | -| XUI_BIN_FOLDER | `string` | `"bin"` | -| XUI_DB_FOLDER | `string` | `"/etc/x-ui"` | -| XUI_LOG_FOLDER | `string` | `"/var/log"` | - -Example: - -```sh -XUI_BIN_FOLDER="bin" XUI_DB_FOLDER="/etc/x-ui" go build main.go -``` - -
- -## Preview - -![1](./media/1.png) -![2](./media/2.png) -![3](./media/3.png) -![4](./media/4.png) -![5](./media/5.png) -![6](./media/6.png) -![7](./media/7.png) - -## A Special Thanks to - -- [alireza0](https://github.com/alireza0/) - -## Acknowledgment - -- [Iran v2ray rules](https://github.com/chocolate4u/Iran-v2ray-rules) (License: **GPL-3.0**): _Enhanced v2ray/xray and v2ray/xray-clients routing rules with built-in Iranian domains and a focus on security and adblocking._ -- [Vietnam Adblock rules](https://github.com/vuong2023/vn-v2ray-rules) (License: **GPL-3.0**): _A hosted domain hosted in Vietnam and blocklist with the most efficiency for Vietnamese._ - -## Stargazers over Time - -[![Stargazers over time](https://starchart.cc/MHSanaei/3x-ui.svg)](https://starchart.cc/MHSanaei/3x-ui) diff --git a/install.sh b/install.sh index a9b6711b..ee5bc641 100644 --- a/install.sh +++ b/install.sh @@ -8,7 +8,7 @@ plain='\033[0m' cur_dir=$(pwd) # check root -[[ $EUID -ne 0 ]] && echo -e "${red}Fatal error: ${plain} Please run this script with root privilege \n " && exit 1 +[[ $EUID -ne 0 ]] && echo -e "${red}致命错误:${plain} 请以 root 权限运行此脚本 \n " && exit 1 # Check OS and set release variable if [[ -f /etc/os-release ]]; then @@ -18,10 +18,10 @@ elif [[ -f /usr/lib/os-release ]]; then source /usr/lib/os-release release=$ID else - echo "Failed to check the system OS, please contact the author!" >&2 + echo "检查系统操作系统失败,请联系作者!" >&2 exit 1 fi -echo "The OS release is: $release" +echo "操作系统版本为:$release" arch3xui() { case "$(uname -m)" in @@ -31,52 +31,52 @@ arch3xui() { armv7* | armv7 | arm) echo 'armv7' ;; armv6* | armv6) echo 'armv6' ;; armv5* | armv5) echo 'armv5' ;; - *) echo -e "${green}Unsupported CPU architecture! ${plain}" && rm -f install.sh && exit 1 ;; + *) echo -e "${green}不支持的CPU架构! ${plain}" && rm -f install.sh && exit 1 ;; esac } -echo "arch: $(arch3xui)" +echo "信息: $(arch3xui)" os_version="" os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1) if [[ "${release}" == "centos" ]]; then if [[ ${os_version} -lt 8 ]]; then - echo -e "${red} Please use CentOS 8 or higher ${plain}\n" && exit 1 + echo -e "${red} 请使用 CentOS 8 或更高版本 ${plain}\n" && exit 1 fi elif [[ "${release}" == "ubuntu" ]]; then if [[ ${os_version} -lt 20 ]]; then - echo -e "${red} Please use Ubuntu 20 or higher version!${plain}\n" && exit 1 + echo -e "${red} 请使用 Ubuntu 20 或更高版本!${plain}\n" && exit 1 fi elif [[ "${release}" == "fedora" ]]; then if [[ ${os_version} -lt 36 ]]; then - echo -e "${red} Please use Fedora 36 or higher version!${plain}\n" && exit 1 + echo -e "${red} 请使用 Fedora 36 或更高版本!${plain}\n" && exit 1 fi elif [[ "${release}" == "debian" ]]; then if [[ ${os_version} -lt 11 ]]; then - echo -e "${red} Please use Debian 11 or higher ${plain}\n" && exit 1 + echo -e "${red} 请使用 Debian 11 或更高版本${plain}\n" && exit 1 fi elif [[ "${release}" == "almalinux" ]]; then if [[ ${os_version} -lt 9 ]]; then - echo -e "${red} Please use AlmaLinux 9 or higher ${plain}\n" && exit 1 + echo -e "${red} 请使用 AlmaLinux 9 或更高版本 ${plain}\n" && exit 1 fi elif [[ "${release}" == "rocky" ]]; then if [[ ${os_version} -lt 9 ]]; then - echo -e "${red} Please use RockyLinux 9 or higher ${plain}\n" && exit 1 + echo -e "${red} 请使用 RockyLinux 9 或更高版本 ${plain}\n" && exit 1 fi elif [[ "${release}" == "arch" ]]; then - echo "Your OS is ArchLinux" + echo "你的操作系统是 ArchLinux" elif [[ "${release}" == "manjaro" ]]; then - echo "Your OS is Manjaro" + echo "您的操作系统是 Manjaro" elif [[ "${release}" == "armbian" ]]; then - echo "Your OS is Armbian" + echo "您的操作系统是 Armbian" else - echo -e "${red}Failed to check the OS version, please contact the author!${plain}" && exit 1 + echo -e "${red}检查操作系统版本失败,请联系作者!${plain}" && exit 1 fi install_base() { @@ -98,34 +98,34 @@ install_base() { # This function will be called when user installed x-ui out of security config_after_install() { - echo -e "${yellow}Install/update finished! For security it's recommended to modify panel settings ${plain}" - read -p "Do you want to continue with the modification [y/n]?": config_confirm + echo -e "${yellow}安装/更新完成!为了安全起见,建议修改面板设置${plain}" + read -p "是否要继续修改 [y/n]?": config_confirm if [[ "${config_confirm}" == "y" || "${config_confirm}" == "Y" ]]; then - read -p "Please set up your username:" config_account - echo -e "${yellow}Your username will be:${config_account}${plain}" - read -p "Please set up your password:" config_password - echo -e "${yellow}Your password will be:${config_password}${plain}" - read -p "Please set up the panel port:" config_port - echo -e "${yellow}Your panel port is:${config_port}${plain}" - echo -e "${yellow}Initializing, please wait...${plain}" + read -p "请设置您的用户名:" config_account + echo -e "${yellow}您的用户名将是:${config_account}${plain}" + read -p "请设置您的密码:" config_password + echo -e "${yellow}您的密码将是:${config_password}${plain}" + read -p "请设置面板端口:" config_port + echo -e "${yellow}您的面板端口是:${config_port}${plain}" + echo -e "${yellow}正在初始化,请稍候...${plain}" /usr/local/x-ui/x-ui setting -username ${config_account} -password ${config_password} - echo -e "${yellow}Account name and password set successfully!${plain}" + echo -e "${yellow}帐户名和密码设置成功!${plain}" /usr/local/x-ui/x-ui setting -port ${config_port} - echo -e "${yellow}Panel port set successfully!${plain}" + echo -e "${yellow}面板端口设置成功!${plain}" else - echo -e "${red}cancel...${plain}" + echo -e "${red}取消...${plain}" if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then local usernameTemp=$(head -c 6 /dev/urandom | base64) local passwordTemp=$(head -c 6 /dev/urandom | base64) /usr/local/x-ui/x-ui setting -username ${usernameTemp} -password ${passwordTemp} - echo -e "this is a fresh installation,will generate random login info for security concerns:" + echo -e "这是一个全新的安装,出于安全考虑,会生成随机登录信息:" echo -e "###############################################" - echo -e "${green}username:${usernameTemp}${plain}" - echo -e "${green}password:${passwordTemp}${plain}" + echo -e "${green}用户名:${usernameTemp}${plain}" + echo -e "${green}密码:${passwordTemp}${plain}" echo -e "###############################################" - echo -e "${red}if you forgot your login info,you can type x-ui and then type 8 to check after installation${plain}" + echo -e "${red}如果您忘记了登录信息,您可以输入 X-UI,然后输入 8 以在安装后进行检查${plain}" else - echo -e "${red} this is your upgrade,will keep old settings,if you forgot your login info,you can type x-ui and then type 8 to check${plain}" + echo -e "${red} 这是您的升级,将保留旧设置,如果您忘记了登录信息,您可以输入 x-ui,然后输入 8 进行检查${plain}" fi fi /usr/local/x-ui/x-ui migrate @@ -135,24 +135,24 @@ install_x-ui() { cd /usr/local/ if [ $# == 0 ]; then - last_version=$(curl -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') + last_version=$(curl -Ls "https://api.github.com/repos/jiulingyun/3x-ui/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/') if [[ ! -n "$last_version" ]]; then - echo -e "${red}Failed to fetch x-ui version, it maybe due to Github API restrictions, please try it later${plain}" + echo -e "${red}无法获取 x-ui 版本,可能是由于 Github API 限制,请稍后再试${plain}" exit 1 fi - echo -e "Got x-ui latest version: ${last_version}, beginning the installation..." - wget -N --no-check-certificate -O /usr/local/x-ui-linux-$(arch3xui).tar.gz https://github.com/MHSanaei/3x-ui/releases/download/${last_version}/x-ui-linux-$(arch3xui).tar.gz + echo -e "获取到 x-ui 最新版本:${last_version},开始安装..." + wget -N --no-check-certificate -O /usr/local/x-ui-linux-$(arch3xui).tar.gz https://github.com/jiulingyun/3x-ui/releases/download/${last_version}/x-ui-linux-$(arch3xui).tar.gz if [[ $? -ne 0 ]]; then - echo -e "${red}Downloading x-ui failed, please be sure that your server can access Github ${plain}" + echo -e "${red}下载 x-ui 失败,请确保您的服务器可以访问 Github${plain}" exit 1 fi else last_version=$1 - url="https://github.com/MHSanaei/3x-ui/releases/download/${last_version}/x-ui-linux-$(arch3xui).tar.gz" - echo -e "Beginning to install x-ui $1" + url="https://github.com/jiulingyun/3x-ui/releases/download/${last_version}/x-ui-linux-$(arch3xui).tar.gz" + echo -e "开始安装 x-ui$1" wget -N --no-check-certificate -O /usr/local/x-ui-linux-$(arch3xui).tar.gz ${url} if [[ $? -ne 0 ]]; then - echo -e "${red}Download x-ui $1 failed,please check the version exists ${plain}" + echo -e "${red}下载 x-ui $1 失败,请检查版本是否存在${plain}" exit 1 fi fi @@ -175,7 +175,7 @@ install_x-ui() { chmod +x x-ui bin/xray-linux-$(arch3xui) cp -f x-ui.service /etc/systemd/system/ - wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh + wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/jiulingyun/3x-ui/main/x-ui.sh chmod +x /usr/local/x-ui/x-ui.sh chmod +x /usr/bin/x-ui config_after_install @@ -183,25 +183,25 @@ install_x-ui() { systemctl daemon-reload systemctl enable x-ui systemctl start x-ui - echo -e "${green}x-ui ${last_version}${plain} installation finished, it is running now..." + echo -e "${green}x-ui ${last_version}${plain} 安装完成,正在运行..." echo -e "" - echo -e "x-ui control menu usages: " + echo -e "X-UI 控件菜单用法: " echo -e "----------------------------------------------" - echo -e "x-ui - Enter Admin menu" - echo -e "x-ui start - Start x-ui" - echo -e "x-ui stop - Stop x-ui" - echo -e "x-ui restart - Restart x-ui" - echo -e "x-ui status - Show x-ui status" - echo -e "x-ui enable - Enable x-ui on system startup" - echo -e "x-ui disable - Disable x-ui on system startup" - echo -e "x-ui log - Check x-ui logs" - echo -e "x-ui banlog - Check Fail2ban ban logs" - echo -e "x-ui update - Update x-ui" - echo -e "x-ui install - Install x-ui" - echo -e "x-ui uninstall - Uninstall x-ui" + echo -e "x-ui - 进入管理菜单" + echo -e "x-ui start - 启动 x-ui" + echo -e "x-ui stop - 停止 x-ui" + echo -e "x-ui restart - 重启 x-ui" + echo -e "x-ui status - 显示 x-ui 状态" + echo -e "x-ui enable - 启用 x-ui 开机自启" + echo -e "x-ui disable - 禁用 x-ui 开机自启" + echo -e "x-ui log - 查看 x-ui 日志" + echo -e "x-ui banlog - 查看 Fail2ban 封禁日志" + echo -e "x-ui update - 更新 x-ui" + echo -e "x-ui install - 安装 x-ui" + echo -e "x-ui uninstall - 卸载 x-ui" echo -e "----------------------------------------------" } -echo -e "${green}Running...${plain}" +echo -e "${green}运行...${plain}" install_base install_x-ui $1 diff --git a/main.go b/main.go index fdf54089..7d69fdc5 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,7 @@ func runWebServer() { case config.Error: logger.InitLogger(logging.ERROR) default: - log.Fatal("unknown log level:", config.GetLogLevel()) + log.Fatal("未知日志级别:", config.GetLogLevel()) } err := database.InitDB(config.GetDBPath()) @@ -113,9 +113,9 @@ func resetSetting() { settingService := service.SettingService{} err = settingService.ResetSettings() if err != nil { - fmt.Println("reset setting failed:", err) + fmt.Println("重置设置失败:", err) } else { - fmt.Println("reset setting success") + fmt.Println("重置设置成功") } } @@ -124,19 +124,19 @@ func showSetting(show bool) { settingService := service.SettingService{} port, err := settingService.GetPort() if err != nil { - fmt.Println("get current port failed,error info:", err) + fmt.Println("获取当前端口失败,错误信息:", err) } userService := service.UserService{} userModel, err := userService.GetFirstUser() if err != nil { - fmt.Println("get current user info failed,error info:", err) + fmt.Println("获取当前用户信息失败,错误信息:", err) } username := userModel.Username userpasswd := userModel.Password if (username == "") || (userpasswd == "") { - fmt.Println("current username or password is empty") + fmt.Println("当前用户名或密码为空") } - fmt.Println("current panel settings as follows:") + fmt.Println("当前面板设置如下:") fmt.Println("username:", username) fmt.Println("userpasswd:", userpasswd) fmt.Println("port:", port) @@ -296,10 +296,10 @@ func main() { flag.Usage = func() { oldUsage() fmt.Println() - fmt.Println("Commands:") - fmt.Println(" run run web panel") - fmt.Println(" migrate migrate form other/old x-ui") - fmt.Println(" setting set settings") + fmt.Println("命令:") + fmt.Println(" run 运行 web 面板") + fmt.Println(" migrate 从其他/旧迁移 x-ui") + fmt.Println(" setting 设置") } flag.Parse() diff --git a/x-ui.sh b/x-ui.sh index a94852f2..3ed344d0 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -19,7 +19,7 @@ function LOGI() { } # check root -[[ $EUID -ne 0 ]] && LOGE "ERROR: You must be root to run this script! \n" && exit 1 +[[ $EUID -ne 0 ]] && LOGE "错误:您必须是 root 用户才能运行此脚本! \n" && exit 1 # Check OS and set release variable if [[ -f /etc/os-release ]]; then @@ -29,45 +29,45 @@ elif [[ -f /usr/lib/os-release ]]; then source /usr/lib/os-release release=$ID else - echo "Failed to check the system OS, please contact the author!" >&2 + echo "检查系统操作系统失败,请联系作者!" >&2 exit 1 fi -echo "The OS release is: $release" +echo "操作系统版本是: $release" os_version="" os_version=$(grep -i version_id /etc/os-release | cut -d \" -f2 | cut -d . -f1) if [[ "${release}" == "centos" ]]; then if [[ ${os_version} -lt 8 ]]; then - echo -e "${red} Please use CentOS 8 or higher ${plain}\n" && exit 1 + echo -e "${red} 请使用 CentOS 8 或更高版本 ${plain}\n" && exit 1 fi elif [[ "${release}" == "ubuntu" ]]; then if [[ ${os_version} -lt 20 ]]; then - echo -e "${red}please use Ubuntu 20 or higher version! ${plain}\n" && exit 1 + echo -e "${red}请使用 Ubuntu 20 或更高版本! ${plain}\n" && exit 1 fi elif [[ "${release}" == "fedora" ]]; then if [[ ${os_version} -lt 36 ]]; then - echo -e "${red}please use Fedora 36 or higher version! ${plain}\n" && exit 1 + echo -e "${red}请使用 Fedora 36 或更高版本! ${plain}\n" && exit 1 fi elif [[ "${release}" == "debian" ]]; then if [[ ${os_version} -lt 11 ]]; then - echo -e "${red} Please use Debian 11 or higher ${plain}\n" && exit 1 + echo -e "${red} 请使用 Debian 11 或更高版本 ${plain}\n" && exit 1 fi elif [[ "${release}" == "almalinux" ]]; then if [[ ${os_version} -lt 9 ]]; then - echo -e "${red} Please use Almalinux 9 or higher ${plain}\n" && exit 1 + echo -e "${red} 请使用 Almalinux 9 或更高版本 ${plain}\n" && exit 1 fi elif [[ "${release}" == "rocky" ]]; then if [[ ${os_version} -lt 9 ]]; then - echo -e "${red} Please use Rockylinux 9 or higher ${plain}\n" && exit 1 + echo -e "${red} 请使用 Rockylinux 9 或更高版本 ${plain}\n" && exit 1 fi elif [[ "${release}" == "arch" ]]; then - echo "Your OS is ArchLinux" + echo "你的操作系统是 ArchLinux" elif [[ "${release}" == "manjaro" ]]; then - echo "Your OS is Manjaro" + echo "您的操作系统是 Manjaro" elif [[ "${release}" == "armbian" ]]; then - echo "Your OS is Armbian" + echo "您的操作系统是 Armbian" fi # Declare Variables @@ -92,7 +92,7 @@ confirm() { } confirm_restart() { - confirm "Restart the panel, Attention: Restarting the panel will also restart xray" "y" + confirm "重新启动面板,注意:重新启动面板也会重新启动 xray" "y" if [[ $? == 0 ]]; then restart else @@ -101,7 +101,7 @@ confirm_restart() { } before_show_menu() { - echo && echo -n -e "${yellow}Press enter to return to the main menu: ${plain}" && read temp + echo && echo -n -e "${yellow}按回车键返回主菜单: ${plain}" && read temp show_menu } @@ -117,7 +117,7 @@ install() { } update() { - confirm "This function will forcefully reinstall the latest version, and the data will not be lost. Do you want to continue?" "y" + confirm "此功能将强制重新安装最新版本,并且不会丢失数据。是否要继续?" "y" if [[ $? != 0 ]]; then LOGE "Cancelled" if [[ $# == 0 ]]; then @@ -125,28 +125,28 @@ update() { fi return 0 fi - bash <(curl -Ls https://raw.githubusercontent.com/MHSanaei/3x-ui/main/install.sh) + bash <(curl -Ls https://raw.githubusercontent.com/jiulingyun/3x-ui/tree/dev/install.sh) if [[ $? == 0 ]]; then - LOGI "Update is complete, Panel has automatically restarted " + LOGI "更新完成,面板已自动重启" exit 0 fi } custom_version() { - echo "Enter the panel version (like 2.0.0):" + echo "输入面板版本(如 2.0.0):" read panel_version if [ -z "$panel_version" ]; then - echo "Panel version cannot be empty. Exiting." + echo "面板版本不能为空。退出。" exit 1 fi - download_link="https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh" + download_link="https://raw.githubusercontent.com/jiulingyun/3x-ui/tree/dev/install.sh" # Use the entered panel version in the download link install_command="bash <(curl -Ls $download_link) v$panel_version" - echo "Downloading and installing panel version $panel_version..." + echo "下载和安装面板版本 $panel_version..." eval $install_command } @@ -157,7 +157,7 @@ delete_script() { } uninstall() { - confirm "Are you sure you want to uninstall the panel? xray will also uninstalled!" "n" + confirm "您确定要卸载面板吗?Xray也将卸载!" "n" if [[ $? != 0 ]]; then if [[ $# == 0 ]]; then show_menu @@ -173,9 +173,9 @@ uninstall() { rm /usr/local/x-ui/ -rf echo "" - echo -e "Uninstalled Successfully.\n" - echo "If you need to install this panel again, you can use below command:" - echo -e "${green}bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh)${plain}" + echo -e "已成功卸载。\n" + echo "如果需要再次安装此面板,可以使用以下命令:" + echo -e "${green}bash <(curl -Ls https://raw.githubusercontent.com/jiulingyun/3x-ui/tree/dev/install.sh)${plain}" echo "" # Trap the SIGTERM signal trap delete_script SIGTERM @@ -183,28 +183,28 @@ uninstall() { } reset_user() { - confirm "Are you sure to reset the username and password of the panel?" "n" + confirm "您确定要重置面板的用户名和密码吗?" "n" if [[ $? != 0 ]]; then if [[ $# == 0 ]]; then show_menu fi return 0 fi - read -rp "Please set the login username [default is a random username]: " config_account + read -rp "请设置登录用户名[默认为随机用户名]: " config_account [[ -z $config_account ]] && config_account=$(date +%s%N | md5sum | cut -c 1-8) - read -rp "Please set the login password [default is a random password]: " config_password + read -rp "请设置登录密码[默认为随机密码]: " config_password [[ -z $config_password ]] && config_password=$(date +%s%N | md5sum | cut -c 1-8) /usr/local/x-ui/x-ui setting -username ${config_account} -password ${config_password} >/dev/null 2>&1 /usr/local/x-ui/x-ui setting -remove_secret >/dev/null 2>&1 - echo -e "Panel login username has been reset to: ${green} ${config_account} ${plain}" - echo -e "Panel login password has been reset to: ${green} ${config_password} ${plain}" - echo -e "${yellow} Panel login secret token disabled ${plain}" - echo -e "${green} Please use the new login username and password to access the X-UI panel. Also remember them! ${plain}" + echo -e "面板登录用户名已重置为: ${green} ${config_account} ${plain}" + echo -e "面板登录密码已重置为: ${green} ${config_password} ${plain}" + echo -e "${yellow} 面板登录密钥令牌已禁用 ${plain}" + echo -e "${green} 请使用新的登录用户名和密码访问 X-UI 面板。 ${plain}" confirm_restart } reset_config() { - confirm "Are you sure you want to reset all panel settings, Account data will not be lost, Username and password will not change" "n" + confirm "您确定要重置所有面板设置吗,帐户数据不会丢失,用户名和密码不会更改" "n" if [[ $? != 0 ]]; then if [[ $# == 0 ]]; then show_menu @@ -212,27 +212,27 @@ reset_config() { return 0 fi /usr/local/x-ui/x-ui setting -reset - echo -e "All panel settings have been reset to default, Please restart the panel now, and use the default ${green}2053${plain} Port to Access the web Panel" + echo -e "所有面板设置均已重置为默认值,请立即重启面板,并使用默认的 ${green}2053${plain} 端口访问 web 面板" confirm_restart } check_config() { info=$(/usr/local/x-ui/x-ui setting -show true) if [[ $? != 0 ]]; then - LOGE "get current settings error, please check logs" + LOGE "获取当前设置错误,请检查日志" show_menu fi LOGI "${info}" } set_port() { - echo && echo -n -e "Enter port number[1-65535]: " && read port + echo && echo -n -e "输入端口号[1-65535]: " && read port if [[ -z "${port}" ]]; then LOGD "Cancelled" before_show_menu else /usr/local/x-ui/x-ui setting -port ${port} - echo -e "The port is set, Please restart the panel now, and use the new port ${green}${port}${plain} to access web panel" + echo -e "端口已设置,请立即重启面板,并使用新端口 ${green}${port}${plain} to access web panel" confirm_restart fi } @@ -241,15 +241,15 @@ start() { check_status if [[ $? == 0 ]]; then echo "" - LOGI "Panel is running, No need to start again, If you need to restart, please select restart" + LOGI "面板正在运行,无需重启,如需重启请选择重启" else systemctl start x-ui sleep 2 check_status if [[ $? == 0 ]]; then - LOGI "x-ui Started Successfully" + LOGI "x-ui 启动成功" else - LOGE "panel Failed to start, Probably because it takes longer than two seconds to start, Please check the log information later" + LOGE "面板启动失败,可能是因为启动时间超过两秒,请稍后查看日志信息" fi fi @@ -262,15 +262,15 @@ stop() { check_status if [[ $? == 1 ]]; then echo "" - LOGI "Panel stopped, No need to stop again!" + LOGI "面板停止了,无需再次停止!" else systemctl stop x-ui sleep 2 check_status if [[ $? == 1 ]]; then - LOGI "x-ui and xray stopped successfully" + LOGI "X-UI 和 Xray 已成功停止" else - LOGE "Panel stop failed, Probably because the stop time exceeds two seconds, Please check the log information later" + LOGE "面板停止失败,可能是因为停止时间超过两秒,请稍后查看日志信息!" fi fi @@ -284,9 +284,9 @@ restart() { sleep 2 check_status if [[ $? == 0 ]]; then - LOGI "x-ui and xray Restarted successfully" + LOGI "x-ui 和 xray 已成功重新启动" else - LOGE "Panel restart failed, Probably because it takes longer than two seconds to start, Please check the log information later" + LOGE "面板重启失败,可能是因为启动时间超过两秒,请稍后查看日志信息" fi if [[ $# == 0 ]]; then before_show_menu @@ -303,9 +303,9 @@ status() { enable() { systemctl enable x-ui if [[ $? == 0 ]]; then - LOGI "x-ui Set to boot automatically on startup successfully" + LOGI "x-ui 成功设置开机自启" else - LOGE "x-ui Failed to set Autostart" + LOGE "x-ui 设置开启自启失败" fi if [[ $# == 0 ]]; then @@ -316,9 +316,9 @@ enable() { disable() { systemctl disable x-ui if [[ $? == 0 ]]; then - LOGI "x-ui Autostart Cancelled successfully" + LOGI "x-ui 开机自启已成功取消" else - LOGE "x-ui Failed to cancel autostart" + LOGE "x-ui 开启自启取消失败" fi if [[ $# == 0 ]]; then @@ -338,18 +338,18 @@ show_banlog() { if [[ -s "${iplimit_banned_log_path}" ]]; then cat ${iplimit_banned_log_path} else - echo -e "${red}Log file is empty.${plain}\n" + echo -e "${red}日志文件为空。${plain}\n" fi else - echo -e "${red}Log file not found. Please Install Fail2ban and IP Limit first.${plain}\n" + echo -e "${red}未找到日志文件。请先安装 Fail2ban 和 IP Limit。${plain}\n" fi } bbr_menu() { - echo -e "${green}\t1.${plain} Enable BBR" - echo -e "${green}\t2.${plain} Disable BBR" - echo -e "${green}\t0.${plain} Back to Main Menu" - read -p "Choose an option: " choice + echo -e "${green}\t1.${plain} 启用 BBR" + echo -e "${green}\t2.${plain} 禁用 BBR" + echo -e "${green}\t0.${plain} 返回主菜单" + read -p "选择一个选项: " choice case "$choice" in 0) show_menu @@ -360,14 +360,14 @@ bbr_menu() { 2) disable_bbr ;; - *) echo "Invalid choice" ;; + *) echo "无效选择" ;; esac } disable_bbr() { if ! grep -q "net.core.default_qdisc=fq" /etc/sysctl.conf || ! grep -q "net.ipv4.tcp_congestion_control=bbr" /etc/sysctl.conf; then - echo -e "${yellow}BBR is not currently enabled.${plain}" + echo -e "${yellow}BBR 当前未启用。${plain}" exit 0 fi @@ -380,15 +380,15 @@ disable_bbr() { # Verify that BBR is replaced with CUBIC if [[ $(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}') == "cubic" ]]; then - echo -e "${green}BBR has been replaced with CUBIC successfully.${plain}" + echo -e "${green}BBR 已成功替换为 CUBIC。${plain}" else - echo -e "${red}Failed to replace BBR with CUBIC. Please check your system configuration.${plain}" + echo -e "${red}无法将 BBR 替换为 CUBIC。请检查您的系统配置。${plain}" fi } enable_bbr() { if grep -q "net.core.default_qdisc=fq" /etc/sysctl.conf && grep -q "net.ipv4.tcp_congestion_control=bbr" /etc/sysctl.conf; then - echo -e "${green}BBR is already enabled!${plain}" + echo -e "${green}BBR 已启用!${plain}" exit 0 fi @@ -404,7 +404,7 @@ enable_bbr() { dnf -y update && dnf -y install ca-certificates ;; *) - echo -e "${red}Unsupported operating system. Please check the script and install the necessary packages manually.${plain}\n" + echo -e "${red}不支持的操作系统。请检查脚本并手动安装必要的软件包。${plain}\n" exit 1 ;; esac @@ -418,21 +418,21 @@ enable_bbr() { # Verify that BBR is enabled if [[ $(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}') == "bbr" ]]; then - echo -e "${green}BBR has been enabled successfully.${plain}" + echo -e "${green}BBR 已成功启用。${plain}" else - echo -e "${red}Failed to enable BBR. Please check your system configuration.${plain}" + echo -e "${red}无法启用 BBR。请检查您的系统配置。${plain}" fi } update_shell() { - wget -O /usr/bin/x-ui -N --no-check-certificate https://github.com/MHSanaei/3x-ui/raw/main/x-ui.sh + wget -O /usr/bin/x-ui -N --no-check-certificate https://github.com/jiulingyun/3x-ui/tree/dev/x-ui.sh if [[ $? != 0 ]]; then echo "" - LOGE "Failed to download script, Please check whether the machine can connect Github" + LOGE "下载脚本失败,请检查机器是否可以连接Github" before_show_menu else chmod +x /usr/bin/x-ui - LOGI "Upgrade script succeeded, Please rerun the script" && exit 0 + LOGI "升级脚本成功,请重新运行脚本" && exit 0 fi } @@ -462,7 +462,7 @@ check_uninstall() { check_status if [[ $? != 2 ]]; then echo "" - LOGE "Panel installed, Please do not reinstall" + LOGE "面板已安装,请不要重新安装" if [[ $# == 0 ]]; then before_show_menu fi @@ -476,7 +476,7 @@ check_install() { check_status if [[ $? == 2 ]]; then echo "" - LOGE "Please install the panel first" + LOGE "请先安装面板" if [[ $# == 0 ]]; then before_show_menu fi @@ -490,15 +490,15 @@ show_status() { check_status case $? in 0) - echo -e "Panel state: ${green}Running${plain}" + echo -e "面板状态: ${green}运行中${plain}" show_enable_status ;; 1) - echo -e "Panel state: ${yellow}Not Running${plain}" + echo -e "面板状态: ${yellow}未运行${plain}" show_enable_status ;; 2) - echo -e "Panel state: ${red}Not Installed${plain}" + echo -e "面板状态: ${red}未安装${plain}" ;; esac show_xray_status @@ -507,9 +507,9 @@ show_status() { show_enable_status() { check_enabled if [[ $? == 0 ]]; then - echo -e "Start automatically: ${green}Yes${plain}" + echo -e "开机自启: ${green}Yes${plain}" else - echo -e "Start automatically: ${red}No${plain}" + echo -e "开机自启: ${red}No${plain}" fi } @@ -525,19 +525,19 @@ check_xray_status() { show_xray_status() { check_xray_status if [[ $? == 0 ]]; then - echo -e "xray state: ${green}Running${plain}" + echo -e "xray 状态: ${green}运行中${plain}" else - echo -e "xray state: ${red}Not Running${plain}" + echo -e "xray 状态: ${red}未运行${plain}" fi } firewall_menu() { - echo -e "${green}\t1.${plain} Install Firewall & open ports" - echo -e "${green}\t2.${plain} Allowed List" - echo -e "${green}\t3.${plain} Delete Ports from List" - echo -e "${green}\t4.${plain} Disable Firewall" - echo -e "${green}\t0.${plain} Back to Main Menu" - read -p "Choose an option: " choice + echo -e "${green}\t1.${plain} 安装防火墙并打开端口" + echo -e "${green}\t2.${plain} 允许列表" + echo -e "${green}\t3.${plain} 从列表中删除端口" + echo -e "${green}\t4.${plain} 禁用防火墙" + echo -e "${green}\t0.${plain} 返回主菜单" + read -p "选择一个选项: " choice case "$choice" in 0) show_menu @@ -554,22 +554,22 @@ firewall_menu() { 4) sudo ufw disable ;; - *) echo "Invalid choice" ;; + *) echo "无效选择" ;; esac } open_ports() { if ! command -v ufw &>/dev/null; then - echo "ufw firewall is not installed. Installing now..." + echo "未安装 UFW 防火墙。正在安装..." apt-get update apt-get install -y ufw else - echo "ufw firewall is already installed" + echo "已安装 UFW 防火墙" fi # Check if the firewall is inactive if ufw status | grep -q "Status: active"; then - echo "firewall is already active" + echo "防火墙已处于活动状态" else # Open the necessary ports ufw allow ssh @@ -582,11 +582,11 @@ open_ports() { fi # Prompt the user to enter a list of ports - read -p "Enter the ports you want to open (e.g. 80,443,2053 or range 400-500): " ports + read -p "输入要打开的端口(例如 80,443,2053 或范围 400-500): " ports # Check if the input is valid if ! [[ $ports =~ ^([0-9]+|[0-9]+-[0-9]+)(,([0-9]+|[0-9]+-[0-9]+))*$ ]]; then - echo "Error: Invalid input. Please enter a comma-separated list of ports or a range of ports (e.g. 80,443,2053 or 400-500)." >&2 + echo "错误:输入无效。请输入以逗号分隔的端口列表或端口范围(例如 80,443,2053 或 400-500)。" >&2 exit 1 fi @@ -612,11 +612,11 @@ open_ports() { delete_ports() { # Prompt the user to enter the ports they want to delete - read -p "Enter the ports you want to delete (e.g. 80,443,2053 or range 400-500): " ports + read -p "输入要删除的端口(例如 80,443,2053 或范围 400-500):" ports # Check if the input is valid if ! [[ $ports =~ ^([0-9]+|[0-9]+-[0-9]+)(,([0-9]+|[0-9]+-[0-9]+))*$ ]]; then - echo "Error: Invalid input. Please enter a comma-separated list of ports or a range of ports (e.g. 80,443,2053 or 400-500)." >&2 + echo "错误:输入无效。请输入以逗号分隔的端口列表或端口范围(例如 80,443,2053 或 400-500)。" >&2 exit 1 fi @@ -637,13 +637,13 @@ delete_ports() { done # Confirm that the ports are deleted - echo "Deleted the specified ports:" + echo "删除了指定的端口:" ufw status | grep $ports } update_geo() { local defaultBinFolder="/usr/local/x-ui/bin" - read -p "Please enter x-ui bin folder path. Leave blank for default. (Default: '${defaultBinFolder}')" binFolder + read -p "请输入 x-ui bin 文件夹路径。默认值留空。(默认值:'${defaultBinFolder}')" binFolder binFolder=${binFolder:-${defaultBinFolder}} if [[ ! -d ${binFolder} ]]; then LOGE "Folder ${binFolder} not exists!" @@ -661,29 +661,29 @@ update_geo() { wget -O geoip_VN.dat https://github.com/vuong2023/vn-v2ray-rules/releases/latest/download/geoip.dat wget -O geosite_VN.dat https://github.com/vuong2023/vn-v2ray-rules/releases/latest/download/geosite.dat systemctl start x-ui - echo -e "${green}Geosite.dat + Geoip.dat + geoip_IR.dat + geosite_IR.dat have been updated successfully in bin folder '${binfolder}'!${plain}" + echo -e "${green}Geosite.dat + Geoip.dat + geoip_IR.dat + geosite_IR.dat已在bin文件夹中成功更新'${binfolder}'!${plain}" before_show_menu } install_acme() { cd ~ - LOGI "install acme..." + LOGI "安装 证书工具..." curl https://get.acme.sh | sh if [ $? -ne 0 ]; then - LOGE "install acme failed" + LOGE "安装 证书工具 失败" return 1 else - LOGI "install acme succeed" + LOGI "安装 证书工具 成功" fi return 0 } ssl_cert_issue_main() { - echo -e "${green}\t1.${plain} Get SSL" - echo -e "${green}\t2.${plain} Revoke" - echo -e "${green}\t3.${plain} Force Renew" - echo -e "${green}\t0.${plain} Back to Main Menu" - read -p "Choose an option: " choice + echo -e "${green}\t1.${plain} 获取 SSL" + echo -e "${green}\t2.${plain} 撤回" + echo -e "${green}\t3.${plain} 强制续期" + echo -e "${green}\t0.${plain} 返回主菜单" + read -p "根据需要选择操作步骤:" choice case "$choice" in 0) show_menu @@ -693,26 +693,26 @@ ssl_cert_issue_main() { ;; 2) local domain="" - read -p "Please enter your domain name to revoke the certificate: " domain + read -p "请输入您的域名以吊销证书:" domain ~/.acme.sh/acme.sh --revoke -d ${domain} - LOGI "Certificate revoked" + LOGI "证书已吊销" ;; 3) local domain="" - read -p "Please enter your domain name to forcefully renew an SSL certificate: " domain + read -p "请输入您的域名以强制续订SSL证书:" domain ~/.acme.sh/acme.sh --renew -d ${domain} --force ;; - *) echo "Invalid choice" ;; + *) echo "无效选择" ;; esac } ssl_cert_issue() { # check for acme.sh first if ! command -v ~/.acme.sh/acme.sh &>/dev/null; then - echo "acme.sh could not be found. we will install it" + echo "acme.sh 无法找到。正在安装..." install_acme if [ $? -ne 0 ]; then - LOGE "install acme failed, please check logs" + LOGE "安装 证书工具 失败,请查看日志" exit 1 fi fi @@ -728,31 +728,31 @@ ssl_cert_issue() { dnf -y update && dnf -y install socat ;; *) - echo -e "${red}Unsupported operating system. Please check the script and install the necessary packages manually.${plain}\n" + echo -e "${red}不支持的操作系统。请检查脚本并手动安装必要的软件包。${plain}\n" exit 1 ;; esac if [ $? -ne 0 ]; then - LOGE "install socat failed, please check logs" + LOGE "安装 socat 失败,请检查日志" exit 1 else - LOGI "install socat succeed..." + LOGI "安装 socat 成功..." fi # get the domain here,and we need verify it local domain="" - read -p "Please enter your domain name:" domain - LOGD "your domain is:${domain},check it..." + read -p "请输入您的域名:" domain + LOGD "你的域名是:${domain},检查一下..." # here we need to judge whether there exists cert already local currentCert=$(~/.acme.sh/acme.sh --list | tail -1 | awk '{print $1}') if [ ${currentCert} == ${domain} ]; then local certInfo=$(~/.acme.sh/acme.sh --list) - LOGE "system already has certs here,can not issue again,current certs details:" + LOGE "系统这里已经有证书,不能再次颁发,当前证书详情:" LOGI "$certInfo" exit 1 else - LOGI "your domain is ready for issuing cert now..." + LOGI "您的域现在已准备好颁发证书..." fi # create a directory for install cert @@ -766,21 +766,21 @@ ssl_cert_issue() { # get needed port here local WebPort=80 - read -p "please choose which port do you use,default will be 80 port:" WebPort + read -p "请选择您使用的端口,默认为 80 端口:" WebPort if [[ ${WebPort} -gt 65535 || ${WebPort} -lt 1 ]]; then - LOGE "your input ${WebPort} is invalid,will use default port" + LOGE "您的输入 ${WebPort} 无效,将使用默认端口" fi - LOGI "will use port:${WebPort} to issue certs,please make sure this port is open..." + LOGI "将使用 端口:${WebPort} 颁发证书,请确保此端口已打开..." # NOTE:This should be handled by user # open the port and kill the occupied progress ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt ~/.acme.sh/acme.sh --issue -d ${domain} --standalone --httpport ${WebPort} if [ $? -ne 0 ]; then - LOGE "issue certs failed,please check logs" + LOGE "申请证书失败,请检查日志" rm -rf ~/.acme.sh/${domain} exit 1 else - LOGE "issue certs succeed,installing certs..." + LOGE "颁发证书成功,安装证书..." fi # install cert ~/.acme.sh/acme.sh --installcert -d ${domain} \ @@ -788,21 +788,21 @@ ssl_cert_issue() { --fullchain-file /root/cert/${domain}/fullchain.pem if [ $? -ne 0 ]; then - LOGE "install certs failed,exit" + LOGE "安装证书失败,退出" rm -rf ~/.acme.sh/${domain} exit 1 else - LOGI "install certs succeed,enable auto renew..." + LOGI "安装证书成功,启用自动续订..." fi ~/.acme.sh/acme.sh --upgrade --auto-upgrade if [ $? -ne 0 ]; then - LOGE "auto renew failed, certs details:" + LOGE "自动续订失败,证书详细信息:" ls -lah cert/* chmod 755 $certPath/* exit 1 else - LOGI "auto renew succeed, certs details:" + LOGI "自动续订成功,证书详细信息:" ls -lah cert/* chmod 755 $certPath/* fi @@ -810,20 +810,20 @@ ssl_cert_issue() { ssl_cert_issue_CF() { echo -E "" - LOGD "******Instructions for use******" - LOGI "This Acme script requires the following data:" - LOGI "1.Cloudflare Registered e-mail" - LOGI "2.Cloudflare Global API Key" - LOGI "3.The domain name that has been resolved dns to the current server by Cloudflare" - LOGI "4.The script applies for a certificate. The default installation path is /root/cert " - confirm "Confirmed?[y/n]" "y" + LOGD "******使用说明******" + LOGI "此 Acme 脚本需要以下数据:" + LOGI "1.Cloudflare注册的邮箱" + LOGI "2.Cloudflare 全球 API 密钥" + LOGI "3.Cloudflare 已将 dns 解析到当前服务器的域名" + LOGI "4.该脚本适用于证书。默认安装路径为 /root/cert " + confirm "确认继续?[y/n]" "y" if [ $? -eq 0 ]; then # check for acme.sh first if ! command -v ~/.acme.sh/acme.sh &>/dev/null; then - echo "acme.sh could not be found. we will install it" + echo "acme.sh 无法找到。正在安装中..." install_acme if [ $? -ne 0 ]; then - LOGE "install acme failed, please check logs" + LOGE "安装 acme.sh 失败,请查看日志" exit 1 fi fi @@ -837,46 +837,46 @@ ssl_cert_issue_CF() { rm -rf $certPath mkdir $certPath fi - LOGD "Please set a domain name:" - read -p "Input your domain here:" CF_Domain - LOGD "Your domain name is set to:${CF_Domain}" - LOGD "Please set the API key:" - read -p "Input your key here:" CF_GlobalKey - LOGD "Your API key is:${CF_GlobalKey}" - LOGD "Please set up registered email:" - read -p "Input your email here:" CF_AccountEmail - LOGD "Your registered email address is:${CF_AccountEmail}" + LOGD "请设置域名:" + read -p "在此输入您的域名:" CF_Domain + LOGD "您的域名设置为:${CF_Domain}" + LOGD "请设置 API 密钥:" + read -p "在此处输入您的密钥:" CF_GlobalKey + LOGD "您的 API 密钥是:${CF_GlobalKey}" + LOGD "请设置邮箱:" + read -p "在此输入您的邮箱:" CF_AccountEmail + LOGD "您注册的电子邮件地址是:${CF_AccountEmail}" ~/.acme.sh/acme.sh --set-default-ca --server letsencrypt if [ $? -ne 0 ]; then - LOGE "Default CA, Lets'Encrypt fail, script exiting..." + LOGE "默认 CA,Lets'Encrypt 失败,脚本退出..." exit 1 fi export CF_Key="${CF_GlobalKey}" export CF_Email=${CF_AccountEmail} ~/.acme.sh/acme.sh --issue --dns dns_cf -d ${CF_Domain} -d *.${CF_Domain} --log if [ $? -ne 0 ]; then - LOGE "Certificate issuance failed, script exiting..." + LOGE "证书颁发失败,脚本正在退出..." exit 1 else - LOGI "Certificate issued Successfully, Installing..." + LOGI "证书已成功颁发,正在安装..." fi ~/.acme.sh/acme.sh --installcert -d ${CF_Domain} -d *.${CF_Domain} --ca-file /root/cert/ca.cer \ --cert-file /root/cert/${CF_Domain}.cer --key-file /root/cert/${CF_Domain}.key \ --fullchain-file /root/cert/fullchain.cer if [ $? -ne 0 ]; then - LOGE "Certificate installation failed, script exiting..." + LOGE "证书安装失败,脚本正在退出..." exit 1 else - LOGI "Certificate installed Successfully,Turning on automatic updates..." + LOGI "证书安装成功,开启自动更新..." fi ~/.acme.sh/acme.sh --upgrade --auto-upgrade if [ $? -ne 0 ]; then - LOGE "Auto update setup Failed, script exiting..." + LOGE "自动更新设置失败,脚本正在退出..." ls -lah cert chmod 755 $certPath exit 1 else - LOGI "The certificate is installed and auto-renewal is turned on, Specific information is as follows" + LOGI "证书已安装并开启自动续期,具体信息如下" ls -lah cert chmod 755 $certPath fi @@ -886,12 +886,12 @@ ssl_cert_issue_CF() { } warp_cloudflare() { - echo -e "${green}\t1.${plain} Install WARP socks5 proxy" - echo -e "${green}\t2.${plain} Account Type (free, plus, team)" - echo -e "${green}\t3.${plain} Turn on/off WireProxy" - echo -e "${green}\t4.${plain} Uninstall WARP" - echo -e "${green}\t0.${plain} Back to Main Menu" - read -p "Choose an option: " choice + echo -e "${green}\t1.${plain} 安装 WARP socks5 代理" + echo -e "${green}\t2.${plain} 账户类型 (free, plus, team)" + echo -e "${green}\t3.${plain} 打开/关闭 WireProxy" + echo -e "${green}\t4.${plain} 卸载 WARP" + echo -e "${green}\t0.${plain} 返回主菜单" + read -p "根据需要选择操作步骤:" choice case "$choice" in 0) show_menu @@ -908,7 +908,7 @@ warp_cloudflare() { 4) warp u ;; - *) echo "Invalid choice" ;; + *) echo "无效选择" ;; esac } @@ -934,7 +934,7 @@ run_speedtest() { fi if [[ -z $pkg_manager ]]; then - echo "Error: Package manager not found. You may need to install Speedtest manually." + echo "错误:找不到包管理器。您可能需要手动安装 Speedtest。" return 1 else curl -s $speedtest_install_script | bash @@ -1020,20 +1020,20 @@ iplimit_remove_conflicts() { } iplimit_main() { - echo -e "\n${green}\t1.${plain} Install Fail2ban and configure IP Limit" - echo -e "${green}\t2.${plain} Change Ban Duration" - echo -e "${green}\t3.${plain} Unban Everyone" - echo -e "${green}\t4.${plain} Check Logs" - echo -e "${green}\t5.${plain} fail2ban status" - echo -e "${green}\t6.${plain} Uninstall IP Limit" - echo -e "${green}\t0.${plain} Back to Main Menu" - read -p "Choose an option: " choice + echo -e "\n${green}\t1.${plain} 安装 Fail2ban 并配置 IP 限制" + echo -e "${green}\t2.${plain} 更改禁令持续时间" + echo -e "${green}\t3.${plain} 取消对所有IP的禁止" + echo -e "${green}\t4.${plain} 检查日志" + echo -e "${green}\t5.${plain} fail2ban 状态" + echo -e "${green}\t6.${plain} 卸载 IP 限制" + echo -e "${green}\t0.${plain} 返回主菜单" + read -p "根据需要选择操作步骤:" choice case "$choice" in 0) show_menu ;; 1) - confirm "Proceed with installation of Fail2ban & IP Limit?" "y" + confirm "继续安装Fail2ban和IP Limit?" "y" if [[ $? == 0 ]]; then install_iplimit else @@ -1041,24 +1041,24 @@ iplimit_main() { fi ;; 2) - read -rp "Please enter new Ban Duration in Minutes [default 30]: " NUM + read -rp "请输入新的封禁持续时间(分钟数)[默认 30]: " NUM if [[ $NUM =~ ^[0-9]+$ ]]; then create_iplimit_jails ${NUM} systemctl restart fail2ban else - echo -e "${red}${NUM} is not a number! Please, try again.${plain}" + echo -e "${red}${NUM} 不是一个数字!请再试一次。${plain}" fi iplimit_main ;; 3) - confirm "Proceed with Unbanning everyone from IP Limit jail?" "y" + confirm "继续从 IP 限制中解禁所有人?" "y" if [[ $? == 0 ]]; then fail2ban-client reload --restart --unban 3x-ipl truncate -s 0 "${iplimit_banned_log_path}" - echo -e "${green}All users Unbanned successfully.${plain}" + echo -e "${green}所有用户成功解禁。${plain}" iplimit_main else - echo -e "${yellow}Cancelled.${plain}" + echo -e "${yellow}取消.${plain}" fi iplimit_main ;; @@ -1072,13 +1072,13 @@ iplimit_main() { 6) remove_iplimit ;; - *) echo "Invalid choice" ;; + *) echo "无效选择" ;; esac } install_iplimit() { if ! command -v fail2ban-client &>/dev/null; then - echo -e "${green}Fail2ban is not installed. Installing now...!${plain}\n" + echo -e "${green}未安装 Fail2ban。正在安装...!${plain}\n" # Check the OS and install necessary packages case "${release}" in @@ -1093,22 +1093,22 @@ install_iplimit() { dnf -y update && dnf -y install fail2ban ;; *) - echo -e "${red}Unsupported operating system. Please check the script and install the necessary packages manually.${plain}\n" + echo -e "${red}不支持的操作系统。请检查脚本并手动安装必要的软件包。${plain}\n" exit 1 ;; esac if ! command -v fail2ban-client &>/dev/null; then - echo -e "${red}Fail2ban installation failed.${plain}\n" + echo -e "${red}Fail2ban 安装失败。${plain}\n" exit 1 fi - echo -e "${green}Fail2ban installed successfully!${plain}\n" + echo -e "${green}Fail2ban 安装成功!${plain}\n" else - echo -e "${yellow}Fail2ban is already installed.${plain}\n" + echo -e "${yellow}已安装 Fail2ban。${plain}\n" fi - echo -e "${green}Configuring IP Limit...${plain}\n" + echo -e "${green}正在配置 IP 限制...${plain}\n" # make sure there's no conflict for jail files iplimit_remove_conflicts @@ -1136,22 +1136,22 @@ install_iplimit() { fi systemctl enable fail2ban - echo -e "${green}IP Limit installed and configured successfully!${plain}\n" + echo -e "${green}IP Limit 安装并配置成功!${plain}\n" before_show_menu } remove_iplimit() { - echo -e "${green}\t1.${plain} Only remove IP Limit configurations" - echo -e "${green}\t2.${plain} Uninstall Fail2ban and IP Limit" - echo -e "${green}\t0.${plain} Abort" - read -p "Choose an option: " num + echo -e "${green}\t1.${plain} 仅删除 IP 限制配置" + echo -e "${green}\t2.${plain} 卸载 Fail2ban 和 IP Limit" + echo -e "${green}\t0.${plain} 终止" + read -p "根据需要选择操作步骤: " num case "$num" in 1) rm -f /etc/fail2ban/filter.d/3x-ipl.conf rm -f /etc/fail2ban/action.d/3x-ipl.conf rm -f /etc/fail2ban/jail.d/3x-ipl.conf systemctl restart fail2ban - echo -e "${green}IP Limit removed successfully!${plain}\n" + echo -e "${green}IP Limit已成功删除!${plain}\n" before_show_menu ;; 2) @@ -1172,78 +1172,78 @@ remove_iplimit() { dnf autoremove -y ;; *) - echo -e "${red}Unsupported operating system. Please uninstall Fail2ban manually.${plain}\n" + echo -e "${red}不支持的操作系统。请手动卸载 Fail2ban。${plain}\n" exit 1 ;; esac - echo -e "${green}Fail2ban and IP Limit removed successfully!${plain}\n" + echo -e "${green}Fail2ban 和 IP Limit已成功删除!${plain}\n" before_show_menu ;; 0) - echo -e "${yellow}Cancelled.${plain}\n" + echo -e "${yellow}取消.${plain}\n" iplimit_main ;; *) - echo -e "${red}Invalid option. Please select a valid number.${plain}\n" + echo -e "${red}无效的选项。请选择一个有效数字${plain}\n" remove_iplimit ;; esac } show_usage() { - echo "x-ui control menu usages: " + echo "X-UI 控件菜单: " echo "------------------------------------------" - echo -e "x-ui - Enter control menu" - echo -e "x-ui start - Start x-ui " - echo -e "x-ui stop - Stop x-ui " - echo -e "x-ui restart - Restart x-ui " - echo -e "x-ui status - Show x-ui status" - echo -e "x-ui enable - Enable x-ui on system startup" - echo -e "x-ui disable - Disable x-ui on system startup" - echo -e "x-ui log - Check x-ui logs" - echo -e "x-ui banlog - Check Fail2ban ban logs" - echo -e "x-ui update - Update x-ui " - echo -e "x-ui install - Install x-ui " - echo -e "x-ui uninstall - Uninstall x-ui " + echo -e "x-ui - 进入控制菜单" + echo -e "x-ui start - 启动 x-ui " + echo -e "x-ui stop - 停止 x-ui " + echo -e "x-ui restart - 重启 x-ui " + echo -e "x-ui status - 显示 x-ui 状态" + echo -e "x-ui enable - 设置 x-ui 开机自启" + echo -e "x-ui disable - 禁用 x-ui 开启自启" + echo -e "x-ui log - 查看 x-ui 日志" + echo -e "x-ui banlog - 查看 Fail2ban 封禁日志" + echo -e "x-ui update - 更新 x-ui " + echo -e "x-ui install - 安装 x-ui " + echo -e "x-ui uninstall - 卸载 x-ui " echo "------------------------------------------" } show_menu() { echo -e " - ${green}3X-ui Panel Management Script${plain} - ${green}0.${plain} Exit Script + ${green}3X-ui 面板管理脚本${plain} + ${green}0.${plain} 退出脚本 ———————————————— - ${green}1.${plain} Install - ${green}2.${plain} Update - ${green}3.${plain} Custom Version - ${green}4.${plain} Uninstall + ${green}1.${plain} 安装 + ${green}2.${plain} 更新 + ${green}3.${plain} 自定义版本 + ${green}4.${plain} 卸载 ———————————————— - ${green}5.${plain} Reset Username & Password & Secret Token - ${green}6.${plain} Reset Settings - ${green}7.${plain} Change Port - ${green}8.${plain} View Current Settings + ${green}5.${plain} 重置用户名 & 密码 & 密钥令牌 + ${green}6.${plain} 重置设置 + ${green}7.${plain} 更改端口 + ${green}8.${plain} 查看当前设置 ———————————————— - ${green}9.${plain} Start - ${green}10.${plain} Stop - ${green}11.${plain} Restart - ${green}12.${plain} Check Status - ${green}13.${plain} Check Logs + ${green}9.${plain} 启动 + ${green}10.${plain} 停止 + ${green}11.${plain} 重启 + ${green}12.${plain} 查看状态 + ${green}13.${plain} 查看日志 ———————————————— - ${green}14.${plain} Enable Autostart - ${green}15.${plain} Disable Autostart + ${green}14.${plain} 设置开启自启 + ${green}15.${plain} 禁用开机自启 ———————————————— - ${green}16.${plain} SSL Certificate Management - ${green}17.${plain} Cloudflare SSL Certificate - ${green}18.${plain} IP Limit Management - ${green}19.${plain} WARP Management - ${green}20.${plain} Firewall Management + ${green}16.${plain} SSL证书管理 + ${green}17.${plain} Cloudflare SSL证书 + ${green}18.${plain} IP Limit 管理 + ${green}19.${plain} WARP 管理 + ${green}20.${plain} Firewall 管理 ———————————————— - ${green}21.${plain} Enable BBR - ${green}22.${plain} Update Geo Files - ${green}23.${plain} Speedtest by Ookla + ${green}21.${plain} 启用 BBR + ${green}22.${plain} 更新 Geo 文件 + ${green}23.${plain} Ookla测速 " show_status - echo && read -p "Please enter your selection [0-23]: " num + echo && read -p "请输入您的选择 [0-23]:" num case "${num}" in 0) @@ -1319,7 +1319,7 @@ show_menu() { run_speedtest ;; *) - LOGE "Please enter the correct number [0-23]" + LOGE "请输入正确的号码 [0-23]" ;; esac }