Help us shape the future of Go! Take the 2026 Go Developer Survey

server

command module
v1.17.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

README

PPanel 服务端

License Go Version Go Report Card Docker CI/CD

PPanel 是一个纯净、专业、完美的开源代理面板工具,旨在成为您学习和实际使用的理想选择。

中文 | English | 报告问题 | 功能请求

第一条
人人生而自由,在尊严与权利上一律平等。
他们赋有理性与良知,应当以兄弟般的精神彼此相待。

第十二条
任何人的隐私、家庭、住宅和通信不得任意干涉,其名誉与荣誉不得加以攻击。
人人有权受到法律的保护,以免遭受这种干涉或攻击。

第十九条
人人有思想与表达的自由;此项自由包括持有主张而不受干预,以及通过任何媒介、无论国界,自由寻求、接受和传播信息与思想。

来源: United Nations – Universal Declaration of Human Rights (UN.org)

📋 概述

PPanel 服务端是 PPanel 项目的后端组件,为代理服务提供强大的 API 和核心功能。它基于 Go 语言开发,注重性能、安全性和可扩展性。

核心特性
  • 多协议支持:支持 Shadowsocks、V2Ray、Trojan 等多种加密协议。
  • 隐私保护:不收集用户日志,确保隐私和安全。
  • 极简设计:简单易用,保留完整的业务逻辑。
  • 用户管理:完善的认证和授权系统。
  • 订阅管理:处理用户订阅和服务开通。
  • 支付集成:支持多种支付网关。
  • 订单管理:跟踪和处理用户订单。
  • 工单系统:内置客户支持和问题跟踪。
  • 节点管理:监控和控制服务器节点。
  • API 框架:提供全面的 RESTful API,供前端集成。

🚀 快速开始

前提条件
  • Go:1.25 或更高版本
  • Docker:可选,用于容器化部署
  • Git:用于克隆仓库
通过源代码运行
  1. 克隆仓库:

    git clone https://github.com/perfect-panel/ppanel-server.git
    cd ppanel-server
    
  2. 安装依赖:

    go mod download
    
  3. 构建项目:

    make linux-amd64
    
  4. 启动服务器:

    ./ppanel-server-linux-amd64 run --config etc/ppanel.yaml
    
🐳 Docker 部署
  1. 构建 Docker 镜像:

    docker buildx build --platform linux/amd64 -t ppanel-server:latest .
    
  2. 运行容器:

    docker run --rm -p 8080:8080 -v $(pwd)/etc:/app/etc ppanel-server:latest
    
  3. 使用 Docker Compose(创建 docker-compose.yml):

    version: '3.8'
    services:
      ppanel-server:
        image: ppanel-server:latest
        ports:
          - "8080:8080"
        volumes:
          - ./etc:/app/etc
        environment:
          - TZ=Asia/Shanghai
    

    运行:

    docker-compose up -d
    
  4. 从 Docker Hub 拉取(CI/CD 发布后):

    docker pull ppanel/ppanel-server:latest
    docker run --rm -p 8080:8080 ppanel/ppanel-server:latest
    

📖 API 文档

API 文档使用 Handler 上的 Swaggo 注解生成,并通过 Hertz 实际注册路由进行完整性校验。根目录的 ppanel.json 是完整 Swagger 2.0 文档:

ppanel.json

修改路由、请求 DTO 或响应 DTO 后,运行:

./script/generate-swagger.sh
go test ./internal/route -run '^TestSwagger' -count=1

master 分支的 GitHub Actions 会生成 ppanel.json 以及 admin.json、user.json、common.json、node.json 分类文档,并同步到 perfect-panel/ppanel-docs 的 public/swagger 目录。现有 GH_TOKEN secret 需要对文档仓库具有 Contents 写权限。

🔗 相关项目

项目 描述 链接
PPanel Web PPanel 前端应用 GitHub
PPanel User Web PPanel 用户界面 预览
PPanel Admin Web PPanel 管理员界面 预览

🌐 官方网站

访问 ppanel.dev 获取更多信息。

🏛 系统架构

Architecture Diagram

📁 目录结构

.
├── cmd/              # 应用程序入口
├── doc/              # 文档
├── etc/              # 配置文件(如 ppanel.yaml)
├── initialize/       # 系统初始化
├── internal/         # 内部模块
│   ├── config/       # 配置文件解析
│   ├── handler/      # HTTP 处理程序
│   ├── middleware/   # HTTP 中间件
│   ├── logic/        # 业务逻辑
│   ├── model/        # 数据模型
│   ├── svc/          # 服务层
│   └── types/        # 类型定义
├── pkg/              # 公共工具代码
├── queue/            # 队列服务
├── scheduler/        # 定时任务
├── script/           # 安装脚本
├── scripts/          # 性能测试与维护脚本
├── go.mod            # Go 模块定义
├── Makefile          # 构建自动化
└── Dockerfile        # Docker 配置

💻 开发

多平台构建

使用 Makefile 构建多种平台(如 Linux、Windows、macOS):

make all  # 构建 linux-amd64、darwin-amd64、windows-amd64
make linux-arm64  # 构建特定平台

支持的平台包括:

  • Linux:386、amd64、arm64、armv5-v7、mips、riscv64、loong64 等
  • Windows:386、amd64、arm64、armv7
  • macOS:amd64、arm64
  • FreeBSD:amd64、arm64

🤝 贡献

欢迎各种贡献,包括功能开发、错误修复和文档改进。请查看贡献指南了解详情。

✨ 特别感谢

感谢以下优秀的开源项目,它们为本项目的开发提供了强大的支持! 🚀

项目 描述 项目 描述
Hertz
Hertz Stars
高性能的 Go HTTP 框架
Gorm
Gorm
Gorm Stars
功能强大的 Go ORM 框架
Asynq
Asynq
Asynq Stars
Go 语言的异步任务队列
Go-Swagger
Go-Swagger
Go-Swagger Stars
完整的 Go Swagger 工具集

🎉 致敬开源:感谢开源社区,让开发变得更简单、更高效!欢迎为这些项目点亮 ⭐,支持开源事业!

📄 许可证

本项目采用 GPL-3.0 许可证 授权。

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
edgeauth
Package edgeauth authenticates Cloudflare edge-subscribe Workers.
Package edgeauth authenticates Cloudflare edge-subscribe Workers.
eventbus
Package eventbus is the domain-event bus riding the asynq message queue (ADR-001 step-6 preparation).
Package eventbus is the domain-event bus riding the asynq message queue (ADR-001 step-6 preparation).
module/billing
Package billing is the facade of the billing module.
Package billing is the facade of the billing module.
module/billing/entity/wallet
Package wallet holds the billing domain's money entities: the wallet row (the single source of truth for balance/gift/commission since migration 02144) and withdrawal records (ADR-001 step 5).
Package wallet holds the billing domain's money entities: the wallet row (the single source of truth for balance/gift/commission since migration 02144) and withdrawal records (ADR-001 step 5).
module/billing/internal/activation
Package activation implements the billing-domain stages of the paid-order activation saga: the recharge wallet credit, the referral commission and the final settlement.
Package activation implements the billing-domain stages of the paid-order activation saga: the recharge wallet credit, the referral commission and the final settlement.
module/billing/internal/adminorder
Package adminorder implements the admin-side order management subdomain of the billing module.
Package adminorder implements the admin-side order management subdomain of the billing module.
module/billing/internal/adminpayment
Package adminpayment implements the payment-method management subdomain of the billing module.
Package adminpayment implements the payment-method management subdomain of the billing module.
module/billing/internal/callbacks
Package callbacks implements the payment gateway callback subdomain of the billing module: it authenticates EPay/Stripe/Alipay/Cryptomus notifications, verifies them against the order's immutable payment expectation, re-confirms with the gateway and settles the payment.
Package callbacks implements the payment gateway callback subdomain of the billing module: it authenticates EPay/Stripe/Alipay/Cryptomus notifications, verifies them against the order's immutable payment expectation, re-confirms with the gateway and settles the payment.
module/billing/internal/checkout
Package checkout implements the user-facing money flows of the billing module: purchase, renewal, traffic reset, recharge, order preview and close.
Package checkout implements the user-facing money flows of the billing module: purchase, renewal, traffic reset, recharge, order preview and close.
module/billing/internal/coupon
Package coupon implements the coupon management subdomain of the billing module.
Package coupon implements the coupon management subdomain of the billing module.
module/billing/internal/portal
Package portal implements the guest storefront subdomain of the billing module: guest pre-orders, gateway/balance checkout, order status polling with session exchange, and the public plan/payment listings.
Package portal implements the guest storefront subdomain of the billing module: guest pre-orders, gateway/balance checkout, order status polling with session exchange, and the public plan/payment listings.
module/billing/internal/settle
Package settle holds the one settlement primitive shared by the checkout and payment-callback subdomains: marking a gateway-verified payment as paid and enqueueing activation.
Package settle holds the one settlement primitive shared by the checkout and payment-callback subdomains: marking a gateway-verified payment as paid and enqueueing activation.
module/billing/internal/userorder
Package userorder implements the user-facing order query subdomain of the billing module (the checkout flows join as migration proceeds).
Package userorder implements the user-facing order query subdomain of the billing module (the checkout flows join as migration proceeds).
module/billing/internal/v2
Package v2 implements the V2 order orchestration subdomain of the billing module: idempotent create-and-checkout, guest checkout capabilities and the SSE event-stream tickets.
Package v2 implements the V2 order orchestration subdomain of the billing module: idempotent create-and-checkout, guest checkout capabilities and the SSE event-stream tickets.
module/billing/internal/wallet
Package wallet implements the user-facing wallet subdomain of the billing module: commission withdrawal, balance/commission statements and the affiliate earnings overview.
Package wallet implements the user-facing wallet subdomain of the billing module: commission withdrawal, balance/commission statements and the affiliate earnings overview.
module/identity
Package identity is the facade of the identity module (accounts, auth methods, devices; the authentication flows join as migration proceeds).
Package identity is the facade of the identity module (accounts, auth methods, devices; the authentication flows join as migration proceeds).
module/identity/internal/adminuser
Package adminuser implements the admin-side account management subdomain of the identity module: user CRUD, auth methods, devices and login logs.
Package adminuser implements the admin-side account management subdomain of the identity module: user CRUD, auth methods, devices and login logs.
module/identity/internal/authmethodadmin
Service assembly for the admin-side authentication-method subdomain of the identity module: method configuration, sender platforms and test sends.
Service assembly for the admin-side authentication-method subdomain of the identity module: method configuration, sender platforms and test sends.
module/identity/internal/authn
Service assembly for the authentication subdomain.
Service assembly for the authentication subdomain.
module/identity/internal/authn/registerpolicy
Package registerpolicy enforces the administrator-configured account policies shared by every authentication and registration path.
Package registerpolicy enforces the administrator-configured account policies shared by every authentication and registration path.
module/identity/internal/profile
Package profile implements the self-service identity subdomain of the identity module: account info, credentials, third-party bindings, devices and notification preferences.
Package profile implements the self-service identity subdomain of the identity module: account info, credentials, third-party bindings, devices and notification preferences.
module/identity/internal/repo
Package repo holds the identity module's repository implementations: the user account rows, auth methods, devices and the cross-domain cache facade (ADR-001 step-6 preparation).
Package repo holds the identity module's repository implementations: the user account rows, auth methods, devices and the cross-domain cache facade (ADR-001 step-6 preparation).
module/identity/internal/verifycode
Service assembly for the verification-code subdomain: issuing and pre-checking the email/SMS codes that gate registration and account mutations.
Service assembly for the verification-code subdomain: issuing and pre-checking the email/SMS codes that gate registration and account mutations.
module/network
Package network is the facade of the network module: admin-side server and node management, the node-facing server API and the edge client manifest.
Package network is the facade of the network module: admin-side server and node management, the node-facing server API and the edge client manifest.
module/network/internal/adminserver
Service assembly for the admin-side server and node management subdomain of the network module.
Service assembly for the admin-side server and node management subdomain of the network module.
module/network/internal/edge
Service assembly for the edge subdomain of the network module: the token- authenticated client manifest.
Service assembly for the edge subdomain of the network module: the token- authenticated client manifest.
module/network/internal/serverapi
Service assembly for the node-facing server API subdomain of the network module: config pulls, user lists, status/traffic pushes.
Service assembly for the node-facing server API subdomain of the network module: config pulls, user lists, status/traffic pushes.
module/notification
Package notification is the facade of the notification module.
Package notification is the facade of the notification module.
module/notification/entity/telegramtopic
Package telegramtopic maps forum topics in the administrators' Telegram group to what they carry.
Package telegramtopic maps forum topics in the administrators' Telegram group to what they carry.
module/notification/internal/telegram
The templates in this file are MarkdownV2 (bold is *single asterisks*, italic is _underscores_).
The templates in this file are MarkdownV2 (bold is *single asterisks*, italic is _underscores_).
module/platform
Package platform is the facade of the platform module (shared-kernel concerns: audit/message logs and their retention settings; system configuration joins as migration proceeds).
Package platform is the facade of the platform module (shared-kernel concerns: audit/message logs and their retention settings; system configuration joins as migration proceeds).
module/platform/entity/outbox
Package outbox holds the generic domain-event outbox row (ADR-001 step-6 preparation): appended in the owning domain's transaction, published onto the asynq queue by the dispatch pump, consumed idempotently via the inbox.
Package outbox holds the generic domain-event outbox row (ADR-001 step-6 preparation): appended in the owning domain's transaction, published onto the asynq queue by the dispatch pump, consumed idempotently via the inbox.
module/platform/internal/auditlog
Package auditlog implements the audit/message log subdomain of the platform module: filtered views over the system log, message log listing and the log retention settings.
Package auditlog implements the audit/message log subdomain of the platform module: filtered views over the system log, message log listing and the log retention settings.
module/platform/internal/dashboard
Package dashboard implements the admin console subdomain of the platform module: cross-domain reporting aggregates.
Package dashboard implements the admin console subdomain of the platform module: cross-domain reporting aggregates.
module/platform/internal/publicinfo
Service assembly for the public-info subdomain: unauthenticated site-level reads (global configuration, ToS/privacy, aggregate stats, client downloads, liveness).
Service assembly for the public-info subdomain: unauthenticated site-level reads (global configuration, ToS/privacy, aggregate stats, client downloads, liveness).
module/platform/internal/systemsetting
Package systemsetting implements the system configuration subdomain of the platform module.
Package systemsetting implements the system configuration subdomain of the platform module.
module/platform/internal/tool
Service assembly for the tool subdomain of the platform module: system log tail, version info, IP geolocation and process restart.
Service assembly for the tool subdomain of the platform module: system log tail, version info, IP geolocation and process restart.
module/subscription
Package subscription is the facade of the subscription module: plan and group management plus the public storefront listings (subscription delivery joins as migration proceeds).
Package subscription is the facade of the subscription module: plan and group management plus the public storefront listings (subscription delivery joins as migration proceeds).
module/subscription/entity/usersub
Package usersub holds the subscription domain's user-subscription entities (ADR-001 step 5: entity packages follow table ownership).
Package usersub holds the subscription domain's user-subscription entities (ADR-001 step 5: entity packages follow table ownership).
module/subscription/internal/application
Service assembly for the client-application subdomain of the subscription module: managing the subscribe clients and previewing their delivery templates.
Service assembly for the client-application subdomain of the subscription module: managing the subscribe clients and previewing their delivery templates.
module/subscription/internal/delivery
Package delivery implements the subscription delivery subdomain of the subscription module: token-authenticated rendering of client configs via the adapter, with notice placeholders for expired/exhausted subscriptions.
Package delivery implements the subscription delivery subdomain of the subscription module: token-authenticated rendering of client configs via the adapter, with notice placeholders for expired/exhausted subscriptions.
module/subscription/internal/fulfillment
Package fulfillment applies a paid order's business effect: creating, renewing or traffic-resetting the user subscription in the fulfillment transaction, idempotent via the inbox marker.
Package fulfillment applies a paid order's business effect: creating, renewing or traffic-resetting the user subscription in the fulfillment transaction, idempotent via the inbox marker.
module/subscription/internal/plan
Package plan implements the subscription plan management subdomain of the subscription module: plan and group CRUD, ordering and token resets.
Package plan implements the subscription plan management subdomain of the subscription module: plan and group CRUD, ordering and token resets.
module/subscription/internal/quotatask
Package quotatask processes the admin-scheduled quota grants: extending subscription time and crediting gift money for a scope of subscriptions.
Package quotatask processes the admin-scheduled quota grants: extending subscription time and crediting gift money for a scope of subscriptions.
module/subscription/internal/selfsub
Package selfsub implements the user self-service subscription management of the subscription module: viewing, token reset, notes, and the two-phase cancellation with its billing refund.
Package selfsub implements the user self-service subscription management of the subscription module: viewing, token reset, notes, and the two-phase cancellation with its billing refund.
module/subscription/internal/storefront
Package storefront implements the public subscription listings of the subscription module.
Package storefront implements the public subscription listings of the subscription module.
module/subscription/internal/sweep
Package sweep implements the subscription lifecycle sweep: marking traffic-exceeded and expired subscriptions finished, then firing the retryable side effects (owner notification, cache invalidation).
Package sweep implements the subscription lifecycle sweep: marking traffic-exceeded and expired subscriptions finished, then firing the retryable side effects (owner notification, cache invalidation).
module/subscription/internal/trial
Package trial grants the registration trial subscription.
Package trial grants the registration trial subscription.
module/subscription/internal/usersub
Package usersub implements the admin-side user subscription management of the subscription module.
Package usersub implements the admin-side user subscription management of the subscription module.
module/support
Package support is the facade of the support module (announcements and, as migration proceeds, documents, tickets and ads).
Package support is the facade of the support module (announcements and, as migration proceeds, documents, tickets and ads).
module/support/internal/ads
Package ads implements the ads subdomain of the support module.
Package ads implements the ads subdomain of the support module.
module/support/internal/announcement
Package announcement implements the announcement subdomain of the support module.
Package announcement implements the announcement subdomain of the support module.
module/support/internal/document
Package document implements the document subdomain of the support module.
Package document implements the document subdomain of the support module.
module/support/internal/marketing
Package marketing implements the marketing subdomain of the support module (batch email campaigns and quota gift tasks).
Package marketing implements the marketing subdomain of the support module (batch email campaigns and quota gift tasks).
module/support/internal/ticket
Package ticket implements the ticket subdomain of the support module.
Package ticket implements the ticket subdomain of the support module.
svc
pkg
aes
asynqx
Package asynqx carries OpenTelemetry trace context across the asynq boundary.
Package asynqx carries OpenTelemetry trace context across the asynq boundary.
deduction
Package deduction provides functionality for calculating remaining amounts in subscription billing systems, supporting various time units and traffic-based calculations.
Package deduction provides functionality for calculating remaining amounts in subscription billing systems, supporting various time units and traffic-based calculations.
fs
ip
jwt
md5
orm
payment/cryptomus
Package cryptomus implements the Cryptomus crypto-payment gateway protocol: invoice creation, invoice lookup and webhook signature verification.
Package cryptomus implements the Cryptomus crypto-payment gateway protocol: invoice creation, invoice lookup and webhook signature verification.
platform
Package platform defines provider metadata shared by payment and messaging integrations.
Package platform defines provider metadata shared by payment and messaging integrations.
sms
telegramsecret
Package telegramsecret derives the webhook secret that Telegram echoes back in the X-Telegram-Bot-Api-Secret-Token header of every webhook call.
Package telegramsecret derives the webhook secret that Telegram echoes back in the X-Telegram-Bot-Api-Secret-Token header of every webhook call.
timeutil
Package timeutil provides centralized timezone handling for the application.
Package timeutil provides centralized timezone handling for the application.
tracectx
Package tracectx provides trace-context access without depending on an application layer.
Package tracectx provides trace-context access without depending on an application layer.
logic/events
Package events hosts the queue shells of the domain-event bus: the publish pump moving outbox rows onto the asynq broker, and the delivery worker running subscribers.
Package events hosts the queue shells of the domain-event bus: the publish pump moving outbox rows onto the asynq broker, and the delivery worker running subscribers.
logic/order
Package order hosts the queue shell of the paid-order activation saga.
Package order hosts the queue shell of the paid-order activation saga.
tools
mysql2postgres command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL