cadd527680
- 新增 internal/dpcred 包,统一 DeriveHy2Password + DefaultFlow agentd 与 HTTP connect handler 共享同一实现 - 新增迁移 000011:nodes 表拆分 reality_prk 私钥 / reality_pbk 公钥 reality_short_id;修正 handler_grpc.go 使用私钥字段 - 新增迁移 000012:connect_credentials 持久化凭证 实现 CredentialsForNode 修复 agent 重连 resync 原先返回空的桩 - 扩展 NodeStore 接口:ListUp / EntitlementForUser / PersistCredential / DeleteCredential;同步 grpc_test.go mock - 新增 httpapi/nodes.go:GET /nodes、POST /nodes/id/connect Hub.Push + PersistCredential + 渲染完整 sing-box client 配置 JSON POST /nodes/id/disconnect - 新增 httpapi/account.go:GET /me、GET /plans、GET /notices - 新增 httpapi/clientconfig.go:BuildClientConfig 服务端渲染 - 重写 cmd/server/main.go:手写 chi public/protected 分组 nodes.Service/Hub 在 main 构造并共享;SMTPMailer/LogMailer go build ./... && go vet ./... && go test ./... 全部通过 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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