From a3e1ee1f35cc8747432f3856c3f064db464c3ec6 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Fri, 14 Apr 2023 04:36:33 +0430 Subject: [PATCH 1/6] update db config path --- config/config.go | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/config/config.go b/config/config.go index e1c7f911..e3fe1709 100644 --- a/config/config.go +++ b/config/config.go @@ -45,6 +45,22 @@ func IsDebug() bool { return os.Getenv("XUI_DEBUG") == "true" } -func GetDBPath() string { - return fmt.Sprintf("/etc/%s/%s.db", GetName(), GetName()) +func GetBinFolderPath() string { + binFolderPath := os.Getenv("XUI_BIN_FOLDER") + if binFolderPath == "" { + binFolderPath = "bin" + } + return binFolderPath +} + +func GetDBFolderPath() string { + dbFolderPath := os.Getenv("XUI_DB_FOLDER") + if dbFolderPath == "" { + dbFolderPath = "/etc/x-ui" + } + return dbFolderPath +} + +func GetDBPath() string { + return fmt.Sprintf("%s/%s.db", GetDBFolderPath(), GetName()) } From f996b9ee2bd4215cf00bf69b8e9bed222106a122 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Fri, 14 Apr 2023 04:39:35 +0430 Subject: [PATCH 2/6] update en lang --- web/translation/translate.en_US.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index a269e631..a050ae04 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -106,8 +106,8 @@ "expireDate" = "Expire date" "resetTraffic" = "Reset traffic" "addInbound" = "Add Inbound" -"addTo" = "Add To" -"revise" = "Revise" +"addTo" = "Create" +"revise" = "Update" "modifyInbound" = "Modify InBound" "deleteInbound" = "Delete Inbound" "deleteInboundContent" = "Are you sure you want to delete inbound?" From f9f8431dd250378d9b8f01ef816426609a6f7675 Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Fri, 14 Apr 2023 04:40:46 +0430 Subject: [PATCH 3/6] update v2-ui.db path --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index d857ab46..0d6e0f90 100644 --- a/main.go +++ b/main.go @@ -217,7 +217,7 @@ func main() { v2uiCmd := flag.NewFlagSet("v2-ui", flag.ExitOnError) var dbPath string - v2uiCmd.StringVar(&dbPath, "db", "/etc/v2-ui/v2-ui.db", "set v2-ui db file path") + v2uiCmd.StringVar(&dbPath, "db", fmt.Sprintf("%s/v2-ui.db", config.GetDBFolderPath()), "set v2-ui db file path") settingCmd := flag.NewFlagSet("setting", flag.ExitOnError) var port int From 6d404e4b27f43b2f7a5af8c03158d9fd77fd076b Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Fri, 14 Apr 2023 04:44:04 +0430 Subject: [PATCH 4/6] update get paths functions --- xray/process.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xray/process.go b/xray/process.go index 0c382ec8..be90331f 100644 --- a/xray/process.go +++ b/xray/process.go @@ -14,6 +14,7 @@ import ( "runtime" "strings" "time" + "x-ui/config" "x-ui/util/common" "github.com/Workiva/go-datastructures/queue" @@ -29,19 +30,19 @@ func GetBinaryName() string { } func GetBinaryPath() string { - return "bin/" + GetBinaryName() + return config.GetBinFolderPath() + "/" + GetBinaryName() } func GetConfigPath() string { - return "bin/config.json" + return config.GetBinFolderPath() + "/config.json" } func GetGeositePath() string { - return "bin/geosite.dat" + return config.GetBinFolderPath() + "/geosite.dat" } func GetGeoipPath() string { - return "bin/geoip.dat" + return config.GetBinFolderPath() + "/geoip.dat" } func stopProcess(p *Process) { From 04095b6ec49263170c85ac82bc1ddcaa2f04709f Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Fri, 14 Apr 2023 16:54:41 +0430 Subject: [PATCH 5/6] update README.md --- README.md | 88 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 56 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 50d22f44..fa471f1f 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,29 @@ # x-ui -![](https://img.shields.io/github/v/release/alireza0/x-ui.svg) + +![](https://img.shields.io/github/v/release/alireza0/x-ui.svg) ![](https://img.shields.io/docker/pulls/alireza7/x-ui.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/alireza0/x-ui)](https://goreportcard.com/report/github.com/alireza0/x-ui) [![Downloads](https://img.shields.io/github/downloads/alireza0/x-ui/total.svg)](https://img.shields.io/github/downloads/alireza0/x-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** xray panel supporting multi-protocol, **Multi-lang (English,Farsi,Chinese)** -| Features | Enable? | -| ------------- |:-------------:| -| Multi-lang | :heavy_check_mark: | -| Dark/Light Theme | :heavy_check_mark: | -| Search in deep | :heavy_check_mark: | -| Inbound Multi User | :heavy_check_mark: | +| Features | Enable? | +| ------------------------------------ | :----------------: | +| Multi-lang | :heavy_check_mark: | +| Dark/Light Theme | :heavy_check_mark: | +| Search in deep | :heavy_check_mark: | +| Inbound Multi User | :heavy_check_mark: | | Multi User Traffic & Expiration time | :heavy_check_mark: | -| REST API | :heavy_check_mark: | -| Telegram BOT (admin + clients) | :heavy_check_mark: | -| Backup database using Telegram BOT | :heavy_check_mark: | -| Subscription link | :heavy_check_mark: | +| REST API | :heavy_check_mark: | +| Telegram BOT (admin + clients) | :heavy_check_mark: | +| Backup database using Telegram BOT | :heavy_check_mark: | +| Subscription link | :heavy_check_mark: | | Calculate expire date on first usage | :heavy_check_mark: | -**If you think this project is helpful to you, you may wish to give a** :star2: +**If you think this project is helpful to you, you may wish to give a** :star2: # Features @@ -44,19 +46,28 @@ xray panel supporting multi-protocol, **Multi-lang (English,Farsi,Chinese)** - `/login` with `PUSH` user data: `{username: '', password: ''}` for login - `/xui/API/inbounds` base for following actions: -| Method | Path | Action | -| ------------- | ------------- | ------------- | -| GET | "/" | Get all inbounds | -| GET | "/get/:id" | Get inbound with inbound.id | -| POST | "/add" | Add inbound | -| POST | "/del/:id" | Delete Inbound | -| POST | "/update/:id" | Update Inbound | -| POST | "/addClient/" | Add Client to inbound | -| POST | "/delClient/:email" | Delete Client | -| POST | "/updateClient/:index" | Update Client | -| POST | "/:id/resetClientTraffic/:email" | Reset Client's Traffic | -| POST | "/resetAllTraffics" | Reset traffics of all inbounds | -| POST | "/resetAllClientTraffics/:id" | Reset traffics of all clients in an inbound | +| Method | Path | Action | +| ------ | -------------------------------- | ------------------------------------------- | +| GET | "/" | Get all inbounds | +| GET | "/get/:id" | Get inbound with inbound.id | +| POST | "/add" | Add inbound | +| POST | "/del/:id" | Delete Inbound | +| POST | "/update/:id" | Update Inbound | +| POST | "/addClient/" | Add Client to inbound | +| POST | "/delClient/:email" | Delete Client | +| POST | "/updateClient/:index" | Update Client | +| POST | "/:id/resetClientTraffic/:email" | Reset Client's Traffic | +| POST | "/resetAllTraffics" | Reset traffics of all inbounds | +| POST | "/resetAllClientTraffics/:id" | Reset traffics of all clients in an inbound | + +# Environment Variables + +| 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"` | # Screenshot from Inbouds page @@ -77,7 +88,9 @@ bash <(curl -Ls https://raw.githubusercontent.com/alireza0/x-ui/master/install.s ``` ## Install custom version + To install your desired version you can add the version to the end of install command. Example for ver `0.5.1`: + ``` bash <(curl -Ls https://raw.githubusercontent.com/alireza0/x-ui/master/install.sh) 0.5.1 ``` @@ -130,6 +143,7 @@ docker build -t x-ui . ``` ## SSL certificate application +
Click for details @@ -146,9 +160,11 @@ ln -s /snap/bin/certbot /usr/bin/certbot certbot certonly --standalone --register-unsafely-without-email --non-interactive --agree-tos -d ``` +
## Tg robot use +
Click for details @@ -167,8 +183,8 @@ Set the robot-related parameters in the panel background, including: Reference syntax: -- 30 * * * * * //Notify at the 30s of each point -- 0 */10 * * * * //Notify at the first second of each 10 minutes +- 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) - @every 8h // notify every 8 hours @@ -190,6 +206,7 @@ Reference syntax:
# Common problem +
Click for details ## Migrating from v2-ui @@ -206,12 +223,15 @@ x-ui v2-ui **If you upgrade from an old version or other forks, for enable traffic for users you should do :** -find this in config : -``` json +find this in config : + +```json "policy": { "system": { ``` -**and add this just after ` "policy": {` :** + +**and add this just after ` "policy": {` :** + ```json "levels": { "0": { @@ -222,6 +242,7 @@ find this in config : ``` **the final output is like :** + ```json "policy": { "levels": { @@ -238,12 +259,15 @@ find this in config : }, "routing": { ``` - restart panel + +restart panel +
# a special thanks to + - [HexaSoftwareTech](https://github.com/HexaSoftwareTech/) -- [MHSanaei](https://github.com/MHSanaei) +- [MHSanaei](https://github.com/MHSanaei) ## Stargazers over time From 2fe4f1ad071f5ee5d5e3528c0533ebdceedae35f Mon Sep 17 00:00:00 2001 From: Hamidreza Ghavami Date: Fri, 14 Apr 2023 16:56:35 +0430 Subject: [PATCH 6/6] update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fa471f1f..53fb9ee6 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ xray panel supporting multi-protocol, **Multi-lang (English,Farsi,Chinese)** # Environment Variables -| variable | type | default | +| Variable | Type | Default | | -------------- | :--------------------------------------------: | :------------ | | XUI_LOG_LEVEL | `"debug"` \| `"info"` \| `"warn"` \| `"error"` | `"info"` | | XUI_DEBUG | `boolean` | `false` |