diff --git a/.env.example b/.env.example index 32e437e5..696e6ce5 100644 --- a/.env.example +++ b/.env.example @@ -7,6 +7,7 @@ XUI_PANEL_DOMAIN="" XUI_SUB_DOMAIN="" XUI_VLESS_REALITY_SNI="" XUI_VLESS_GRPC_SNI="" +X_UI_ENABLE_FAIL2BAN="true" #XUI_SUB_PROFILE_TITLE="" #XUI_SUB_SUPPORT_URL="" #XUI_SUB_PROFILE_WEB_PAGE_URL="" diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index cb70d3ec..300ac10d 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -7,7 +7,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v4 @@ -31,6 +31,8 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 + with: + install: true - name: Login to Docker Hub uses: docker/login-action@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e2ce07ae..10615089 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,7 +72,7 @@ jobs: export GOARCH=s390x export CC=s390x-linux-gnu-gcc fi - go build -o xui-release -v main.go + go build -ldflags "-w -s" -o xui-release -v main.go mkdir x-ui cp xui-release x-ui/ @@ -83,43 +83,43 @@ jobs: cd x-ui/bin # Download dependencies - Xray_URL="https://github.com/XTLS/Xray-core/releases/download/v24.12.18/" + Xray_URL="https://github.com/XTLS/Xray-core/releases/download/v25.1.30/" if [ "${{ matrix.platform }}" == "amd64" ]; then - wget ${Xray_URL}Xray-linux-64.zip + wget -q ${Xray_URL}Xray-linux-64.zip unzip Xray-linux-64.zip rm -f Xray-linux-64.zip elif [ "${{ matrix.platform }}" == "arm64" ]; then - wget ${Xray_URL}Xray-linux-arm64-v8a.zip + wget -q ${Xray_URL}Xray-linux-arm64-v8a.zip unzip Xray-linux-arm64-v8a.zip rm -f Xray-linux-arm64-v8a.zip elif [ "${{ matrix.platform }}" == "armv7" ]; then - wget ${Xray_URL}Xray-linux-arm32-v7a.zip + wget -q ${Xray_URL}Xray-linux-arm32-v7a.zip unzip Xray-linux-arm32-v7a.zip rm -f Xray-linux-arm32-v7a.zip elif [ "${{ matrix.platform }}" == "armv6" ]; then - wget ${Xray_URL}Xray-linux-arm32-v6.zip + wget -q ${Xray_URL}Xray-linux-arm32-v6.zip unzip Xray-linux-arm32-v6.zip rm -f Xray-linux-arm32-v6.zip elif [ "${{ matrix.platform }}" == "386" ]; then - wget ${Xray_URL}Xray-linux-32.zip + wget -q ${Xray_URL}Xray-linux-32.zip unzip Xray-linux-32.zip rm -f Xray-linux-32.zip elif [ "${{ matrix.platform }}" == "armv5" ]; then - wget ${Xray_URL}Xray-linux-arm32-v5.zip + wget -q ${Xray_URL}Xray-linux-arm32-v5.zip unzip Xray-linux-arm32-v5.zip rm -f Xray-linux-arm32-v5.zip elif [ "${{ matrix.platform }}" == "s390x" ]; then - wget ${Xray_URL}Xray-linux-s390x.zip + wget -q ${Xray_URL}Xray-linux-s390x.zip unzip Xray-linux-s390x.zip rm -f Xray-linux-s390x.zip fi rm -f geoip.dat geosite.dat - wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat - wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat - wget -O geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat - wget -O geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat - 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 + wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat + wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat + wget -q -O geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat + wget -q -O geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat + wget -q -O geoip_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat + wget -q -O geosite_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat mv xray xray-linux-${{ matrix.platform }} cd ../.. diff --git a/DockerEntrypoint.sh b/DockerEntrypoint.sh index ec4771ed..204c1e75 100644 --- a/DockerEntrypoint.sh +++ b/DockerEntrypoint.sh @@ -1,7 +1,7 @@ #!/bin/sh # Start fail2ban -fail2ban-client -x start +[ $X_UI_ENABLE_FAIL2BAN == "true" ] && fail2ban-client -x start # Docker Logs #ln -sf /dev/stdout /app/access.log diff --git a/DockerInit.sh b/DockerInit.sh index 38cd9d7b..38bf6fba 100755 --- a/DockerInit.sh +++ b/DockerInit.sh @@ -27,16 +27,16 @@ case $1 in esac mkdir -p build/bin cd build/bin -wget "https://github.com/XTLS/Xray-core/releases/download/v24.12.18/Xray-linux-${ARCH}.zip" +wget -q "https://github.com/XTLS/Xray-core/releases/download/v25.1.30/Xray-linux-${ARCH}.zip" unzip "Xray-linux-${ARCH}.zip" rm -f "Xray-linux-${ARCH}.zip" geoip.dat geosite.dat mv xray "xray-linux-${FNAME}" -wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat -wget https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat -wget -O geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat -wget -O geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat -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 +wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat +wget -q https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat +wget -q -O geoip_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geoip.dat +wget -q -O geosite_IR.dat https://github.com/chocolate4u/Iran-v2ray-rules/releases/latest/download/geosite.dat +wget -q -O geoip_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geoip.dat +wget -q -O geosite_RU.dat https://github.com/runetfreedom/russia-v2ray-rules-dat/releases/latest/download/geosite.dat cd ../../ # Antizapret diff --git a/Dockerfile b/Dockerfile index 499e8ba0..b3ef10f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,7 +16,7 @@ COPY . . ENV CGO_ENABLED=1 ENV CGO_CFLAGS="-D_LARGEFILE64_SOURCE" -RUN go build -o build/x-ui main.go +RUN go build -ldflags "-w -s" -o build/x-ui main.go RUN ./DockerInit.sh "$TARGETARCH" "$BUILD_WITH_ANTIZAPRET" # ======================================================== @@ -133,6 +133,7 @@ RUN chmod +x \ /app/x-ui \ /usr/bin/x-ui +ENV X_UI_ENABLE_FAIL2BAN="true" VOLUME [ "/etc/x-ui" ] CMD [ "./x-ui" ] ENTRYPOINT [ "/app/DockerEntrypoint.sh" ] diff --git a/README.es_ES.md b/README.es_ES.md index 1b158589..49a0d4f5 100644 --- a/README.es_ES.md +++ b/README.es_ES.md @@ -1,4 +1,4 @@ -[English](/README.md) | [中文](/README.zh_CN.md) | [Español](/README.es_ES.md) | [Русский](/README.ru_RU.md) +[English](/README.md) | [فارسی](/README.fa_IR.md) | [中文](/README.zh_CN.md) | [Español](/README.es_ES.md) | [Русский](/README.ru_RU.md)
+
+
جزئیات گواهی SSL
+
+### ACME
+
+برای مدیریت گواهیهای SSL با استفاده از ACME:
+
+1. اطمینان حاصل کنید دامنه شما به درستی به سرور متصل است.
+2. دستور `x-ui` را در ترمینال اجرا کرده و گزینه `مدیریت گواهی SSL` را انتخاب کنید.
+3. گزینههای زیر نمایش داده میشوند:
+
+ - **دریافت SSL:** دریافت گواهی SSL
+ - **لغو:** لغو گواهیهای موجود
+ - **تمدید اجباری:** تمدید اجباری گواهیها
+ - **نمایش دامنههای موجود:** نمایش تمام دامنههای دارای گواهی
+ - **تنظیم مسیر گواهی برای پنل:** تنظیم مسیر گواهی برای دامنه شما
+
+### Certbot
+
+نصب و استفاده از Certbot:
+
+```sh
+apt-get install certbot -y
+certbot certonly --standalone --agree-tos --register-unsafely-without-email -d yourdomain.com
+certbot renew --dry-run
+```
+
+### Cloudflare
+
+اسکریپت داخلی برای دریافت گواهی SSL از Cloudflare. نیازمند:
+
+- ایمیل ثبتشده در Cloudflare
+- کلید API جهانی Cloudflare
+- دامنه باید از طریق Cloudflare به سرور متصل باشد
+
+**دریافت کلید API جهانی Cloudflare:**
+
+1. دستور `x-ui` را اجرا و گزینه `گواهی SSL کلادفلر` را انتخاب کنید.
+2. به لینک [Cloudflare API Tokens](https://dash.cloudflare.com/profile/api-tokens) مراجعه کنید.
+3. روی "View Global API Key" کلیک کنید:
+ 
+4. پس از احراز هویت، کلید API نمایش داده میشود:
+ 
+
+در هنگام استفاده، نام دامنه، ایمیل و کلید API را وارد کنید:
+ 
+
+جزئیات نصب دستی
+
+#### استفاده
+
+1. دریافت آخرین نسخه از سرور:
+
+```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" ;;
+ s390x) echo 's390x' ;;
+ *) XUI_ARCH="amd64" ;;
+esac
+
+wget https://github.com/serogaq/3x-ui/releases/latest/download/x-ui-linux-${XUI_ARCH}.tar.gz
+```
+
+2. نصب یا ارتقا:
+
+```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" ;;
+ s390x) echo 's390x' ;;
+ *) 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
+```
+
+جزئیات Docker
+
+#### استفاده
+
+1. **نصب Docker:**
+
+ ```sh
+ bash <(curl -sSL https://get.docker.com)
+ ```
+
+2. **کلون پروژه:**
+
+ ```sh
+ git clone https://github.com/serogaq/3x-ui.git
+ cd 3x-ui
+ ```
+
+3. **راهاندازی سرویس:**
+
+ ```sh
+ docker compose up -d
+ ```
+
+ یا
+
+ ```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/serogaq/3x-ui:latest
+ ```
+
+4. **بهروزرسانی:**
+
+ ```sh
+ cd 3x-ui
+ docker compose down
+ docker compose pull 3x-ui
+ docker compose up -d
+ ```
+
+5. **حذف:**
+
+ ```sh
+ docker stop 3x-ui
+ docker rm 3x-ui
+ cd --
+ rm -r 3x-ui
+ ```
+
+پیکربندی Reverse Proxy
+
+#### Nginx Reverse Proxy
+```nginx
+location / {
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Host $http_host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header Range $http_range;
+ proxy_set_header If-Range $http_if_range;
+ proxy_redirect off;
+ proxy_pass http://127.0.0.1:2053;
+}
+```
+
+#### مسیر فرعی در Nginx
+- اطمینان حاصل کنید "URI Path" در تنظیمات پنل یکسان باشد.
+- `url` در تنظیمات پنل باید با `/` پایان یابد.
+
+```nginx
+location /sub {
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header Host $http_host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header Range $http_range;
+ proxy_set_header If-Range $http_if_range;
+ proxy_redirect off;
+ proxy_pass http://127.0.0.1:2053;
+}
+```
+جزئیات معماریها و دستگاهها
+
+- **amd64**: معماری استاندارد برای کامپیوترهای شخصی و سرورها
+- **x86 / i386**: سیستمهای دسکتاپ و لپتاپ
+- **armv8 / arm64 / aarch64**: دستگاههای موبایل و embedded مانند Raspberry Pi 4
+- **armv7 / arm / arm32**: دستگاههای قدیمی مانند Orange Pi Zero
+- **armv6 / arm / arm32**: دستگاههای بسیار قدیمی مانند Raspberry Pi 1
+- **armv5 / arm / arm32**: سیستمهای embedded قدیمی
+- **s390x**: کامپیوترهای IBM mainframe
+جزئیات تنظیمات پیشفرض
+
+### نام کاربری، رمز عبور، پورت و مسیر وب
+
+در صورت عدم تغییر، این موارد به صورت تصادفی ایجاد میشوند (به جز Docker).
+
+**تنظیمات پیشفرض Docker:**
+- **نام کاربری:** admin
+- **رمز عبور:** admin
+- **پورت:** 2053
+
+### مدیریت دیتابیس:
+
+ امکان Backup و Restore دیتابیس از طریق پنل.
+
+- **مسیر دیتابیس:**
+ - `/etc/x-ui/x-ui.db`
+
+### مسیر پایه وب
+
+1. **بازنشانی مسیر:**
+ - اجرای دستور `x-ui`
+ - انتخاب گزینه `Reset Web Base Path`
+
+2. **ساخت یا تنظیم مسیر:**
+ - مسیر به صورت تصادفی ساخته شده یا قابل تنظیم است
+
+3. **مشاهده تنظیمات فعلی:**
+ - استفاده از دستور `x-ui settings` یا `View Current Settings` در `x-ui`
+
+**توصیه امنیتی:**
+- استفاده از مسیرهای طولانی و تصادفی برای افزایش امنیت
+
+**مثال:**
+- `http://ip:port/*webbasepath*/panel`
+- `http://domain:port/*webbasepath*/panel`
+
+جزئیات WARP
+
+#### استفاده
+
+**برای نسخههای `v2.1.0` و جدیدتر:**
+
+WARP به صورت داخلی پشتیبانی میشود. تنها نیاز به فعالسازی در پنل است.
+
+جزئیات محدودیت IP
+
+#### استفاده
+
+**توجه:** محدودیت IP در صورت استفاده از IP Tunnel کار نمیکند.
+
+- **تا نسخه `v1.6.1`:**
+ - محدودیت IP به صورت داخلی در پنل وجود دارد
+
+**برای نسخههای `v1.7.0` و جدیدتر:**
+
+برای فعالسازی نیاز به نصب `fail2ban` است:
+
+1. اجرای دستور `x-ui` و انتخاب `مدیریت محدودیت IP`
+2. گزینههای موجود:
+
+ - **تغییر مدت زمان Ban**
+ - **حذف تمام Banها**
+ - **مشاهده لاگها**
+ - **وضعیت Fail2ban**
+ - **راهاندازی مجدد Fail2ban**
+ - **حذف Fail2ban**
+
+3. تنظیم مسیر `Access log` در پنل به `./access.log` و ذخیره و راهاندازی مجدد Xray
+
+- **قبل از نسخه `v2.1.3`:**
+ - تنظیم دستی `access.log` در تنظیمات Xray:
+
+ ```sh
+ "log": {
+ "access": "./access.log",
+ "dnsLog": false,
+ "loglevel": "warning"
+ },
+ ```
+
+- **از نسخه `v2.1.3`:**
+ - امکان تنظیم `access.log` از طریق پنل
+
+جزئیات ربات تلگرام
+
+#### استفاده
+
+ربات تلگرام برای اطلاعرسانی ترافیک، ورود به پنل، Backup دیتابیس و ... استفاده میشود. نیازمند تنظیم:
+
+- توکن تلگرام
+- Chat ID ادمینها
+- زمان اطلاعرسانی (Cron syntax)
+- اطلاعرسانی انقضا
+- اطلاعرسانی ترافیک
+- Backup دیتابیس
+- اطلاعرسانی مصرف CPU
+
+**سینتکس نمونه:**
+
+- `30 \* \* \* \* \*` - اطلاع در ثانیه 30 هر دقیقه
+- `@hourly` - هر ساعت
+- `@daily` - هر روز
+
+### ویژگیهای ربات
+
+- گزارش دورهای
+- اطلاع ورود به پنل
+- اطلاع مصرف CPU
+- اطلاع پیشاز موعد انقضا و ترافیک
+- گزارش ترافیک کلاینتها
+- منوی مبتنی بر دستور
+- جستجوی کلاینت بر اساس ایمیل
+- بررسی inboundها
+- بررسی وضعیت سرور
+- دریافت Backup
+- چندزبانه
+
+### راهاندازی ربات
+
+- شروع [Botfather](https://t.me/BotFather) در تلگرام:
+ 
+
+- ساخت ربات جدید با دستور /newbot:
+ 
+
+- شروع ربات ساخته شده:
+ 
+
+- تنظیمات پنل:
+
+
+وارد کردن توکن و Chat ID (دریافت از [این ربات](https://t.me/useridinfobot)):
+
+
+جزئیات API
+
+#### استفاده
+
+- [مستندات API](https://www.postman.com/hsanaei/3x-ui/collection/q1l5l0u/3x-ui)
+- `/login` با `POST` داده کاربر: `{username: '', password: ''}`
+
+| Method | مسیر | عملکرد |
+| :----: | ---------------------------------- | ------------------------------------------- |
+| `GET` | `"/list"` | دریافت تمام inboundها |
+| `GET` | `"/get/:id"` | دریافت inbound بر اساس id |
+| `POST` | `"/add"` | افزودن inbound |
+| `POST` | `"/del/:id"` | حذف inbound |
+
+- [](https://app.getpostman.com/run-collection/5146551-dda3cab3-0e33-485f-96f9-d4262f437ac5?action=collection%2Ffork&source=rip_markdown&collection-url=entityId%3D5146551-dda3cab3-0e33-485f-96f9-d4262f437ac5%26entityType%3Dcollection%26workspaceId%3Dd64f609f-485a-4951-9b8f-876b3f917124)
+
جزئیات متغیرها
+
+#### استفاده
+
+| متغیر | نوع | پیشفرض |
+| ------------- | :--------------------------------------------: | :------------ |
+| XUI_LOG_LEVEL | `"debug"` \| `"info"` \| `"warn"` \| `"error"` | `"info"` |
+| XUI_DEBUG | `boolean` | `false` |
+| XUI_BIN_FOLDER| `string` | `"bin"` |
+
+مثال:
+
+```sh
+XUI_BIN_FOLDER="bin" XUI_DB_FOLDER="/etc/x-ui" go build main.go
+```
+
+
+
+
this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()},u.isLocal=function(){return!!this.isValid()&&!this._isUTC},u.isUtcOffset=function(){return!!this.isValid()&&this._isUTC},u.isUtc=At,u.isUTC=At,u.zoneAbbr=function(){return this._isUTC?"UTC":""},u.zoneName=function(){return this._isUTC?"Coordinated Universal Time":""},u.dates=e("dates accessor is deprecated. Use date instead.",ge),u.months=e("months accessor is deprecated. Use month instead",Ie),u.years=e("years accessor is deprecated. Use year instead",Pe),u.zone=e("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",function(e,t){return null!=e?(this.utcOffset(e="string"!=typeof e?-e:e,t),this):-this.utcOffset()}),u.isDSTShifted=e("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",function(){var e,t;return g(this._isDSTShifted)&&(q(e={},this),(e=Nt(e))._a?(t=(e._isUTC?l:R)(e._a),this._isDSTShifted=this.isValid()&&0
+
{{ i18n "comment" }}
+
+
+
{{ i18n "pages.inbounds.IPLimit" }}
@@ -419,7 +427,7 @@
-