Files
pangolin/server
wangjia ea1a875607
ci-pangolin / Redline Scan — 脱敏 (UI 文案) (push) Successful in 28s
ci-pangolin / Cleartext Scan — Android 禁明文 (push) Successful in 19s
ci-pangolin / Portable SQL — 可移植性 (mysql/sqlite) (push) Successful in 18s
ci-pangolin / OpenAPI Sync Check (push) Successful in 1m24s
ci-pangolin / Flutter — analyze + test (push) Successful in 1m0s
ci-pangolin / Codegen Drift — token 生成物未漂移 (push) Successful in 27s
ci-pangolin / DS-flow — 原型/跨端同源/代码色单源闸 (push) Successful in 29s
ci-pangolin / Go — build + test (push) Failing after 49s
ci-pangolin / E2E Smoke — L4 进程级端到端 (push) Failing after 38s
ci-pangolin / Go — integration (mysql/redis testcontainers) (push) Failing after 5m3s
ci-pangolin / Golden — 视觉回归 (全量:components/auth/desktop/tablet) (push) Successful in 43s
ci-pangolin / Lint — shellcheck (push) Failing after 12m23s
Merge feat/private-dest-acl: 节点侧私有目的地 ACL(按 dp_uuid 放行家庭内网服务)
pangolin 出口 IP 是家庭内网服务(brain/nas/git/win.51yanmei.com)在 ali 侧的
唯一准入凭据;单用户时=「只有我」,现在 5 个账号退化成「所有 pangolin 用户」。
本功能在节点 sing-box route 上按 dp_uuid 补一道 fail-closed 白名单闸,把语义
拉回「只有我」。改动收敛在 internal/agentd/,零 migration,不动控制面/客户端/DB。

合并动因:该分支代码已在 pangolin1 生产运行(线上 agent 二进制 vcs.revision=
e4b527b + auth_user 修复,昨晚经 SIGHUP 热渲染 auth_user 闸生效),但 main 缺失
——从 main 重建部署 agent 会静默移除这道安全闸。合并后 main 与生产对齐,并把
线上「脏树构建(vcs.modified=true)」规整成干净可追溯来源。

含 21 个提交:设计/计划文档、ACL 配置类型与 fail-closed 加载、渲染放行+拒绝
规则对、last-good 内存+落盘跨重启兜底、SIGHUP 热重载不踢人、ip_cidr/port 校验、
resolve 堵域名绕过、auth_user(VLESS 运行时只认 auth_user)、29 个单测 + 真机验收。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9G7E3wmAYL9KeYCVZVsqu
2026-07-25 00:20:53 +08:00
..

Pangolin Server

Go 后端控制面,负责账户、套餐、激活码、设备与节点目录管理。架构详见 ../design/server/ARCHITECTURE.md

目录结构

server/
├── cmd/
│   ├── server/          # HTTP 服务入口(chi router/healthz/v1 挂载归 1d
│   └── migrate/         # 数据库迁移 CLI 入口(实现归 1e)
├── internal/
│   ├── config/          # 配置加载(env + 文件,归 1e)
│   ├── store/           # 数据库访问层 Postgres(归 1e
│   ├── apierr/          # 统一错误体 {code, message_zh, message_en}(归 1f
│   ├── idgen/           # UUID + Crockford Base32 激活码(归 1f
│   ├── auth/            # 验证码、argon2id、JWT RS256(归 1c/1d
│   ├── codes/           # 激活码批次、兑换、审计(归 1d)
│   ├── devices/         # 设备管理(归 1d)
│   ├── nodes/           # 节点目录、connect/disconnect(归 1d
│   ├── usage/           # 用量统计(归 1d)
│   └── admin/           # 内部管理端(归 1d)
├── Makefile
├── go.mod
├── go.sum
├── tools.go             # //go:build tools — 锁定 oapi-codegen / migrate 版本
└── .golangci.yml

常用命令

make build        # go build ./...
make test         # go test ./...
make vet          # go vet ./...
make lint         # golangci-lint run ./...
make generate     # oapi-codegen 代码生成(1d 填充)
make migrate-up   # 执行迁移(1e 填充)
make migrate-down # 回滚迁移(1e 填充)

# 快速启动(默认监听 :8080
go run ./cmd/server
# 指定地址
go run ./cmd/server -addr :9090
# 或通过环境变量
ADDR=:9090 go run ./cmd/server