Files
MoShiro/backend
justme a2f88a344b
ci/woodpecker/tag/gitea-release Pipeline is pending
ci/woodpecker/tag/linux-release Pipeline failed
ci/woodpecker/tag/windows-release Pipeline was canceled
feat!: genesis-pinned operator set, server identity with an encrypted control link, key-less join codes; release key continuity
Join codes need no passkey touch and carry only public values (genesis
fingerprint, owner credentials, installer hashes). Nodes pin the genesis and
owners at enrollment and only follow passkey-signed operator set versions.
The panel's server key is listed in the set; pinned nodes require its
signature and run the control link under AES-256-GCM. Password sessions carry
no capabilities. The updater adopts a next_key from a signed manifest.

Bump version to 0.2.0. [CI SKIP]
2026-10-08 03:21:44 +08:00
..
2026-10-04 21:46:39 +08:00

Backend

Backend 是 MoShiro 的控制面和数据服务,负责 Agent 注册与连接、任务编排、原始测量数据持久化、指标分析,以及供前端使用的 REST API 和 SSE 实时数据流。

组件

路径 职责
src/MoShiro.Backend/ 应用入口与依赖组合
src/MoShiro.Backend.Api/ Public、Admin API 和 OpenAPI
src/MoShiro.Backend.Gateway/ Fleet RPC、节点状态与测量数据接收
src/MoShiro.Backend.Application/ 业务用例、查询、任务和后台服务
src/MoShiro.Backend.Analysis/ 指标计算、累加器和服务模型
src/MoShiro.Backend.Storage.Sqlite/ 段文件与 SQLite 存储
fleet/ 通用节点身份、注册和连接框架
shared/ 测量引擎、协议和数据格式
tests/ 集成测试和测试支持代码

环境要求

使用 .NET SDK 10。仓库根目录的 global.json 指定所需 SDK 版本及滚动策略。

构建与测试

在 backend/ 目录运行:

cd backend
dotnet build MoShiro.slnx -c Release
dotnet test --solution MoShiro.slnx

发布当前平台的 NativeAOT Backend:

dotnet publish src/MoShiro.Backend -c Release -r <RID> -p:PublishAot=true

例如 <RID> 可为 win-x64、linux-x64 或 linux-arm64。NativeAOT 发布需要对应平台的 C/C++ 工具链。仓库根目录的 scripts/publish.sh backend <RID> 可构建单个平台的 Backend 可执行文件;容器发布由 Woodpecker tag 流水线完成,详见 ../docs/deployment.md。

正式发布通过 Woodpecker tag 流水线生成 Linux/amd64 与 Linux/arm64 OCI 镜像,容器内监听 8080,数据写入挂载的 /data 卷。Agent 与 Probe 的多平台二进制包单独发布,不包含在 Backend 镜像中。

本地运行

在 backend/ 目录启动服务:

cd backend
dotnet run --project src/MoShiro.Backend -- --urls http://localhost:5000

首次启动时可用 MoShiro__InitialAdminUser 和 MoShiro__InitialAdminPassword 设置初始管理员。数据目录、公开地址、Cookie 和 CORS 等设置通过 MoShiro 配置节传入;完整配置说明见 ../docs/deployment.md。站点默认需要登录,可在管理端修改公开设置。

OpenAPI 文档由构建生成到 openapi/v1.json。API 设计和端点说明见 ../docs/api.md;项目总览见仓库根目录的 README.md。