diff --git a/README.md b/README.md index ce441cb29..8fafa7dc9 100644 --- a/README.md +++ b/README.md @@ -1,186 +1,210 @@ -

- - - - - - -

- -

PasarGuard

- -

- Unified GUI Censorship Resistant Solution -

- -
-

- - - - - - - - - - - - - - - - - - -

- -

- - English - - / - - فارسی - - / - - 简体中文 - - / - - Русский - -

- -

- - PasarGuard screenshots - -

- -## Table of Contents - -- [Overview](#overview) - - [Why using PasarGuard?](#why-using-PasarGuard) - - [Features](#features) -- [Installation guide](#installation-guide) -- [Configuration](#configuration) -- [Documentation](#documentation) -- [API](#api) -- [Backup](#backup) -- [Telegram Bot](#telegram-bot) -- [PasarGuard CLI](#PasarGuard-cli) -- [PasarGuard Node](#node) -- [Webhook notifications](#webhook-notifications) -- [Donation](#donation) -- [License](#license) -- [Contributors](#contributors) - -# Overview - -PasarGuard is a proxy management tool that provides a simple and easy-to-use user interface for managing hundreds of proxy accounts powered by [Xray-core](https://github.com/XTLS/Xray-core) and built using Python and Reactjs. - -## Why using PasarGuard? - -PasarGuard is user-friendly, feature-rich and reliable. It lets you to create different proxies for your users without any complicated configuration. Using its built-in web UI, you are able to monitor, modify and limit users. - -### Features - -- Built-in **Web UI** -- Fully **REST API** backend -- [**Multiple Nodes**](#node) support (for infrastructure distribution & scalability) -- Supports protocols **Vmess**, **VLESS**, **Trojan** and **Shadowsocks** -- **Multi-protocol** for a single user -- **Multi-user** on a single inbound -- **Multi-inbound** on a **single port** (fallbacks support) -- **Traffic** and **expiry date** limitations -- **Periodic** traffic limit (e.g. daily, weekly, etc.) -- **Subscription link** compatible with **V2ray** _(such as V2RayNG, SingBox, Nekoray, etc.)_, **Clash** and **ClashMeta** -- Automated **Share link** and **QRcode** generator -- System monitoring and **traffic statistics** -- Customizable xray configuration -- **TLS** and **REALITY** support -- Integrated **Telegram Bot** -- Integrated **Command Line Interface (CLI)** -- **Multi-language** -- **Multi-admin** support (WIP) - -# Installation guide - -### ⚠️ The following commands will install the pre release versions (alpha/beta) - -Run the following command to install PasarGuard with SQLite database: +
+ +# 🛡️ PasarGuard + +[![PasarGuard Logo](https://github.com/PasarGuard/docs/blob/main/logos/PasarGuard-black-logo.png)](https://github.com/PasarGuard/panel) + +### Unified GUI Censorship Resistant Solution + +
+ +
+ +## 📊 Project Status + +[![Build Status](https://img.shields.io/github/actions/workflow/status/PasarGuard/panel/build.yml?style=for-the-badge&label=Build&logo=github)](https://github.com/PasarGuard/panel/actions) +[![Docker Pulls](https://img.shields.io/docker/pulls/PasarGuard/panel?style=for-the-badge&label=Docker%20Pulls&logo=docker)](https://hub.docker.com/r/PasarGuard/panel) +[![License](https://img.shields.io/github/license/PasarGuard/panel?style=for-the-badge&label=License&logo=opensourceinitiative)](https://github.com/PasarGuard/panel/blob/main/LICENSE) +[![Telegram](https://img.shields.io/badge/Telegram-Group-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white)](https://t.me/Pasar_Guard) +[![GitHub Stars](https://img.shields.io/github/stars/PasarGuard/panel?style=for-the-badge&label=Stars&logo=github)](https://github.com/PasarGuard/panel) + +
+ +
+ +## 🌍 Languages + +[![English](https://img.shields.io/badge/English-🇺🇸-blue?style=for-the-badge)](./README.md) +[![فارسی](https://img.shields.io/badge/فارسی-🇮🇷-green?style=for-the-badge)](./README-fa.md) +[![简体中文](https://img.shields.io/badge/简体中文-🇨🇳-red?style=for-the-badge)](./README-zh-cn.md) +[![Русский](https://img.shields.io/badge/Русский-🇷🇺-orange?style=for-the-badge)](./README-ru.md) + +
+ +
+ +## 🖼️ Preview + +[![PasarGuard Dashboard Preview](https://github.com/PasarGuard/docs/raw/master/screenshots/preview.png)](https://github.com/PasarGuard/panel) + +*Click to view larger image* + +
+ +## 📋 Table of Contents + +- [📖 Overview](#overview) + - [❓ Why using PasarGuard?](#why-using-PasarGuard) + - [✨ Features](#features) +- [🚀 Installation guide](#installation-guide) +- [⚙️ Configuration](#configuration) +- [📚 Documentation](#documentation) +- [🔌 API](#api) +- [💾 Backup](#backup) +- [🤖 Telegram Bot](#telegram-bot) +- [💻 PasarGuard CLI](#PasarGuard-cli) +- [🌐 PasarGuard Node](#node) +- [🔔 Webhook notifications](#webhook-notifications) +- [💝 Donation](#donation) +- [📄 License](#license) +- [👥 Contributors](#contributors) + +# 📖 Overview + +
+ +**PasarGuard** is a powerful proxy management tool that provides a simple and easy-to-use user interface for managing hundreds of proxy accounts. Built on [Xray-core](https://github.com/XTLS/Xray-core) and developed using Python and Reactjs. + +
+ +## ❓ Why using PasarGuard? + +
+ +PasarGuard is user-friendly, feature-rich and reliable. It lets you create different proxies for your users without any complicated configuration. Using its built-in web UI, you are able to monitor, modify and limit users. + +
+ +### ✨ Features + +
+ +| 🎯 **Core Features** | 🔧 **Technical Features** | 🌐 **Protocol Support** | +|:---:|:---:|:---:| +| 🌐 Built-in **Web UI** | 🔌 Fully **REST API** backend | 📡 **Vmess** Protocol | +| 📊 System monitoring | 🏗️ [**Multiple Nodes**](#node) support | 🚀 **VLESS** Protocol | +| 📈 **Traffic statistics** | ⚙️ Customizable xray configuration | 🛡️ **Trojan** Protocol | +| 🔗 **Subscription links** | 🔐 **TLS** and **REALITY** support | 🌙 **Shadowsocks** Protocol | +| 📱 **QRcode** generator | 🤖 Integrated **Telegram Bot** | 🔄 **Multi-protocol** support | +| 📅 **Traffic limitations** | 💻 Integrated **CLI** | 👥 **Multi-user** support | +| ⏰ **Periodic limits** | 🌍 **Multi-language** | 🔀 **Multi-inbound** support | +| 👨‍💼 **Multi-admin** support | 📦 **Docker** ready | 🎯 **Single port** fallbacks | + +
+ +#### 🎯 **Key Capabilities:** + +- ✅ **Built-in Web UI** +- ✅ **Fully REST API** backend +- ✅ **[Multiple Nodes](#node)** support +- ✅ **Multi-protocol** for a single user +- ✅ **Multi-user** on a single inbound +- ✅ **Multi-inbound** on a **single port** +- ✅ **Traffic** and **expiry date** limitations +- ✅ **Periodic** traffic limit (daily, weekly, etc.) +- ✅ **Subscription link** compatible with **V2ray**, **Clash** and **ClashMeta** +- ✅ Automated **Share link** and **QRcode** generator +- ✅ System monitoring and **traffic statistics** +- ✅ Customizable xray configuration +- ✅ **TLS** and **REALITY** support +- ✅ Integrated **Telegram Bot** +- ✅ Integrated **Command Line Interface (CLI)** +- ✅ **Multi-language** support +- ✅ **Multi-admin** support (WIP) + +# 🚀 Installation guide + +
+ +## ⚠️ Warning + +The following commands will install the pre-release versions (alpha/beta) + +
+ +## 📦 Install with SQLite Database ```bash sudo bash -c "$(curl -sL https://github.com/PasarGuard/scripts/raw/main/pasarguard.sh)" @ install --pre-release ``` -Run the following command to install PasarGuard with MySQL database: +## 🗄️ Install with MySQL Database ```bash sudo bash -c "$(curl -sL https://github.com/PasarGuard/scripts/raw/main/pasarguard.sh)" @ install --database mysql --pre-release ``` -Run the following command to install PasarGuard with MariaDB database: +## 🗃️ Install with MariaDB Database ```bash sudo bash -c "$(curl -sL https://github.com/PasarGuard/scripts/raw/main/pasarguard.sh)" @ install --database mariadb --pre-release ``` -Run the following command to install PasarGuard with PostgreSQL database: +## 🐘 Install with PostgreSQL Database ```bash sudo bash -c "$(curl -sL https://github.com/PasarGuard/scripts/raw/main/pasarguard.sh)" @ install --database postgresql --pre-release ``` -Once the installation is complete: +## ✅ After Installation Complete + +
+ +### 📋 Next Steps + +
-- You will see the logs that you can stop watching them by closing the terminal or pressing `Ctrl+C` -- The PasarGuard files will be located at `/opt/pasarguard` -- The configuration file can be found at `/opt/pasarguard/.env` (refer to [configurations](#configuration) section to see variables) -- The data files will be placed at `/var/lib/pasarguard` -- For security reasons, the PasarGuard dashboard is not accessible via IP address. Therefore, you must [obtain SSL certificate](https://PasarGuard.github.io/PasarGuard/en/examples/issue-ssl-certificate) and access your PasarGuard dashboard by opening a web browser and navigating to `https://YOUR_DOMAIN:8000/dashboard/` (replace YOUR_DOMAIN with your actual domain) -- You can also use SSH port forwarding to access the PasarGuard dashboard locally without a domain. Replace `user@serverip` with your actual SSH username and server IP and Run the command below: +- ✅ **Logs**: You will see the logs that you can stop watching them by closing the terminal or pressing `Ctrl+C` +- 📁 **Files Location**: The PasarGuard files will be located at `/opt/pasarguard` +- ⚙️ **Configuration**: The configuration file can be found at `/opt/pasarguard/.env` +- 💾 **Data Files**: The data files will be placed at `/var/lib/pasarguard` +- 🔒 **Security**: For security reasons, the PasarGuard dashboard is not accessible via IP address +- 🌐 **SSL Required**: You must [obtain SSL certificate](https://PasarGuard.github.io/PasarGuard/en/examples/issue-ssl-certificate) and access your PasarGuard dashboard by opening a web browser and navigating to `https://YOUR_DOMAIN:8000/dashboard/` + +### 🔗 Local Access via SSH ```bash ssh -L 8000:localhost:8000 user@serverip ``` -Finally, you can enter the following link in your browser to access your PasarGuard dashboard: +Then navigate to the following link in your browser: +``` http://localhost:8000/dashboard/ +``` -You will lose access to the dashboard as soon as you close the SSH terminal. Therefore, this method is recommended only for testing purposes. +⚠️ **Note**: You will lose access to the dashboard as soon as you close the SSH terminal. Therefore, this method is recommended only for testing purposes. -Next, you need to create a sudo admin for logging into the PasarGuard dashboard by the following command +### 👨‍💼 Create Admin ```bash pasarguard cli admin create --sudo ``` -That's it! You can login to your dashboard using these credentials - -To see the help message of the PasarGuard script, run the following command +### ❓ Help ```bash pasarguard --help ``` +## 🔧 Manual Install (Advanced) + +
+ If you are eager to run the project using the source code, check the section below -
-

Manual install (advanced)

+
-Install xray on your machine +
+

🔧 Manual install (advanced)

-You can install it using [Xray-install](https://github.com/XTLS/Xray-install) +### 🚀 Step 1: Install Xray ```bash bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install ``` -Clone this project and install the dependencies (you need Python >= 3.12.7) +### 📥 Step 2: Clone Project ```bash git clone https://github.com/PasarGuard/panel.git @@ -189,15 +213,15 @@ curl -LsSf https://astral.sh/uv/install.sh | sh uv sync ``` -Alternatively, to have an isolated environment you can use [Python Virtualenv](https://pypi.org/project/virtualenv/) +> **Note**: You need Python >= 3.12.7 -Then run the following command to run the database migration scripts +### 🗄️ Step 3: Database Migration ```bash uv run alembic upgrade head ``` -If you want to use `PasarGuard-cli`, you should link it to a file in your `$PATH`, make it executable, and install the auto-completion: +### 💻 Step 4: Install CLI ```bash sudo ln -s $(pwd)/PasarGuard-cli.py /usr/bin/pasarguard-cli @@ -205,35 +229,31 @@ sudo chmod +x /usr/bin/pasarguard-cli pasarguard-cli completion install ``` -Now it's time to configuration - -Make a copy of `.env.example` file, take a look and edit it using a text editor like `nano`. - -You probably like to modify the admin credentials. +### ⚙️ Step 5: Configuration ```bash cp .env.example .env nano .env ``` -> Check [configurations](#configuration) section for more information +> 📖 Check [configurations](#configuration) section for more information -Eventually, launch the application using command below +### 🚀 Step 6: Run Application ```bash uv run main.py ``` -To launch with linux systemctl (copy PasarGuard.service file to `/var/lib/pasarguard/PasarGuard.service`) +### 🔧 Run with systemctl -``` +```bash systemctl enable /var/lib/pasarguard/PasarGuard.service systemctl start PasarGuard ``` -To use with nginx +### 🌐 Nginx Configuration -``` +```nginx server { listen 443 ssl http2; listen [::]:443 ssl http2; @@ -269,9 +289,9 @@ server { } ``` -or +### 🌐 Simple Nginx Configuration -``` +```nginx server { listen 443 ssl http2; listen [::]:443 ssl http2; @@ -289,128 +309,223 @@ server { } ``` +### 🌐 Dashboard Access + By default the app will be run on `http://localhost:8000/dashboard`. You can configure it using changing the `UVICORN_HOST` and `UVICORN_PORT` environment variables.
-# Configuration +# ⚙️ Configuration -> You can set settings below using environment variables or placing them in `.env` file. +
+You can set settings below using environment variables or placing them in `.env` file. +
-| Variable | Description | -| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | -| SUDO_USERNAME | Superuser's username | -| SUDO_PASSWORD | Superuser's password | -| SQLALCHEMY_DATABASE_URL | Database URL ([SQLAlchemy's docs](https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls)) | -| SQLALCHEMY_POOL_SIZE | (default: `10`) | -| SQLALCHEMY_MAX_OVERFLOW | (default: `30`) | -| UVICORN_HOST | Bind application to this host (default: `0.0.0.0`) | -| UVICORN_PORT | Bind application to this port (default: `8000`) | -| UVICORN_UDS | Bind application to a UNIX domain socket | -| UVICORN_SSL_CERTFILE | SSL certificate file to have application on https | -| UVICORN_SSL_KEYFILE | SSL key file to have application on https | -| UVICORN_SSL_CA_TYPE | Type of authority SSL certificate. Use `private` for testing self-signed CA (default: `public`) | -| XRAY_JSON | Path of Xray's json config file (default: `xray_config.json`) | -| CUSTOM_TEMPLATES_DIRECTORY | Customized templates directory (default: `app/templates`) | -| CLASH_SUBSCRIPTION_TEMPLATE | The template that will be used for generating clash configs (default: `clash/default.yml`) | -| SUBSCRIPTION_PAGE_TEMPLATE | The template used for generating subscription info page (default: `subscription/index.html`) | -| XRAY_SUBSCRIPTION_TEMPLATE | The template that will be used for generating xray configs (default: `xray/default.yml`) | -| SINGBOX_SUBSCRIPTION_TEMPLATE | The template that will be used for generating xray configs (default: `xray/default.yml`) | -| HOME_PAGE_TEMPLATE | Decoy page template (default: `home/index.html`) | -| JWT_ACCESS_TOKEN_EXPIRE_MINUTES | Expire time for the Access Tokens in minutes, `0` considered as infinite (default: `1440`) | -| DOCS | Whether API documents should be available on `/docs` and `/redoc` or not (default: `False`) | -| DEBUG | Debug mode for development (default: `False`) | -| USERS_AUTODELETE_DAYS | Delete expired (and optionally limited users) after this many days (Negative values disable this feature, default: `-1`) | -| USER_AUTODELETE_INCLUDE_LIMITED_ACCOUNTS | Whether to include limited accounts in the auto-delete feature (default: `False`) | -| XRAY_SUBSCRIPTION_PATH | You can change your api path for subscrtiption (default: `sub`) | -| ENABLE_RECORDING_NODES_STATS | Due to high amount of data, this job is only available for postgresql and timescaledb | +## 📋 Configuration Variables Table -# Documentation +| Variable | Description | +|:---:|:---:| +| `SUDO_USERNAME` | Superuser's username | +| `SUDO_PASSWORD` | Superuser's password | +| `SQLALCHEMY_DATABASE_URL` | Database URL | +| `SQLALCHEMY_POOL_SIZE` | Pool size (default: 10) | +| `SQLALCHEMY_MAX_OVERFLOW` | Max overflow (default: 30) | +| `UVICORN_HOST` | Bind host (default: 0.0.0.0) | +| `UVICORN_PORT` | Bind port (default: 8000) | +| `UVICORN_UDS` | UNIX domain socket | +| `UVICORN_SSL_CERTFILE` | SSL certificate file | +| `UVICORN_SSL_KEYFILE` | SSL key file | +| `UVICORN_SSL_CA_TYPE` | CA type (default: public) | +| `XRAY_JSON` | Xray config file path | +| `CUSTOM_TEMPLATES_DIRECTORY` | Custom templates directory | +| `CLASH_SUBSCRIPTION_TEMPLATE` | Clash subscription template | +| `SUBSCRIPTION_PAGE_TEMPLATE` | Subscription page template | +| `XRAY_SUBSCRIPTION_TEMPLATE` | Xray subscription template | +| `SINGBOX_SUBSCRIPTION_TEMPLATE` | SingBox subscription template | +| `HOME_PAGE_TEMPLATE` | Home page template | +| `JWT_ACCESS_TOKEN_EXPIRE_MINUTES` | Token expire time (minutes) | +| `DOCS` | Show API docs | +| `DEBUG` | Debug mode | +| `USERS_AUTODELETE_DAYS` | Auto-delete expired users | +| `USER_AUTODELETE_INCLUDE_LIMITED_ACCOUNTS` | Include limited accounts | +| `XRAY_SUBSCRIPTION_PATH` | Subscription API path | +| `ENABLE_RECORDING_NODES_STATS` | Record node statistics | -The [PasarGuard Documentation](https://PasarGuard.github.io/PasarGuard) provides all the essential guides to get you started, available in three languages: Farsi, English, and Russian. This documentation requires significant effort to cover all aspects of the project comprehensively. We welcome and appreciate your contributions to help us improve it. You can contribute on this [GitHub repository](https://github.com/PasarGuard/PasarGuard.github.io). +# 📚 Documentation -# API +
-PasarGuard provides a REST API that enables developers to interact with PasarGuard services programmatically. To view the API documentation in Swagger UI or ReDoc, set the configuration variable `DOCS=True` and navigate to the `/docs` and `/redoc`. +The [PasarGuard Documentation](https://PasarGuard.github.io/PasarGuard) provides all the essential guides to get you started, available in three languages: Farsi, English, and Russian. -# Backup +
-It's always a good idea to backup your PasarGuard files regularly to prevent data loss in case of system failures or accidental deletion. Here are the steps to backup PasarGuard: +## 🤝 Contributing to Documentation -1. By default, all PasarGuard important files are saved in `/var/lib/pasarguard` (Docker versions). Copy the entire `/var/lib/pasarguard` directory to a backup location of your choice, such as an external hard drive or cloud storage. -2. Additionally, make sure to backup your env file, which contains your configuration variables, and also, your Xray config file. If you installed PasarGuard using PasarGuard-scripts (recommended installation approach), the env and other configurations should be inside `/opt/pasarguard/` directory. +This documentation requires significant effort to cover all aspects of the project comprehensively. We welcome and appreciate your contributions to help us improve it. -PasarGuard's backup service efficiently zips all necessary files and sends them to your specified Telegram bot. It supports SQLite, MySQL, and MariaDB databases. One of its key features is automation, allowing you to schedule backups every hour. There are no limitations concerning Telegram's upload limits for bots; if a file exceeds the limit, it will be split and sent in multiple parts. Additionally, you can initiate an immediate backup at any time. +[Documentation GitHub Repository](https://github.com/PasarGuard/PasarGuard.github.io) -Install the Latest Version of PasarGuard Command: +# 🔌 API -```bash -sudo bash -c "$(curl -sL https://github.com/PasarGuard/scripts/raw/main/pasarguard.sh)" @ install-script -``` +
-Setup the Backup Service: +PasarGuard provides a REST API that enables developers to interact with PasarGuard services programmatically. -```bash -pasarguard backup-service -``` +
+ +## 📖 View API Documentation + +To view the API documentation in Swagger UI or ReDoc, set the configuration variable `DOCS=True` and navigate to the `/docs` and `/redoc`. + +# 💾 Backup -Get an Immediate Backup: +
+ +## 🔄 Automated Backup Service + +It's always a good idea to backup your PasarGuard files regularly to prevent data loss in case of system failures or accidental deletion. + +
+ +## 📋 Backup Steps + +1. **📁 Important Files**: By default, all PasarGuard important files are saved in `/var/lib/pasarguard` +2. **⚙️ Configuration Files**: Make sure to backup your env file and Xray config file +3. **📂 Configuration Path**: If you installed PasarGuard using PasarGuard-scripts, configurations should be inside `/opt/pasarguard/` directory + +## 🤖 Telegram Backup Service + +PasarGuard's backup service efficiently zips all necessary files and sends them to your specified Telegram bot. + +### ✨ Features + +- ✅ Supports SQLite, MySQL and MariaDB +- ✅ Automation with hourly backup scheduling +- ✅ No Telegram upload limits (large files are split) +- ✅ Immediate backup at any time + +### 🚀 Installation & Setup ```bash +# Install latest PasarGuard script +sudo bash -c "$(curl -sL https://github.com/PasarGuard/scripts/raw/main/pasarguard.sh)" @ install-script + +# Setup backup service +pasarguard backup-service + +# Get immediate backup pasarguard backup ``` -By following these steps, you can ensure that you have a backup of all your PasarGuard files and data, as well as your configuration variables and Xray configuration, in case you need to restore them in the future. Remember to update your backups regularly to keep them up-to-date. +## 💡 Important Notes + +- 🔄 Update your backups regularly +- 📁 Backup all data and configuration files +- 🔐 Don't forget env files and Xray configuration + +# 🤖 Telegram Bot + +
-# Telegram Bot +PasarGuard comes with an integrated Telegram bot that can handle server management, user creation and removal, and send notifications. -PasarGuard comes with an integrated Telegram bot that can handle server management, user creation and removal, and send notifications. This bot can be easily enabled by following a few simple steps, and it provides a convenient way to interact with PasarGuard without having to log in to the server every time. +
-To enable Telegram Bot: +## ⚙️ Enable Telegram Bot -1. set `TELEGRAM_API_TOKEN` to your bot's API Token -2. set `TELEGRAM_ADMIN_ID` to your Telegram account's numeric ID, you can get your ID from [@userinfobot](https://t.me/userinfobot) +This bot can be easily enabled by following a few simple steps, and it provides a convenient way to interact with PasarGuard without having to log in to the server every time. -# PasarGuard CLI +### 🔧 Setup Steps + +1. **🔑 Set API Token**: Set `TELEGRAM_API_TOKEN` to your bot's API Token +2. **👤 Set Admin ID**: Set `TELEGRAM_ADMIN_ID` to your Telegram account's numeric ID + +### 📱 Get Telegram ID + +You can get your ID from [@userinfobot](https://t.me/userinfobot). + +# 💻 PasarGuard CLI + +
PasarGuard comes with an integrated CLI named `PasarGuard-cli` which allows administrators to have direct interaction with it. -If you've installed PasarGuard using easy install script, you can access the cli commands by running +
+ +## 🚀 Using CLI + +If you've installed PasarGuard using easy install script, you can access the cli commands by running: ```bash pasarguard cli [OPTIONS] COMMAND [ARGS]... ``` +## 📖 CLI Documentation + For more information, You can read [PasarGuard CLI's documentation](./cli/README.md). -# PasarGuard TUI +# 🖥️ PasarGuard TUI + +
PasarGuard also provides a Terminal User Interface (TUI) for interactive management directly within your terminal. +
+ +## 🚀 Using TUI + If you've installed PasarGuard using the easy install script, you can access the TUI by running: ```bash pasarguard tui ``` +## 📖 TUI Documentation + For more information, you can read [PasarGuard TUI's documentation](./tui/README.md). -# Node +# 🌐 Node + +
+ +The PasarGuard project introduces the [node](https://github.com/PasarGuard/node), which revolutionizes infrastructure distribution. + +
+ +## ✨ Node Benefits + +With node, you can distribute your infrastructure across multiple locations, unlocking benefits such as: + +- 🔄 **Redundancy** +- ⚡ **High Availability** +- 📈 **Scalability** +- 🔧 **Flexibility** + +## 🎯 User Flexibility + +node empowers users to connect to different servers, offering them the flexibility to choose and connect to multiple servers instead of being limited to only one server. + +## 📖 Node Documentation -The PasarGuard project introduces the [node](https://github.com/PasarGuard/node), which revolutionizes infrastructure distribution. With node, you can distribute your infrastructure across multiple locations, unlocking benefits such as redundancy, high availability, scalability, flexibility. node empowers users to connect to different servers, offering them the flexibility to choose and connect to multiple servers instead of being limited to only one server. For more detailed information and installation instructions, please refer to the [PasarGuard-node official documentation](https://github.com/PasarGuard/node) -# Webhook notifications +# 🔔 Webhook notifications + +
You can set a webhook address and PasarGuard will send the notifications to that address. -the requests will be sent as a post request to the adress provided by `WEBHOOK_ADDRESS` with `WEBHOOK_SECRET` as `x-webhook-secret` in the headers. +
-Example request sent from PasarGuard: +## 📡 How it Works -``` +The requests will be sent as a post request to the address provided by `WEBHOOK_ADDRESS` with `WEBHOOK_SECRET` as `x-webhook-secret` in the headers. + +## 📋 Example Request + +```http Headers: Host: 0.0.0.0:9000 User-Agent: python-requests/2.28.1 @@ -421,38 +536,70 @@ x-webhook-secret: something-very-very-secret Content-Length: 107 Content-Type: application/json - - Body: {"username": "PasarGuard_test_user", "action": "user_updated", "enqueued_at": 1680506457.636369, "tries": 0} ``` -Different action typs are: `user_created`, `user_updated`, `user_deleted`, `user_limited`, `user_expired`, `user_disabled`, `user_enabled` +## 🎯 Action Types + +Different action types are: `user_created`, `user_updated`, `user_deleted`, `user_limited`, `user_expired`, `user_disabled`, `user_enabled` + +# 💝 Donation + +
+ +If you found PasarGuard useful and would like to support its development, you can make a donation. + +
-# Donation +## 🎯 Support the Project -If you found PasarGuard useful and would like to support its development, you can make a donation, [Click Here](https://donate.gozargah.pro) +[Make a Donation](https://donate.gozargah.pro) Thank you for your support! -# License +# 📄 License + +
Made in [Unknown!] and Published under [AGPL-3.0](./LICENSE). -# Contributors +
+ +# 👥 Contributors + +
+ +We ❤️‍🔥 contributors! If you'd like to contribute, please check out our [Contributing Guidelines](CONTRIBUTING.md) and feel free to submit a pull request or open an issue. -We ❤️‍🔥 contributors! If you'd like to contribute, please check out our [Contributing Guidelines](CONTRIBUTING.md) and feel free to submit a pull request or open an issue. We also welcome you to join our [Telegram](https://t.me/Pasar_Guard) group for either support or contributing guidance. +
+ +## 🤝 Join the Community + +We also welcome you to join our [Telegram](https://t.me/Pasar_Guard) group for either support or contributing guidance. + +## 🐛 Help Project Progress Check [open issues](https://github.com/PasarGuard/panel/issues) to help the progress of this project. -

+

+ +## 🙏 Thanks to Contributors + Thanks to the all contributors who have helped improve PasarGuard: -

-

+ +

+ +
+ -

-

- Made with contrib.rocks -

+ +
+ +
+ +Made with contrib.rocks + +
diff --git a/app/utils/system.py b/app/utils/system.py index 5fbc20717..68b0be637 100644 --- a/app/utils/system.py +++ b/app/utils/system.py @@ -70,6 +70,7 @@ def get_public_ip(): except httpx.RequestError: pass + sock = None try: sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) sock.connect(("8.8.8.8", 80)) @@ -79,7 +80,8 @@ def get_public_ip(): except (socket.error, IndexError): pass finally: - sock.close() + if sock: + sock.close() return "127.0.0.1" diff --git a/main.py b/main.py index e3043aa60..03dd0e69a 100644 --- a/main.py +++ b/main.py @@ -59,7 +59,7 @@ def check_and_modify_ip(ip_address: str) -> str: else: return "localhost" - except ValueError: + except (ValueError, socket.gaierror): return "localhost"