Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 32 additions & 25 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


# Contribute to PasarGuard

Thanks for considering contributing to **PasarGuard**!
Expand All @@ -8,17 +6,17 @@ Thanks for considering contributing to **PasarGuard**!

Please **don’t use GitHub Issues** to ask questions. Instead, use one of the following platforms:

* 💬 Telegram: [@Pasar_Guard](https://t.me/pasar_guard)
* 🗣️ GitHub Discussions: [PasarGuard Discussions](https://github.com/pasarguard/panel/discussions)
- 💬 Telegram: [@Pasar_Guard](https://t.me/pasar_guard)
- 🗣️ GitHub Discussions: [PasarGuard Discussions](https://github.com/pasarguard/panel/discussions)

## 🐞 Reporting Issues

When reporting a bug or issue, please include:

* ✅ What you expected to happen
* ❌ What actually happened (include server logs or browser errors)
* ⚙️ Your `xray` JSON config and `.env` settings (censor sensitive info)
* 🔢 Your PasarGuard version and Docker version (if applicable)
- ✅ What you expected to happen
- ❌ What actually happened (include server logs or browser errors)
- ⚙️ Your `xray` JSON config and `.env` settings (censor sensitive info)
- 🔢 Your PasarGuard version and Docker version (if applicable)

---

Expand All @@ -28,15 +26,15 @@ If there's no open issue for your idea, consider opening one for discussion **be

You can contribute to any issue that:

* Has no PR linked
* Has no maintainer assigned
- Has no PR linked
- Has no maintainer assigned

No need to ask for permission!

## 🔀 Branching Strategy

* Always branch off of the `next` branch
* Keep `master` stable and production-ready
- Always branch off of the `next` branch
- Keep `main` stable and production-ready

---

Expand All @@ -46,6 +44,7 @@ No need to ask for permission!
.
├── app # Backend code (FastAPI - Python)
├── cli # CLI code (Typer - Python)
├── tui # TUI code (Textual - Python)
├── dashboard # Frontend code (React - TypeScript)
└── tests # API tests
```
Expand All @@ -56,19 +55,19 @@ No need to ask for permission!

The backend is built with **FastAPI** and **SQLAlchemy**:

* **Pydantic models**: `app/models`
* **Database models & operations**: `app/db`
* **backend logic should go in**: `app/operations`
* **Migrations (Alembic)**: `app/db/migrations`
- **Pydantic models**: `app/models`
- **Database models & operations**: `app/db`
- **backend logic should go in**: `app/operations`
- **Migrations (Alembic)**: `app/db/migrations`

🧩 **Note**: Ensure **all backend logic is organized and implemented in the `operations` module**. This keeps route handling, database access, and service logic clearly separated and easier to maintain.

### 📘 API Docs (Swagger / ReDoc)

Enable the `DOCS` flag in your `.env` file to access:

* Swagger UI: [http://localhost:8000/docs](http://localhost:8000/docs)
* ReDoc: [http://localhost:8000/redoc](http://localhost:8000/redoc)
- Swagger UI: [http://localhost:8000/docs](http://localhost:8000/docs)
- ReDoc: [http://localhost:8000/redoc](http://localhost:8000/redoc)

### 🎯 Code Formatting

Expand All @@ -95,8 +94,8 @@ make run-migration

The frontend is located in the `dashboard` directory and is built using:

* **React + TypeScript**
* **Tailwind CSS (Shadcn UI)**
- **React + TypeScript**
- **Tailwind CSS (Shadcn UI)**

To build:

Expand All @@ -108,17 +107,25 @@ Remove the `dashboard/build` directory and restart the Python backend — the fr

### 🧩 Component Guidelines

* Follow **Tailwind + Shadcn** best practices
* Keep components **single-purpose**
* Prioritize **readability** and **maintainability**
- Follow **Tailwind + Shadcn** best practices
- Keep components **single-purpose**
- Prioritize **readability** and **maintainability**

---

## 🛠️ PasarGuard CLI

PasarGuard’s CLI is built using [Textual](https://textual.textualize.io/).
PasarGuard’s CLI is built using [Typer](https://typer.tiangolo.com/).

- CLI codebase: `cli/`

---

## 🛠️ PasarGuard TUI

PasarGuard’s TUI is built using [Textual](https://textual.textualize.io/).

* CLI codebase: `cli/`
- TUI codebase: `tui/`

---

Expand Down
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ WORKDIR /code

ENV PATH="/code/.venv/bin:$PATH"

COPY cli_wrapper.sh /usr/bin/marzban-cli
RUN chmod +x /usr/bin/marzban-cli
COPY cli_wrapper.sh /usr/bin/pasarguard-cli
RUN chmod +x /usr/bin/pasarguard-cli

COPY tui_wrapper.sh /usr/bin/pasarguard-tui
RUN chmod +x /usr/bin/pasarguard-tui

RUN chmod +x /code/start.sh

ENTRYPOINT ["/code/start.sh"]
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ run:
run-cli:
@uv run pasarguard-cli.py

# run pasarguard-tui
.PHONY: run-tui
run-tui:
@uv run pasarguard-tui.py


# Run tests
.PHONY: test
test:
Expand Down
12 changes: 12 additions & 0 deletions README-fa.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,18 @@ pasarguard cli [OPTIONS] COMMAND [ARGS]...

برای اطلاعات بیشتر، می توانید [مستندات CLI پاسارگارد](./cli/README.md) را مطالعه کنید.

# رابط کاربری متنی (TUI) پاسارگارد

پاسارگارد همچنین یک رابط کاربری متنی (TUI) برای مدیریت تعاملی مستقیم در ترمینال شما فراهم می کند.

اگر پاسارگارد را با استفاده از اسکریپت نصب آسان نصب کرده اید، می توانید با اجرای دستور زیر به TUI دسترسی پیدا کنید:

```bash
pasarguard tui
```

برای اطلاعات بیشتر، می توانید [مستندات TUI پاسارگارد](./tui/README.md) را مطالعه کنید.

# نود

پروژه پاسارگارد [نود](https://github.com/PasarGuard/node) را معرفی می کند که توزیع زیرساخت را متحول می کند. با نود، می توانید زیرساخت خود را در چندین مکان توزیع کنید و از مزایایی مانند افزونگی، در دسترس بودن بالا، مقیاس پذیری و انعطاف پذیری بهره مند شوید. نود به کاربران این امکان را می دهد که به سرورهای مختلف متصل شوند و به آنها انعطاف پذیری انتخاب و اتصال به چندین سرور را به جای محدود شدن به تنها یک سرور ارائه می دهد.
Expand Down
12 changes: 12 additions & 0 deletions README-ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,18 @@ pasarguard cli [OPTIONS] COMMAND [ARGS]...

Для получения дополнительной информации можно ознакомиться с [документацией по PasarGuard CLI](./cli/README.md).

# Пользовательский интерфейс терминала (TUI) PasarGuard

PasarGuard также предоставляет пользовательский интерфейс терминала (TUI) для интерактивного управления непосредственно в вашем терминале.

Если вы установили PasarGuard с помощью простого установочного скрипта, вы можете получить доступ к TUI, запустив:

```bash
pasarguard tui
```

Для получения дополнительной информации вы можете ознакомиться с [документацией по TUI PasarGuard](./tui/README.md).

# Node

Проект PasarGuard представляет [node](https://github.com/PasarGuard/node), который помогает Вам в распределении инфраструктуры. С помощью node можно распределить инфраструктуру по нескольким узлам, получив такие преимущества, как высокая доступность, масштабируемость и гибкость. node позволяет пользователям подключаться к различным серверам, предоставляя им гибкость в выборе, а не ограничиваться только одним сервером.
Expand Down
12 changes: 12 additions & 0 deletions README-zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,18 @@ pasarguard cli [OPTIONS] COMMAND [ARGS]...

更多信息,您可以阅读[PasarGuard CLI的文档](./cli/README.md)。

# PasarGuard 终端用户界面 (TUI)

PasarGuard 还提供了一个终端用户界面 (TUI),用于直接在您的终端中进行交互式管理。

如果您使用简易安装脚本安装了 PasarGuard,您可以通过运行以下命令访问 TUI:

```bash
pasarguard tui
```

更多信息,您可以阅读 [PasarGuard TUI 的文档](./tui/README.md)。

# Node

PasarGuard项目引入了[node](https://github.com/PasarGuard/node),它彻底改变了基础设施的分布。通过node,您可以将您的基础设施分布到多个位置,从而获得冗余、高可用性、可伸缩性、灵活性等好处。node使用户能够连接到不同的服务器,为他们提供了选择和连接多个服务器的灵活性,而不是仅限于一个服务器。
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,18 @@ pasarguard cli [OPTIONS] COMMAND [ARGS]...

For more information, You can read [PasarGuard CLI's documentation](./cli/README.md).

# PasarGuard TUI

PasarGuard also provides a Terminal User Interface (TUI) for interactive management directly within your terminal.

If you've installed PasarGuard using the easy install script, you can access the TUI by running:

```bash
pasarguard tui
```

For more information, you can read [PasarGuard TUI's documentation](./tui/README.md).

# Node

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.
Expand Down
9 changes: 0 additions & 9 deletions app/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ def format_validation_error(error: ValidationError) -> str:
return "\n".join([e["loc"][0].replace("_", " ").capitalize() + ": " + e["msg"] for e in error.errors()])


def format_cli_validation_error(errors: ValidationError, notify: callable):
for error in errors.errors():
for err in error["msg"].split(";"):
notify(
title=f"Error: {error['loc'][0].replace('_', ' ').capitalize()}",
message=err.strip(),
severity="error",
)


def escape_tg_html(list: tuple[str]) -> tuple[str]:
"""Escapes HTML special characters for the telegram HTML parser."""
Expand Down
66 changes: 42 additions & 24 deletions cli/README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,60 @@
# PasarGuard CLI

A modern, interactive command-line interface for managing PasarGuard, built with Textual.
A modern, type-safe command-line interface for managing PasarGuard, built with Typer.

## Features

- 🎯 Interactive TUI (Text User Interface)
- 📱 Responsive design with dark mode support
- ⌨️ Keyboard shortcuts for quick navigation
- 🔄 Real-time updates
- 📊 Rich data visualization
- 🔒 Secure admin management
- 🎯 Type-safe CLI with rich output
- 📊 Beautiful tables and panels
- 🔒 Secure admin management
- 📈 System status monitoring
- ⌨️ Interactive prompts and confirmations

## Installation

The CLI is included with PasarGuard and can be used directly:

```bash
PasarGuard cli --help

# Or from the project root
uv run PasarGuard-cli.py --help
```

## Usage

### Starting the CLI
### General Commands

```bash
pasarguard cli
# Show version
pasarguard cli version

# Show help
pasarguard cli --help
```

### Keyboard Shortcuts
### Admin Management

#### Global Commands
```bash
# List all admins
pasarguard cli admins --list

- `q` - Quit the application
- `?` - Show help
# Create new admin
pasarguard cli admins --create username

#### Admin Section
# Delete admin
pasarguard cli admins --delete username

- `c` - Create new admin
- `m` - Modify admin
- `r` - Reset admin usage
- `d` - Delete admin
- `i` - Import admins from environment
# Modify admin (password and sudo status)
PasarGuard cli admins --modify username

### Admin Management
# Reset admin usage
pasarguard cli admins --reset-usage username
```

- Create, modify, and delete admin accounts
- Reset admin usage statistics
- Import admins from environment variables
- View admin details and status
### System Information

```bash
# Show system status
PasarGuard cli system
```
Loading