Compare commits

...

15 Commits

Author SHA1 Message Date
mhsanaei
86586b7e8f v2.3.7 2024-07-01 23:54:12 +02:00
mhsanaei
f9792632d4 pageSize default to 50 2024-07-01 21:11:42 +02:00
mhsanaei
a9ec24f811 update dependencies 2024-07-01 19:45:51 +02:00
mhsanaei
2da7dda794 grpc.Dial is deprecated: use NewClient instead 2024-07-01 19:22:35 +02:00
mhsanaei
39aae6fd16 sub - add hour for time left
1D,10H
22M
2024-07-01 19:11:40 +02:00
dependabot[bot]
f355ab5758 Bump github.com/shirou/gopsutil/v4 from 4.24.5 to 4.24.6 (#2429)
Bumps [github.com/shirou/gopsutil/v4](https://github.com/shirou/gopsutil) from 4.24.5 to 4.24.6.
- [Release notes](https://github.com/shirou/gopsutil/releases)
- [Commits](https://github.com/shirou/gopsutil/compare/v4.24.5...v4.24.6)

---
updated-dependencies:
- dependency-name: github.com/shirou/gopsutil/v4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-01 17:13:28 +02:00
mhsanaei
3847bc0a78 Update README.md 2024-06-27 12:45:58 +02:00
mhsanaei
546d676472 Xray Core v1.8.16 2024-06-25 08:56:52 +02:00
mhsanaei
6fb6241c3c bash - update menu 2024-06-24 15:45:50 +02:00
mhsanaei
f481ab993e bash - Reset Web Base Path 2024-06-24 15:06:52 +02:00
mhsanaei
3ef4ab423f Update README.md 2024-06-24 14:15:32 +02:00
mhsanaei
b5a32ef57e update commands 2024-06-24 13:47:13 +02:00
mhsanaei
4033001798 update readme 2024-06-24 12:36:38 +02:00
mhsanaei
2486b5ff43 ensure file exists 2024-06-24 09:57:46 +02:00
dependabot[bot]
58647c6496 Bump github.com/xtls/xray-core from 1.8.15 to 1.8.16 (#2426)
Bumps [github.com/xtls/xray-core](https://github.com/xtls/xray-core) from 1.8.15 to 1.8.16.
- [Release notes](https://github.com/xtls/xray-core/releases)
- [Commits](https://github.com/xtls/xray-core/compare/v1.8.15...v1.8.16)

---
updated-dependencies:
- dependency-name: github.com/xtls/xray-core
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-24 00:57:32 +02:00
16 changed files with 352 additions and 192 deletions

View File

@@ -83,7 +83,7 @@ jobs:
cd x-ui/bin cd x-ui/bin
# Download dependencies # Download dependencies
Xray_URL="https://github.com/XTLS/Xray-core/releases/download/v1.8.15/" Xray_URL="https://github.com/XTLS/Xray-core/releases/download/v1.8.16/"
if [ "${{ matrix.platform }}" == "amd64" ]; then if [ "${{ matrix.platform }}" == "amd64" ]; then
wget ${Xray_URL}Xray-linux-64.zip wget ${Xray_URL}Xray-linux-64.zip
unzip Xray-linux-64.zip unzip Xray-linux-64.zip

View File

@@ -27,7 +27,7 @@ case $1 in
esac esac
mkdir -p build/bin mkdir -p build/bin
cd build/bin cd build/bin
wget "https://github.com/XTLS/Xray-core/releases/download/v1.8.15/Xray-linux-${ARCH}.zip" wget "https://github.com/XTLS/Xray-core/releases/download/v1.8.16/Xray-linux-${ARCH}.zip"
unzip "Xray-linux-${ARCH}.zip" unzip "Xray-linux-${ARCH}.zip"
rm -f "Xray-linux-${ARCH}.zip" geoip.dat geosite.dat rm -f "Xray-linux-${ARCH}.zip" geoip.dat geosite.dat
mv xray "xray-linux-${FNAME}" mv xray "xray-linux-${FNAME}"

View File

@@ -1,5 +1,3 @@
# 3X-UI
[English](/README.md) | [Chinese](/README.zh.md) | [Español](/README.es_ES.md) [English](/README.md) | [Chinese](/README.zh.md) | [Español](/README.es_ES.md)
<p align="center"><a href="#"><img src="./media/3X-UI.png" alt="Image"></a></p> <p align="center"><a href="#"><img src="./media/3X-UI.png" alt="Image"></a></p>

191
README.md
View File

@@ -1,5 +1,3 @@
# 3X-UI
[English](/README.md) | [Chinese](/README.zh.md) | [Español](/README.es_ES.md) [English](/README.md) | [Chinese](/README.zh.md) | [Español](/README.es_ES.md)
<p align="center"><a href="#"><img src="./media/3X-UI.png" alt="Image"></a></p> <p align="center"><a href="#"><img src="./media/3X-UI.png" alt="Image"></a></p>
@@ -28,48 +26,59 @@ bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.
## Install Custom Version ## Install Custom Version
To install your desired version, add the version to the end of the installation command. e.g., ver `v2.3.6`: To install your desired version, add the version to the end of the installation command. e.g., ver `v2.3.7`:
``` ```
bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) v2.3.6 bash <(curl -Ls https://raw.githubusercontent.com/mhsanaei/3x-ui/master/install.sh) v2.3.7
``` ```
## SSL Certificate ## SSL Certificate
<details> <details>
<summary>Click for SSL Certificate</summary> <summary>Click for SSL Certificate details</summary>
### Cloudflare ### ACME
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: To manage SSL certificates using ACME:
- Cloudflare registered email 1. Ensure your domain is correctly resolved to the server.
- Cloudflare Global API Key 2. Run the `x-ui` command in the terminal, then choose `SSL Certificate Management`.
- The domain name has been resolved to the current server through cloudflare 3. You will be presented with the following options:
How to get the Cloudflare Global API Key: - **Get SSL:** Obtain SSL certificates.
- **Revoke:** Revoke existing SSL certificates.
1. Run the`x-ui`command on the terminal, then choose `Cloudflare SSL Certificate`. - **Force Renew:** Force renewal of SSL certificates.
2. Visit the link https://dash.cloudflare.com/profile/api-tokens
3. Click on View Global API Key (See the screenshot below)
![](media/APIKey1.PNG)
4. You may have to re-authenticate your account. After that, the API Key will be shown (See the screenshot below)\
![](media/APIKey2.png)
When using, just enter `domain name`, `email`, `API KEY`, the diagram is as follows:
![](media/DetailEnter.png)
### Certbot ### Certbot
```
To install and use Certbot:
```sh
apt-get install certbot -y apt-get install certbot -y
certbot certonly --standalone --agree-tos --register-unsafely-without-email -d yourdomain.com certbot certonly --standalone --agree-tos --register-unsafely-without-email -d yourdomain.com
certbot renew --dry-run 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`.* ### Cloudflare
The management script includes 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 must be resolved to the current server through Cloudflare
**How to get the Cloudflare Global API Key:**
1. Run the `x-ui` command in the terminal, then choose `Cloudflare SSL Certificate`.
2. Visit the link: [Cloudflare API Tokens](https://dash.cloudflare.com/profile/api-tokens).
3. Click on "View Global API Key" (see the screenshot below):
![](media/APIKey1.PNG)
4. You may need to re-authenticate your account. After that, the API Key will be shown (see the screenshot below):
![](media/APIKey2.png)
When using, just enter your `domain name`, `email`, and `API KEY`. The diagram is as follows:
![](media/DetailEnter.png)
</details> </details>
@@ -135,26 +144,26 @@ systemctl restart x-ui
#### Usage #### Usage
1. Install Docker: 1. **Install Docker:**
```sh ```sh
bash <(curl -sSL https://get.docker.com) bash <(curl -sSL https://get.docker.com)
``` ```
2. Clone the Project Repository: 2. **Clone the Project Repository:**
```sh ```sh
git clone https://github.com/MHSanaei/3x-ui.git git clone https://github.com/MHSanaei/3x-ui.git
cd 3x-ui cd 3x-ui
``` ```
3. Start the Service 3. **Start the Service:**
```sh ```sh
docker compose up -d docker compose up -d
``` ```
OR **OR**
```sh ```sh
docker run -itd \ docker run -itd \
@@ -167,22 +176,22 @@ systemctl restart x-ui
ghcr.io/mhsanaei/3x-ui:latest ghcr.io/mhsanaei/3x-ui:latest
``` ```
update to latest version 4. **Update to the Latest Version:**
```sh ```sh
cd 3x-ui cd 3x-ui
docker compose down docker compose down
docker compose pull 3x-ui docker compose pull 3x-ui
docker compose up -d docker compose up -d
``` ```
remove 3x-ui from docker 5. **Remove 3x-ui from Docker:**
```sh ```sh
docker stop 3x-ui docker stop 3x-ui
docker rm 3x-ui docker rm 3x-ui
cd -- cd --
rm -r 3x-ui rm -r 3x-ui
``` ```
</details> </details>
@@ -255,24 +264,44 @@ Our platform offers compatibility with a diverse range of architectures and devi
- Supports export/import database from the panel - Supports export/import database from the panel
## Default Settings ## Default Panel Settings
<details> <details>
<summary>Click for default settings details</summary> <summary>Click for default settings details</summary>
### Information ### Username & Password & webbasepath:
These will be generated randomly if you skip modifying them.
- **Port:** the default port for panel is `2053`
### Database Management:
You can conveniently perform database Backups and Restores directly from the panel.
- **Port:** 2053
- **Username & Password:** It will be generated randomly if you skip modifying.
- **Database Path:** - **Database Path:**
- /etc/x-ui/x-ui.db - `/etc/x-ui/x-ui.db`
- **Xray Config Path:**
- /usr/local/x-ui/bin/config.json
- **Web Panel Path w/o Deploying SSL:** ### Web Base Path
- http://ip:2053/panel
- http://domain:2053/panel 1. **Reset Web Base Path:**
- **Web Panel Path w/ Deploying SSL:** - Open your terminal.
- https://domain:2053/panel - Run the `x-ui` command.
- Select the option to `Reset Web Base Path`.
2. **Generate or Customize Path:**
- The path will be randomly generated, or you can enter a custom path.
3. **View Current Settings:**
- To view your current settings, use the `x-ui settings` command in the terminal or `View Current Settings` in `x-ui`
### Security Recommendation:
- For enhanced security, use a long, random word in your URL structure.
**Examples:**
- `http://ip:port/*webbasepath*/panel`
- `http://domain:port/*webbasepath*/panel`
</details> </details>
@@ -283,27 +312,20 @@ Our platform offers compatibility with a diverse range of architectures and devi
#### Usage #### Usage
If you want to use routing to WARP before v2.1.0 follow steps as below: **For versions `v2.1.0` and later:**
**1.** Install WARP on **SOCKS Proxy Mode**: WARP is built-in, and no additional installation is required. Simply turn on the necessary configuration in the panel.
```sh **For versions before `v2.1.0`:**
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: 1. Run the `x-ui` command in the terminal, then choose `WARP Management`.
2. You will see the following options:
```sh - **Account Type (free, plus, team):** Choose the appropriate account type.
warp u - **Enable/Disable WireProxy:** Toggle WireProxy on or off.
``` - **Uninstall WARP:** Remove the WARP application.
**3.** Turn on the config you need in panel 3. Configure the settings as needed in the panel.
Config Features:
- Block Ads
- Route Google + Netflix + Spotify + OpenAI (ChatGPT) to WARP
- Fix Google 403 error
</details> </details>
@@ -314,29 +336,40 @@ If you want to use routing to WARP before v2.1.0 follow steps as below:
#### Usage #### Usage
**Note:** IP Limit won't work correctly when using IP Tunnel **Note:** IP Limit won't work correctly when using IP Tunnel.
- For versions up to `v1.6.1`: - **For versions up to `v1.6.1`:**
- The IP limit is built-in to the panel
- IP limit is built-in into the panel. **For versions `v1.7.0` and newer:**
- For versions `v1.7.0` and newer: To enable the IP Limit functionality, you need to install `fail2ban` and its required files by following these steps:
- To make IP Limit work properly, you need to install fail2ban and its required files by following these steps: 1. Run the `x-ui` command in the terminal, then choose `IP Limit Management`.
2. You will see the following options:
1. Use the `x-ui` command inside the shell. - **Change Ban Duration:** Adjust the duration of bans.
2. Select `IP Limit Management`. - **Unban Everyone:** Lift all current bans.
3. Choose the appropriate options based on your needs. - **Check Logs:** Review the logs.
- **Fail2ban Status:** Check the status of `fail2ban`.
- **Restart Fail2ban:** Restart the `fail2ban` service.
- **Uninstall Fail2ban:** Uninstall Fail2ban with configuration.
- make sure you have ./access.log on your Xray Configuration after v2.1.3 we have an option for it 3. Add a path for the access log on the panel by setting `Xray Configs/log/Access log` to `./access.log` then save and restart xray.
```sh - **For versions before `v2.1.3`:**
- You need to set the access log path manually in your Xray configuration:
```sh
"log": { "log": {
"access": "./access.log", "access": "./access.log",
"dnsLog": false, "dnsLog": false,
"loglevel": "warning" "loglevel": "warning"
}, },
``` ```
- **For versions `v2.1.3` and newer:**
- There is an option for configuring `access.log` directly from the panel.
</details> </details>

View File

@@ -1,5 +1,3 @@
# 3X-UI
[English](/README.md) | [Chinese](/README.zh.md) | [Español](/README.es_ES.md) [English](/README.md) | [Chinese](/README.zh.md) | [Español](/README.es_ES.md)
<p align="center"><a href="#"><img src="./media/3X-UI.png" alt="Image"></a></p> <p align="center"><a href="#"><img src="./media/3X-UI.png" alt="Image"></a></p>

View File

@@ -1 +1 @@
2.3.6 2.3.7

12
go.mod
View File

@@ -12,9 +12,9 @@ require (
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7 github.com/op/go-logging v0.0.0-20160315200505-970db520ece7
github.com/pelletier/go-toml/v2 v2.2.2 github.com/pelletier/go-toml/v2 v2.2.2
github.com/robfig/cron/v3 v3.0.1 github.com/robfig/cron/v3 v3.0.1
github.com/shirou/gopsutil/v4 v4.24.5 github.com/shirou/gopsutil/v4 v4.24.6
github.com/valyala/fasthttp v1.55.0 github.com/valyala/fasthttp v1.55.0
github.com/xtls/xray-core v1.8.15 github.com/xtls/xray-core v1.8.16
go.uber.org/atomic v1.11.0 go.uber.org/atomic v1.11.0
golang.org/x/text v0.16.0 golang.org/x/text v0.16.0
google.golang.org/grpc v1.64.0 google.golang.org/grpc v1.64.0
@@ -24,7 +24,7 @@ require (
require ( require (
github.com/andybalholm/brotli v1.1.0 // indirect github.com/andybalholm/brotli v1.1.0 // indirect
github.com/bytedance/sonic v1.11.8 // indirect github.com/bytedance/sonic v1.11.9 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudflare/circl v1.3.9 // indirect github.com/cloudflare/circl v1.3.9 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/base64x v0.1.4 // indirect
@@ -32,12 +32,12 @@ require (
github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 // indirect
github.com/fasthttp/router v1.5.1 // indirect github.com/fasthttp/router v1.5.1 // indirect
github.com/francoispqt/gojay v1.2.13 // indirect github.com/francoispqt/gojay v1.2.13 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gabriel-vasile/mimetype v1.4.4 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.21.0 // indirect github.com/go-playground/validator/v10 v10.22.0 // indirect
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
github.com/google/btree v1.1.2 // indirect github.com/google/btree v1.1.2 // indirect
github.com/google/pprof v0.0.0-20240528025155-186aa0362fba // indirect github.com/google/pprof v0.0.0-20240528025155-186aa0362fba // indirect
@@ -50,7 +50,7 @@ require (
github.com/jinzhu/now v1.1.5 // indirect github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.17.9 // indirect github.com/klauspost/compress v1.17.9 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/klauspost/cpuid/v2 v2.2.8 // indirect
github.com/leodido/go-urn v1.4.0 // indirect github.com/leodido/go-urn v1.4.0 // indirect
github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed // indirect github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed // indirect
github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-isatty v0.0.20 // indirect

24
go.sum
View File

@@ -18,8 +18,8 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
github.com/bytedance/sonic v1.11.8 h1:Zw/j1KfiS+OYTi9lyB3bb0CFxPJVkM17k1wyDG32LRA= github.com/bytedance/sonic v1.11.9 h1:LFHENlIY/SLzDWverzdOvgMztTxcfcF+cqNsz9pK5zg=
github.com/bytedance/sonic v1.11.8/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= github.com/bytedance/sonic v1.11.9/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU= github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
@@ -43,8 +43,8 @@ github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI
github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk=
github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.4 h1:QjV6pZ7/XZ7ryI2KuyeEDE8wnh7fHP9YnQy+R0LnH8I=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= github.com/gabriel-vasile/mimetype v1.4.4/go.mod h1:JwLei5XPtWdGiMFB5Pjle1oEeoSeEuJfJE+TtfvdB/s=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3A65HN+7CMjSDP/gofXL4CZt1V4= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344 h1:Arcl6UOIS/kgO2nW3A65HN+7CMjSDP/gofXL4CZt1V4=
github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I= github.com/ghodss/yaml v1.0.1-0.20220118164431-d8423dcdf344/go.mod h1:GIjDIg/heH5DOkXY3YJ/wNhfHsQHoXGjl8G8amsYQ1I=
@@ -69,8 +69,8 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.21.0 h1:4fZA11ovvtkdgaeev9RGWPgc1uj3H8W+rNYyH/ySBb0= github.com/go-playground/validator/v10 v10.22.0 h1:k6HsTZ0sTnROkhS//R0O+55JgM8C4Bx7ia+JlgcnOao=
github.com/go-playground/validator/v10 v10.21.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM= github.com/go-playground/validator/v10 v10.22.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA= github.com/goccy/go-json v0.10.3 h1:KZ5WoDbxAIgm2HNbYckL0se1fHD6rz5j4ywS6ebzDqA=
@@ -127,8 +127,8 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.8 h1:+StwCXwm9PdpiEkPyzBXIy+M9KUb4ODm0Zarf1kS5BM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/klauspost/cpuid/v2 v2.2.8/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
@@ -205,8 +205,8 @@ github.com/savsgio/gotils v0.0.0-20240303185622-093b76447511/go.mod h1:sM7Mt7uEo
github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb h1:XfLJSPIOUX+osiMraVgIrMR27uMXnRJWGm1+GL8/63U=
github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg= github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb/go.mod h1:bR6DqgcAl1zTcOX8/pE2Qkj9XO00eCNqmKb7lXP8EAg=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shirou/gopsutil/v4 v4.24.5 h1:gGsArG5K6vmsh5hcFOHaPm87UD003CaDMkAOweSQjhM= github.com/shirou/gopsutil/v4 v4.24.6 h1:9qqCSYF2pgOU+t+NgJtp7Co5+5mHF/HyKBUckySQL64=
github.com/shirou/gopsutil/v4 v4.24.5/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA= github.com/shirou/gopsutil/v4 v4.24.6/go.mod h1:aoebb2vxetJ/yIDZISmduFvVNPHqXQ9SEJwRXxkf0RA=
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU= github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
@@ -275,8 +275,8 @@ github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1Y
github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM= github.com/vishvananda/netns v0.0.4/go.mod h1:SpkAiCQRtJ6TvvxPnOSyH3BMl6unz3xZlaprSwhNNJM=
github.com/xtls/reality v0.0.0-20240429224917-ecc4401070cc h1:0Nj8T1n7F7+v4vRVroaJIvY6R0vNABLfPH+lzPHRJvI= github.com/xtls/reality v0.0.0-20240429224917-ecc4401070cc h1:0Nj8T1n7F7+v4vRVroaJIvY6R0vNABLfPH+lzPHRJvI=
github.com/xtls/reality v0.0.0-20240429224917-ecc4401070cc/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE= github.com/xtls/reality v0.0.0-20240429224917-ecc4401070cc/go.mod h1:dm4y/1QwzjGaK17ofi0Vs6NpKAHegZky8qk6J2JJZAE=
github.com/xtls/xray-core v1.8.15 h1:8lmDV0TaqSz0Agdh4dqQstg2QJa183j2D59PKOTVc+Y= github.com/xtls/xray-core v1.8.16 h1:PhbpdREAIvDS7xmxR6Sdpkx0h5ugmf6wIoWECWtJ0kE=
github.com/xtls/xray-core v1.8.15/go.mod h1:tjzDQQJpFORuhf7fBsiswiexLVEeJpAfMsD0NE5xV7M= github.com/xtls/xray-core v1.8.16/go.mod h1:tjzDQQJpFORuhf7fBsiswiexLVEeJpAfMsD0NE5xV7M=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=

View File

@@ -121,6 +121,12 @@ install_base() {
esac esac
} }
gen_random_string() {
local length="$1"
local random_string=$(LC_ALL=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w "$length" | head -n 1)
echo "$random_string"
}
# This function will be called when user installed x-ui out of security # This function will be called when user installed x-ui out of security
config_after_install() { config_after_install() {
echo -e "${yellow}Install/update finished! For security it's recommended to modify panel settings ${plain}" echo -e "${yellow}Install/update finished! For security it's recommended to modify panel settings ${plain}"
@@ -146,7 +152,7 @@ config_after_install() {
if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then if [[ ! -f "/etc/x-ui/x-ui.db" ]]; then
local usernameTemp=$(head -c 6 /dev/urandom | base64) local usernameTemp=$(head -c 6 /dev/urandom | base64)
local passwordTemp=$(head -c 6 /dev/urandom | base64) local passwordTemp=$(head -c 6 /dev/urandom | base64)
local webBasePathTemp=$(head -c 6 /dev/urandom | base64) local webBasePathTemp=$(gen_random_string 10)
/usr/local/x-ui/x-ui setting -username ${usernameTemp} -password ${passwordTemp} -webBasePath ${webBasePathTemp} /usr/local/x-ui/x-ui setting -username ${usernameTemp} -password ${passwordTemp} -webBasePath ${webBasePathTemp}
echo -e "This is a fresh installation, will generate random login info for security concerns:" echo -e "This is a fresh installation, will generate random login info for security concerns:"
echo -e "###############################################" echo -e "###############################################"
@@ -218,18 +224,21 @@ install_x-ui() {
echo -e "" echo -e ""
echo -e "x-ui control menu usages: " echo -e "x-ui control menu usages: "
echo -e "----------------------------------------------" echo -e "----------------------------------------------"
echo -e "x-ui - Enter Admin menu" echo -e "SUBCOMMANDS:"
echo -e "x-ui start - Start x-ui" echo -e "x-ui - Admin Management Script"
echo -e "x-ui stop - Stop x-ui" echo -e "x-ui start - Start"
echo -e "x-ui restart - Restart x-ui" echo -e "x-ui stop - Stop"
echo -e "x-ui status - Show x-ui status" echo -e "x-ui restart - Restart"
echo -e "x-ui enable - Enable x-ui on system startup" echo -e "x-ui status - Current Status"
echo -e "x-ui disable - Disable x-ui on system startup" echo -e "x-ui settings - Current Settings"
echo -e "x-ui log - Check x-ui logs" echo -e "x-ui enable - Enable Autostart on OS Startup"
echo -e "x-ui disable - Disable Autostart on OS Startup"
echo -e "x-ui log - Check logs"
echo -e "x-ui banlog - Check Fail2ban ban logs" echo -e "x-ui banlog - Check Fail2ban ban logs"
echo -e "x-ui update - Update x-ui" echo -e "x-ui update - Update"
echo -e "x-ui install - Install x-ui" echo -e "x-ui custom - custom version"
echo -e "x-ui uninstall - Uninstall x-ui" echo -e "x-ui install - Install"
echo -e "x-ui uninstall - Uninstall"
echo -e "----------------------------------------------" echo -e "----------------------------------------------"
} }

View File

@@ -1007,9 +1007,37 @@ func (s *SubService) genRemark(inbound *model.Inbound, email string, extra strin
now := time.Now().Unix() now := time.Now().Unix()
switch exp := stats.ExpiryTime / 1000; { switch exp := stats.ExpiryTime / 1000; {
case exp > 0: case exp > 0:
remark = append(remark, fmt.Sprintf("%d%s⏳", (exp-now)/86400, "Days")) remainingSeconds := exp - now
days := remainingSeconds / 86400
hours := (remainingSeconds % 86400) / 3600
minutes := (remainingSeconds % 3600) / 60
if days > 0 {
if hours > 0 {
remark = append(remark, fmt.Sprintf("%dD,%dH⏳", days, hours))
} else {
remark = append(remark, fmt.Sprintf("%dD⏳", days))
}
} else if hours > 0 {
remark = append(remark, fmt.Sprintf("%dH⏳", hours))
} else {
remark = append(remark, fmt.Sprintf("%dM⏳", minutes))
}
case exp < 0: case exp < 0:
remark = append(remark, fmt.Sprintf("%d%s⏳", exp/-86400, "Days")) passedSeconds := now - exp
days := passedSeconds / 86400
hours := (passedSeconds % 86400) / 3600
minutes := (passedSeconds % 3600) / 60
if days > 0 {
if hours > 0 {
remark = append(remark, fmt.Sprintf("%dD,%dH⏳", days, hours))
} else {
remark = append(remark, fmt.Sprintf("%dD⏳", days))
}
} else if hours > 0 {
remark = append(remark, fmt.Sprintf("%dH⏳", hours))
} else {
remark = append(remark, fmt.Sprintf("%dM⏳", minutes))
}
} }
} }
} }

View File

@@ -8,7 +8,7 @@ class AllSetting {
this.webKeyFile = ""; this.webKeyFile = "";
this.webBasePath = "/"; this.webBasePath = "/";
this.sessionMaxAge = ""; this.sessionMaxAge = "";
this.pageSize = 0; this.pageSize = 50;
this.expireDiff = ""; this.expireDiff = "";
this.trafficDiff = ""; this.trafficDiff = "";
this.remarkModel = "-ieo"; this.remarkModel = "-ieo";

View File

@@ -664,7 +664,7 @@
tgBotEnable: false, tgBotEnable: false,
showAlert: false, showAlert: false,
ipLimitEnable: false, ipLimitEnable: false,
pageSize: 0, pageSize: 50,
isMobile: window.innerWidth <= 768, isMobile: window.innerWidth <= 768,
}, },
methods: { methods: {

View File

@@ -3,6 +3,7 @@ package job
import ( import (
"io" "io"
"os" "os"
"path/filepath"
"x-ui/logger" "x-ui/logger"
"x-ui/xray" "x-ui/xray"
@@ -14,28 +15,53 @@ func NewClearLogsJob() *ClearLogsJob {
return new(ClearLogsJob) return new(ClearLogsJob)
} }
// ensureFileExists creates the necessary directories and file if they don't exist
func ensureFileExists(path string) error {
dir := filepath.Dir(path)
if err := os.MkdirAll(dir, 0755); err != nil {
return err
}
file, err := os.OpenFile(path, os.O_CREATE|os.O_RDWR, 0644)
if err != nil {
return err
}
file.Close()
return nil
}
// Here Run is an interface method of the Job interface // Here Run is an interface method of the Job interface
func (j *ClearLogsJob) Run() { func (j *ClearLogsJob) Run() {
logFiles := []string{xray.GetIPLimitLogPath(), xray.GetIPLimitBannedLogPath(), xray.GetAccessPersistentLogPath()} logFiles := []string{xray.GetIPLimitLogPath(), xray.GetIPLimitBannedLogPath(), xray.GetAccessPersistentLogPath()}
logFilesPrev := []string{xray.GetIPLimitBannedPrevLogPath(), xray.GetAccessPersistentPrevLogPath()} logFilesPrev := []string{xray.GetIPLimitBannedPrevLogPath(), xray.GetAccessPersistentPrevLogPath()}
// clear log files and copy to previous logs // Ensure all log files and their paths exist
for _, path := range append(logFiles, logFilesPrev...) {
if err := ensureFileExists(path); err != nil {
logger.Warning("Failed to ensure log file exists:", path, "-", err)
}
}
// Clear log files and copy to previous logs
for i := 0; i < len(logFiles); i++ { for i := 0; i < len(logFiles); i++ {
if i > 0 { if i > 0 {
// copy to previous logs // Copy to previous logs
logFilePrev, err := os.OpenFile(logFilesPrev[i-1], os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644) logFilePrev, err := os.OpenFile(logFilesPrev[i-1], os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0644)
if err != nil { if err != nil {
logger.Warning("clear logs job err:", err) logger.Warning("Failed to open previous log file for writing:", logFilesPrev[i-1], "-", err)
continue
} }
logFile, err := os.OpenFile(logFiles[i], os.O_CREATE|os.O_RDONLY, 0644) logFile, err := os.OpenFile(logFiles[i], os.O_RDONLY, 0644)
if err == nil { if err != nil {
_, err = io.Copy(logFilePrev, logFile) logger.Warning("Failed to open current log file for reading:", logFiles[i], "-", err)
if err != nil { logFilePrev.Close()
logger.Warning("clear logs job err:", err) continue
} }
} else {
logger.Warning("clear logs job err:", err) _, err = io.Copy(logFilePrev, logFile)
if err != nil {
logger.Warning("Failed to copy log file:", logFiles[i], "to", logFilesPrev[i-1], "-", err)
} }
logFile.Close() logFile.Close()
@@ -44,7 +70,7 @@ func (j *ClearLogsJob) Run() {
err := os.Truncate(logFiles[i], 0) err := os.Truncate(logFiles[i], 0)
if err != nil { if err != nil {
logger.Warning("clear logs job err:", err) logger.Warning("Failed to truncate log file:", logFiles[i], "-", err)
} }
} }
} }

View File

@@ -33,7 +33,7 @@ var defaultValueMap = map[string]string{
"secret": random.Seq(32), "secret": random.Seq(32),
"webBasePath": "/", "webBasePath": "/",
"sessionMaxAge": "0", "sessionMaxAge": "0",
"pageSize": "0", "pageSize": "50",
"expireDiff": "0", "expireDiff": "0",
"trafficDiff": "0", "trafficDiff": "0",
"remarkModel": "-ieo", "remarkModel": "-ieo",

179
x-ui.sh
View File

@@ -157,6 +157,30 @@ update() {
fi fi
} }
update_menu() {
echo -e "${yellow}Updating Menu${plain}"
confirm "This function will update the menu to the latest changes." "y"
if [[ $? != 0 ]]; then
LOGE "Cancelled"
if [[ $# == 0 ]]; then
before_show_menu
fi
return 0
fi
wget --no-check-certificate -O /usr/bin/x-ui https://raw.githubusercontent.com/MHSanaei/3x-ui/main/x-ui.sh
chmod +x /usr/local/x-ui/x-ui.sh
chmod +x /usr/bin/x-ui
if [[ $? == 0 ]]; then
echo -e "${green}Update successful. The panel has automatically restarted.${plain}"
exit 0
else
echo -e "${red}Failed to update the menu.${plain}"
return 1
fi
}
custom_version() { custom_version() {
echo "Enter the panel version (like 2.0.0):" echo "Enter the panel version (like 2.0.0):"
read panel_version read panel_version
@@ -228,6 +252,32 @@ reset_user() {
confirm_restart confirm_restart
} }
gen_random_string() {
local length="$1"
local random_string=$(LC_ALL=C tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w "$length" | head -n 1)
echo "$random_string"
}
reset_webbasepath() {
echo -e "${yellow}Resetting Web Base Path${plain}"
# Prompt user to set a new web base path
read -rp "Please set the new web base path [default is a random path]: " config_webBasePath
# If user input is empty, generate a random path
if [[ -z $config_webBasePath ]]; then
config_webBasePath=$(gen_random_string 10)
fi
# Apply the new web base path setting
/usr/local/x-ui/x-ui setting -webBasePath "${config_webBasePath}" >/dev/null 2>&1
systemctl restart x-ui
# Display confirmation message
echo -e "Web base path has been reset to: ${green}${config_webBasePath}${plain}"
echo -e "${green}Please use the new web base path to access the panel.${plain}"
}
reset_config() { 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 "Are you sure you want to reset all panel settings, Account data will not be lost, Username and password will not change" "n"
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
@@ -1070,7 +1120,7 @@ iplimit_main() {
echo -e "${green}\t4.${plain} Check Logs" echo -e "${green}\t4.${plain} Check Logs"
echo -e "${green}\t5.${plain} Fail2ban Status" echo -e "${green}\t5.${plain} Fail2ban Status"
echo -e "${green}\t6.${plain} Restart Fail2ban" echo -e "${green}\t6.${plain} Restart Fail2ban"
echo -e "${green}\t7.${plain} Uninstall IP Limit" echo -e "${green}\t7.${plain} Uninstall Fail2ban"
echo -e "${green}\t0.${plain} Back to Main Menu" echo -e "${green}\t0.${plain} Back to Main Menu"
read -p "Choose an option: " choice read -p "Choose an option: " choice
case "$choice" in case "$choice" in
@@ -1253,57 +1303,62 @@ remove_iplimit() {
show_usage() { show_usage() {
echo "x-ui control menu usages: " echo "x-ui control menu usages: "
echo "------------------------------------------" echo "------------------------------------------"
echo -e "x-ui - Enter control menu" echo -e "SUBCOMMANDS:"
echo -e "x-ui start - Start x-ui " echo -e "x-ui - Admin Management Script"
echo -e "x-ui stop - Stop x-ui " echo -e "x-ui start - Start"
echo -e "x-ui restart - Restart x-ui " echo -e "x-ui stop - Stop"
echo -e "x-ui status - Show x-ui status" echo -e "x-ui restart - Restart"
echo -e "x-ui enable - Enable x-ui on system startup" echo -e "x-ui status - Current Status"
echo -e "x-ui disable - Disable x-ui on system startup" echo -e "x-ui settings - Current Settings"
echo -e "x-ui log - Check x-ui logs" echo -e "x-ui enable - Enable Autostart on OS Startup"
echo -e "x-ui disable - Disable Autostart on OS Startup"
echo -e "x-ui log - Check logs"
echo -e "x-ui banlog - Check Fail2ban ban logs" echo -e "x-ui banlog - Check Fail2ban ban logs"
echo -e "x-ui update - Update x-ui " echo -e "x-ui update - Update"
echo -e "x-ui install - Install x-ui " echo -e "x-ui custom - custom version"
echo -e "x-ui uninstall - Uninstall x-ui " echo -e "x-ui install - Install"
echo -e "x-ui uninstall - Uninstall"
echo "------------------------------------------" echo "------------------------------------------"
} }
show_menu() { show_menu() {
echo -e " echo -e "
${green}3X-ui Panel Management Script${plain} ${green}3X-UI Panel Management Script${plain}
${green}0.${plain} Exit Script ${green}0.${plain} Exit Script
———————————————— ————————————————
${green}1.${plain} Install ${green}1.${plain} Install
${green}2.${plain} Update ${green}2.${plain} Update
${green}3.${plain} Custom Version ${green}3.${plain} Update Menu
${green}4.${plain} Uninstall ${green}4.${plain} Custom Version
${green}5.${plain} Uninstall
———————————————— ————————————————
${green}5.${plain} Reset Username & Password & Secret Token ${green}6.${plain} Reset Username & Password & Secret Token
${green}6.${plain} Reset Settings ${green}7.${plain} Reset Web Base Path
${green}7.${plain} Change Port ${green}8.${plain} Reset Settings
${green}8.${plain} View Current Settings ${green}9.${plain} Change Port
${green}10.${plain} View Current Settings
———————————————— ————————————————
${green}9.${plain} Start ${green}11.${plain} Start
${green}10.${plain} Stop ${green}12.${plain} Stop
${green}11.${plain} Restart ${green}13.${plain} Restart
${green}12.${plain} Check Status ${green}14.${plain} Check Status
${green}13.${plain} Check Logs ${green}15.${plain} Check Logs
———————————————— ————————————————
${green}14.${plain} Enable Autostart ${green}16.${plain} Enable Autostart
${green}15.${plain} Disable Autostart ${green}17.${plain} Disable Autostart
———————————————— ————————————————
${green}16.${plain} SSL Certificate Management ${green}18.${plain} SSL Certificate Management
${green}17.${plain} Cloudflare SSL Certificate ${green}19.${plain} Cloudflare SSL Certificate
${green}18.${plain} IP Limit Management ${green}20.${plain} IP Limit Management
${green}19.${plain} WARP Management ${green}21.${plain} WARP Management
${green}20.${plain} Firewall Management ${green}22.${plain} Firewall Management
———————————————— ————————————————
${green}21.${plain} Enable BBR ${green}23.${plain} Enable BBR
${green}22.${plain} Update Geo Files ${green}24.${plain} Update Geo Files
${green}23.${plain} Speedtest by Ookla ${green}25.${plain} Speedtest by Ookla
" "
show_status show_status
echo && read -p "Please enter your selection [0-23]: " num echo && read -p "Please enter your selection [0-25]: " num
case "${num}" in case "${num}" in
0) 0)
@@ -1316,70 +1371,76 @@ show_menu() {
check_install && update check_install && update
;; ;;
3) 3)
check_install && custom_version check_install && update_menu
;; ;;
4) 4)
check_install && uninstall check_install && custom_version
;; ;;
5) 5)
check_install && reset_user check_install && uninstall
;; ;;
6) 6)
check_install && reset_config check_install && reset_user
;; ;;
7) 7)
check_install && set_port check_install && reset_webbasepath
;; ;;
8) 8)
check_install && check_config check_install && reset_config
;; ;;
9) 9)
check_install && start check_install && set_port
;; ;;
10) 10)
check_install && stop check_install && check_config
;; ;;
11) 11)
check_install && restart check_install && start
;; ;;
12) 12)
check_install && status check_install && stop
;; ;;
13) 13)
check_install && show_log check_install && restart
;; ;;
14) 14)
check_install && enable check_install && status
;; ;;
15) 15)
check_install && disable check_install && show_log
;; ;;
16) 16)
ssl_cert_issue_main check_install && enable
;; ;;
17) 17)
ssl_cert_issue_CF check_install && disable
;; ;;
18) 18)
iplimit_main ssl_cert_issue_main
;; ;;
19) 19)
warp_cloudflare ssl_cert_issue_CF
;; ;;
20) 20)
firewall_menu iplimit_main
;; ;;
21) 21)
bbr_menu warp_cloudflare
;; ;;
22) 22)
update_geo firewall_menu
;; ;;
23) 23)
bbr_menu
;;
24)
update_geo
;;
25)
run_speedtest run_speedtest
;; ;;
*) *)
LOGE "Please enter the correct number [0-23]" LOGE "Please enter the correct number [0-25]"
;; ;;
esac esac
} }
@@ -1398,6 +1459,9 @@ if [[ $# > 0 ]]; then
"status") "status")
check_install 0 && status 0 check_install 0 && status 0
;; ;;
"settings")
check_install 0 && check_config 0
;;
"enable") "enable")
check_install 0 && enable 0 check_install 0 && enable 0
;; ;;
@@ -1413,6 +1477,9 @@ if [[ $# > 0 ]]; then
"update") "update")
check_install 0 && update 0 check_install 0 && update 0
;; ;;
"custom")
check_install 0 && custom_version 0
;;
"install") "install")
check_uninstall 0 && install 0 check_uninstall 0 && install 0
;; ;;

View File

@@ -35,10 +35,11 @@ func (x *XrayAPI) Init(apiPort int) (err error) {
if apiPort == 0 { if apiPort == 0 {
return common.NewError("xray api port wrong:", apiPort) return common.NewError("xray api port wrong:", apiPort)
} }
x.grpcClient, err = grpc.Dial(fmt.Sprintf("127.0.0.1:%v", apiPort), grpc.WithTransportCredentials(insecure.NewCredentials())) conn, err := grpc.NewClient(fmt.Sprintf("127.0.0.1:%v", apiPort), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil { if err != nil {
return err return err
} }
x.grpcClient = conn
x.isConnected = true x.isConnected = true
hsClient := command.NewHandlerServiceClient(x.grpcClient) hsClient := command.NewHandlerServiceClient(x.grpcClient)