chore: 导入旧记忆备份供恢复

This commit is contained in:
2026-09-23 22:38:40 +08:00
parent 5313fcee7a
commit 6a6a895eaf
638 changed files with 29816 additions and 1 deletions
@@ -0,0 +1,67 @@
---
title: Project CPE Glossary
type: curated
permalink: main/projects/4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0/curated/project-cpe-glossary
stable_id: c78e3afc-4da6-4358-8901-c96c647b71d5
scope: project
project_id: 4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0
workspace_type: development
usage_profile_id: null
preference_context: development
document_type: glossary
revision: 1
source_memory_ids: []
source_checkpoint_ids: []
source_file_ids: []
source_git_commit: de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_git_commits:
- de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_agent_sync_ids: []
model_connection: Sub2API
model_name: openai/gpt-oss-120b
source_count: 188
source_revisions: {}
source_dispositions:
processed: 188
unchanged: 0
unsupported: 0
skipped: 0
cited_source_ids: []
job_cited_source_ids: []
conflicts: []
supersedes: []
preferences: []
source_cursor: 87
source_hash: 96f0e4026558c8a03161f53b392fcec7359d4d701c4f33576b44e2f308b0ec5a
prompt_version: 2026-08-12.3
schema_version: '3'
curation_job_id: a9f69899-ee39-4900-b39a-a54d737f9614
created_at: '2026-08-19T18:49:35.064057+00:00'
updated_at: '2026-08-19T18:49:35.064617+00:00'
tags:
- glossary
- definitions
- project‑cpe
---
## Glossary
| Term | Definition |
|------|------------|
| **OTA** | Over‑The‑Air update package containing the backend binary, the compiled front‑end `www/` assets and the FRPC client. Packaged as `udx710-ota-{VERSION}.tar.gz` with a `meta.json` manifest (version, commit, checksums, architecture). |
| **FRPC** | Fast Reverse Proxy client (v0.70.1) bundled with the OTA. Used to expose services from the device to a remote server. Managed by `backend/src/state.rs` (install, config render, start/stop, log rotation). |
| **DBus / ofono** | Linux D‑Bus interface to the modem stack, provided by the `ofono` daemon. The project communicates via the `zbus` crate, wrapping interfaces such as `MessageManager`, `VoiceCallManager`, etc. |
| **Serial AT lock** | Global mutex (`DBUS_LOCK`) that serialises all AT commands and DBus calls to avoid `org.ofono.Error.InProgress`. Implemented in `backend/src/serial.rs` and used via `with_serial`. |
| **USB Gadget Hot‑Switch** | Runtime re‑configuration of the USB‑OTG gadget (NCM, ECM, RNDIS) using configfs. Implemented in `backend/src/usb_switch.rs`. Persistent mode stored in `/mnt/data/mode.cfg`. |
| **Band‑mask** | Bit‑mask representation of LTE/NR carrier bands. Mapping is hardware‑specific (Rockchip/Unisoc) and handled by utility functions in `backend/src/utils.rs`. |
| **Vite** | Front‑end build tool (v7) used to compile the React 19 source into a static `dist/` directory. |
| **MUI** | Material‑UI React component library (v7) providing theming and UI widgets. |
| **TanStack Query** | Data‑fetching library (`@tanstack/react-query` v5) used for API calls with caching and background refetch. |
| **Vaultwarden** | Self‑hosted Bitwarden compatible password manager; the sole source of stored secrets for this project. |
| **UPX** | Optional executable compressor used in the CI pipeline to shrink the backend binary size. |
| **CORS** | Cross‑Origin Resource Sharing configuration; currently set to allow any origin (`*`). |
| **CI pipeline** | GitHub Actions workflow (`.github/workflows/build-ota.yml`) that builds backend and frontend, optionally compresses binaries, creates OTA tarball, verifies checksums, and uploads artifacts. |
| **Refresh interval** | UI polling frequency controlled via `RefreshContext`; default 5 s, adjustable through the Top‑Bar menu. |
| **InitScript** | Device initialization shell script (`init.sh`) editable via the UI; static analysis warns about syntax issues and potentially dangerous commands. |
All definitions are extracted directly from the evidence (see source IDs in the surrounding documents).
@@ -0,0 +1,105 @@
---
title: Common Issues & Remedies
type: curated
permalink: main/projects/4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0/curated/development/common-issues-remedies
stable_id: b74934b7-77c3-4cbc-acd6-f6f7d8dc350e
scope: project
project_id: 4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0
workspace_type: development
usage_profile_id: null
preference_context: development
document_type: troubleshooting
revision: 1
source_memory_ids: []
source_checkpoint_ids: []
source_file_ids: []
source_git_commit: de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_git_commits:
- de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_agent_sync_ids: []
model_connection: Sub2API
model_name: openai/gpt-oss-120b
source_count: 188
source_revisions: {}
source_dispositions:
processed: 188
unchanged: 0
unsupported: 0
skipped: 0
cited_source_ids:
- git:backend/src/handlers.rs
- git:backend/src/dbus.rs
- git:backend/src/iptables.rs
- git:backend/src/usb_switch.rs
job_cited_source_ids:
- git:backend/src/handlers.rs
- git:backend/src/dbus.rs
- git:backend/src/iptables.rs
- git:backend/src/usb_switch.rs
conflicts: []
supersedes: []
preferences: []
source_cursor: 87
source_hash: 96f0e4026558c8a03161f53b392fcec7359d4d701c4f33576b44e2f308b0ec5a
prompt_version: 2026-08-12.3
schema_version: '3'
curation_job_id: a9f69899-ee39-4900-b39a-a54d737f9614
created_at: '2026-08-19T18:49:42.050675+00:00'
updated_at: '2026-08-19T18:49:42.051299+00:00'
tags:
- troubleshooting
- issues
- solutions
---
## 1. Concurrent AT / DBus Commands → `org.ofono.Error.InProgress`
- **Cause**: Overlapping AT commands sent to ofono.
- **Solution**: Use the global serial lock (`with_serial`) provided in `backend/src/serial.rs`. All AT‑related paths in `dbus.rs` and `handlers.rs` already wrap calls with this lock.
- **Reference**: `git:backend/src/dbus.rs`.
## 2. Stale iptables Rules After Crash
- **Cause**: Crash leaves NAT/iptables rules active.
- **Solution**: `iptables_watchdog` (started after a 5 s delay) periodically flushes iptables. Ensure `flush_iptables()` is invoked before any data‑connection change.
- **Reference**: `git:backend/src/iptables.rs`.
## 3. OTA Package Corruption
- **Cause**: Missing files, wrong architecture, or checksum mismatch.
- **Solution**: Run `validate_ota_package()` (in `backend/src/ota.rs`) before install. The CI pipeline also validates checksums via `scripts/pack-ota.sh`.
- **Reference**: `memory:e92dbe0b…`.
## 4. Missing Authentication on AT Gateway
- **Cause**: `/api/at` endpoint is unauthenticated.
- **Remedy**: Implement token‑based auth or whitelist allowed AT commands.
- **Reference**: `git:backend/src/handlers.rs` (open issue).
## 5. Sensitive Fields Redacted
- **Cause**: APN passwords, FRPC tokens stored as `[REDACTED]`.
- **Remedy**: Integrate secure storage (Vaultwarden or encrypted file) and expose UI controls for entry.
- **Reference**: `git:backend/src/config.rs`, `git:frontend/src/pages/Network.tsx`.
## 6. USB Hot‑Switch Instability
- **Cause**: Re‑configuring configfs gadget may fail, leaving the device without USB networking.
- **Remedy**: Use the `switch_usb_mode_advanced` routine; if it fails, fallback to a reboot. Mark the UI option as experimental.
- **Reference**: `git:backend/src/usb_switch.rs`.
## 7. Band‑Mask Mismatch
- **Cause**: UI allows bands unsupported by hardware; backend rejects silently.
- **Remedy**: Capture the backend error response and display it in the UI; validate band selections before sending.
- **Reference**: `git:frontend/src/pages/Network.tsx`.
## 8. FRPC Log Growth
- **Cause**: Logs grow beyond 512 KB without rotation.
- **Remedy**: Adjust `log_rotation_size` in `state.rs` or enable compression.
- **Reference**: `git:backend/src/state.rs`.
## 9. CORS Wide Open
- **Cause**: Development CORS set to `*`.
- **Remedy**: Restrict allowed origins in production (`main.rs`). Add environment‑specific configuration.
- **Reference**: `git:backend/src/main.rs`.
## 10. No Unit Tests
- **Cause**: Repository lacks test suites.
- **Remedy**: Add Rust unit tests for utilities (`utils.rs`) and Jest/RTL tests for frontend components.
- **Reference**: Various source files.
*Each troubleshooting entry is traceable to its source ID as indicated.*
@@ -0,0 +1,107 @@
---
title: System Architecture Overview (Backend + Frontend)
type: curated
permalink: main/projects/4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0/curated/development/system-architecture-overview-backend-frontend
stable_id: faab1e63-b668-4362-896d-9a82ea81d348
scope: project
project_id: 4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0
workspace_type: development
usage_profile_id: null
preference_context: development
document_type: architecture
revision: 1
source_memory_ids: []
source_checkpoint_ids: []
source_file_ids: []
source_git_commit: de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_git_commits:
- de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_agent_sync_ids: []
model_connection: Sub2API
model_name: openai/gpt-oss-120b
source_count: 188
source_revisions: {}
source_dispositions:
processed: 188
unchanged: 0
unsupported: 0
skipped: 0
cited_source_ids:
- git:backend/Cargo.toml
- git:frontend/pnpm-lock.yaml
job_cited_source_ids:
- git:backend/Cargo.toml
- git:frontend/pnpm-lock.yaml
conflicts: []
supersedes: []
preferences: []
source_cursor: 87
source_hash: 96f0e4026558c8a03161f53b392fcec7359d4d701c4f33576b44e2f308b0ec5a
prompt_version: 2026-08-12.3
schema_version: '3'
curation_job_id: a9f69899-ee39-4900-b39a-a54d737f9614
created_at: '2026-08-19T18:49:38.284609+00:00'
updated_at: '2026-08-19T18:49:38.285207+00:00'
tags:
- architecture
- system‑design
- backend
- frontend
---
## 1. Backend Architecture (Rust)
- **Core Stack**: Rust 2021, Axum 0.8 (HTTP server), Tokio 1.48 (async runtime), `zbus` 5 for DBus communication with **ofono**.
- **Modules**:
- `config.rs` – JSON‑based configuration with hot‑reload; aggregates webhook, SMS‑push, refresh, FRPC sub‑configs.
- `db.rs` – Embedded SQLite (`rusqlite`) storing SMS and call history; protected by `Arc<Mutex<Connection>>`.
- `dbus.rs` – Generated proxies for ofono interfaces; all calls go through the global serial lock (`with_serial`).
- `handlers.rs` – HTTP API handlers exposing health, AT gateway, device info, USB mode, band‑lock, OTA, FRPC, webhook, SMS‑push, etc. All responses use a uniform JSON envelope.
- `ota.rs` – Validates and installs OTA packages atomically; checks architecture, version monotonicity and checksums.
- `state.rs` – FRPC lifecycle management (install, config render, start/stop, log rotation).
- `usb_switch.rs` – Configfs‑based USB gadget re‑configuration; persistent mode stored in `/mnt/data/mode.cfg`.
- `utils.rs` – Helpers for band‑mask conversion, system stats, AT response parsing.
- **Build Process**: Cross‑compiled on a Windows host using Docker (`docker/gnu-builder.Dockerfile`) targeting `aarch64-unknown-linux-gnu`. Build script (`build.rs`) injects `APP_VERSION`, `GIT_BRANCH`, `GIT_COMMIT`.
- **Docker Image**: Ubuntu 18.04 base with `gcc-aarch64-linux-gnu`; installs Rust toolchain and cross‑compiler.
**Key Design Decisions** (derived from evidence):
- Global serial lock to avoid `InProgress` DBus errors.
- iptables watchdog to clean stale NAT rules.
- All HTTP endpoints currently return `200 OK` (open issue).
- CORS set to `*` (development convenience, open issue).
- Sensitive fields are redacted in source code; secure storage is pending.
## 2. Front‑end Architecture (React 19 + TypeScript 5.9)
- **Build Tool**: Vite 7 with alias `@` → `src/*`. Injects compile‑time constants (`__APP_VERSION__`, `__GIT_COMMIT__`).
- **UI Library**: MUI v7 (Emotion styling engine). Theme persisted via `ThemeContext`.
- **State / Data Fetching**: `@tanstack/react-query` 5 for caching; custom `useApi` hook wraps `fetch` with timeout and error mapping.
- **Global Contexts**: `ThemeContext` (light/dark), `RefreshContext` (polling interval). Both persisted in `localStorage`.
- **Routing**: React Router lazy‑loaded routes for each page (Dashboard, ATConsole, Network, FRP, OTA, etc.).
- **Pages**:
- **Dashboard** – Real‑time status overview, quick controls, system resource monitors.
- **ATConsole** – Raw AT command gateway with history.
- **Configuration** – Device toggles, USB mode selector, webhook & SMS‑push config.
- **Network** – Cell list, band‑lock UI, APN editor, interface list.
- **FRP** – FRPC client management (enable, auto‑start, config, logs).
- **OTA Update** – OTA upload, validation table, apply/reboot actions.
- **InitScript** – Edit and static‑analyse `init.sh`.
- **Phone**, **SMS**, **Terminal**, … (additional functional pages).
- **Styling Guidelines**: Compact “label‑left / control‑right” for narrow fields; vertical layout for large sections; fixed header with inner scrolling.
- **Testing & Linting**: ESLint 9, strict TypeScript `strict` mode; no unit tests currently (open issue).
**Key Design Decisions** (frontend):
- Adaptive polling (`useAdaptivePolling`) scales interval by page visibility.
- Sensitive identifiers are blurred by default and togglable.
- All scripts must run on Windows (development platform).
- UI strings are Chinese‑language by default (communication language set in project metadata).
## 3. Build & Deployment
- `scripts/build.sh` – Cross‑compiles backend, builds frontend via Vite, optionally compresses with UPX, generates OTA meta.
- `scripts/pack-ota.sh` – Packages binaries, frontend `dist`, FRPC binary; creates `meta.json` with MD5/SHA‑256 checksums.
- CI (`.github/workflows/build-ota.yml`) runs the above, validates checksums, uploads artifacts.
- `scripts/deploy.sh` – Pushes OTA artifacts to device via ADB, stops running service, copies files.
- Docker image (`docker/gnu-builder.Dockerfile`) provides reproducible cross‑compile environment.
**Source IDs**: `git:backend/Cargo.toml`, `git:frontend/pnpm-lock.yaml`, `docker/gnu-builder.Dockerfile`.
@@ -0,0 +1,88 @@
---
title: 项目 CPE 运行与维护手册
type: curated
permalink: main/projects/4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0/curated/development/项目-cpe-运行与维护手册
stable_id: 9d1ffd0c-9758-495f-ab5f-20e2ebff3034
scope: project
project_id: 4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0
workspace_type: development
usage_profile_id: null
preference_context: development
document_type: maintenance
revision: 1
source_memory_ids: []
source_checkpoint_ids: []
source_file_ids: []
source_git_commit: de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_git_commits:
- de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_agent_sync_ids: []
model_connection: Sub2API
model_name: openai/gpt-oss-120b
source_count: 188
source_revisions: {}
source_dispositions:
processed: 188
unchanged: 0
unsupported: 0
skipped: 0
cited_source_ids:
- git:backend/src/config.rs
- git:backend/src/usb_switch.rs
- git:backend/src/handlers.rs
- git:frontend/src/pages/ATConsole.tsx
- git:frontend/src/pages/Configuration.tsx
- global_guidance_memory:bf88c265-4749-4c50-85bc-4bae25298cd5
- global_guidance_document:6973450e-6ecc-48e3-8cdd-4d7d7707d843
job_cited_source_ids:
- git:backend/src/config.rs
- git:backend/src/usb_switch.rs
- git:backend/src/handlers.rs
- git:frontend/src/pages/ATConsole.tsx
- git:frontend/src/pages/Configuration.tsx
- global_guidance_memory:bf88c265-4749-4c50-85bc-4bae25298cd5
- global_guidance_document:6973450e-6ecc-48e3-8cdd-4d7d7707d843
conflicts: []
supersedes: []
preferences: []
source_cursor: 87
source_hash: 96f0e4026558c8a03161f53b392fcec7359d4d701c4f33576b44e2f308b0ec5a
prompt_version: 2026-08-12.3
schema_version: '3'
curation_job_id: a9f69899-ee39-4900-b39a-a54d737f9614
created_at: '2026-08-19T18:49:47.691587+00:00'
updated_at: '2026-08-19T18:49:47.692127+00:00'
tags:
- 运行
- 维护
- 故障排查
- 安全
- 配置
---
# 项目 CPE 运行与维护手册
## 组件概览
- 后端服务 (Rust + Axum) 监听 `0.0.0.0:3000`
- 前端 (React + Vite) 位于 `/home/root/www/`
- 可选 FRPC 客户端 `frpc`,配置文件 `frpc.toml`
- USB Gadget 切换实现于 `backend/src/usb_switch.rs`
- OTA 更新通过 `scripts/pack-ota.sh` 生成的包,由后端 `ota.rs` 校验并原子替换。
## 配置管理
- 主配置 `config.json` 支持热重载,涉及 `WebhookConfig`、`SmsPushConfig`、`RefreshConfig`、`FrpcConfig`、`AppConfig`(见 `backend/src/config.rs`)。
- 敏感信息应通过 Vaultwarden 或加密文件注入,前端 UI 仅显示占位。
## 常规运维任务
- **日志**: 后端通过 `tracing` 输出,容器可 `docker logs`;FRPC 日志轮转 512 KB。
- **系统资源**: Dashboard 实时展示 CPU、内存、磁盘、网络、温度、运行时间。
- **OTA 更新流程**: 上传 `.tar.gz` → 后端 `validate_ota_package()` 检查版本、架构、校验和 → 原子 `rename` 完成更新。
- **USB 切换**: UI 调用 `switch_usb_mode_advanced`,在 `/mnt/data/mode.cfg` 写入模式并重新启用 UDC。
## 未决事项
1. OTA 包签名校验与回滚机制(A/B 分区)。
2. HTTP API token/白名单安全。
3. 敏感凭证统一 Vaultwarden 管理。
4. Docker 基础镜像升级至 `ubuntu:24.04`。
**标签**: ["运行","维护","故障排查","安全","配置"]
@@ -0,0 +1,92 @@
---
title: 项目 CPE 部署指南
type: curated
permalink: main/projects/4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0/curated/development/项目-cpe-部署指南
stable_id: 95f0ac0f-1d2e-4a1a-8adf-4b3638e28035
scope: project
project_id: 4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0
workspace_type: development
usage_profile_id: null
preference_context: development
document_type: deployment
revision: 1
source_memory_ids: []
source_checkpoint_ids: []
source_file_ids: []
source_git_commit: de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_git_commits:
- de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_agent_sync_ids: []
model_connection: Sub2API
model_name: openai/gpt-oss-120b
source_count: 188
source_revisions: {}
source_dispositions:
processed: 188
unchanged: 0
unsupported: 0
skipped: 0
cited_source_ids:
- git:.github/workflows/build-ota.yml
- git:backend/build.rs
- git:scripts/build.sh
- git:scripts/pack-ota.sh
- git:scripts/deploy.sh
- global_guidance_memory:bf88c265-4749-4c50-85bc-4bae25298cd5
- global_guidance_document:6973450e-6ecc-48e3-8cdd-4d7d7707d843
job_cited_source_ids:
- git:.github/workflows/build-ota.yml
- git:backend/build.rs
- git:scripts/build.sh
- git:scripts/pack-ota.sh
- git:scripts/deploy.sh
- global_guidance_memory:bf88c265-4749-4c50-85bc-4bae25298cd5
- global_guidance_document:6973450e-6ecc-48e3-8cdd-4d7d7707d843
conflicts: []
supersedes: []
preferences: []
source_cursor: 87
source_hash: 96f0e4026558c8a03161f53b392fcec7359d4d701c4f33576b44e2f308b0ec5a
prompt_version: 2026-08-12.3
schema_version: '3'
curation_job_id: a9f69899-ee39-4900-b39a-a54d737f9614
created_at: '2026-08-19T18:49:44.618729+00:00'
updated_at: '2026-08-19T18:49:44.619384+00:00'
tags:
- 部署
- CI
- 交叉编译
- OTA
- Docker
---
# 项目 CPE 部署指南
## 前置条件
- OS: Windows + WSL2 + Docker Desktop
- 交叉编译环境: `docker/gnu-builder.Dockerfile`
- 代码仓库: `https://github.com/nixevol/project-cpe.git`
- 凭证: MEMRelay MCP Token via Vaultwarden
## 构建
```bash
cd scripts && ./build.sh
```
- 生成后端二进制、前端 `dist/`、可选 UPX 压缩、 OTA 元数据 `meta.json`。
## 打包 OTA
```bash
./pack-ota.sh
```
- 产生 `udx710-ota-<version>.tar.gz` 与校验文件。
## 部署到设备
```bash
./deploy.sh
```
- 停止服务、推送二进制与前端至 `/home/root/www/`,必要时重启设备。
## CI/CD
`.github/workflows/build-ota.yml` 包括代码拉取、交叉编译、前端打包、UPX、打包 OTA 并上传构件。
**标签**: ["部署","CI","交叉编译","OTA","Docker"]
@@ -0,0 +1,108 @@
---
title: project-cpe 关键时间线 (2026‑08‑19)
type: curated
permalink: main/projects/4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0/curated/project-cpe-关键时间线-2026-08-19
stable_id: 13f2b063-060f-4f4a-8d2d-5f53d81cb3e8
scope: project
project_id: 4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0
workspace_type: development
usage_profile_id: null
preference_context: development
document_type: timeline
revision: 2
source_memory_ids: []
source_checkpoint_ids: []
source_file_ids: []
source_git_commit: de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_git_commits:
- de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_agent_sync_ids: []
model_connection: Sub2API
model_name: openai/gpt-oss-120b
source_count: 188
source_revisions:
memory:c8101753-2674-42d9-8849-8e98d325d497: '1'
memory:b84527b2-0fef-4062-897d-bc06cb2b41bc: '1'
memory:2ab0a44e-c56a-4cbc-a82f-c8b8456d5019: '1'
memory:866234ea-0d81-4fd9-912a-6cb68441e1cc: '1'
memory:d0a91595-3be4-4366-a615-58833dd0dff8: '1'
memory:51b5b48b-ac1f-4477-ab2f-dfc46198eb01: '1'
memory:fd164c80-b38b-4984-8008-48b57ba46e61: '1'
memory:fa66c797-a786-4966-8cb1-2eff40e3dc4e: '1'
memory:f0d365e8-4d2c-4d91-bdc0-df4d3d6fa6b3: '1'
memory:a732a5c7-f413-440e-ad41-2c018a68e15f: '1'
memory:ce9c98cd-85c8-4595-9cae-aa019b487893: '1'
memory:e92dbe0b-bb27-4b0e-b5bb-2330a0472fd2: '1'
memory:8c6276e6-d7db-409d-a3cd-5570c2d8fdc5: '1'
source_dispositions:
processed: 188
unchanged: 0
unsupported: 0
skipped: 0
cited_source_ids:
- git:backend/src/iptables.rs
- git:backend/src/main.rs
- git:backend/src/ota.rs
- git:frontend/src/pages/ATConsole.tsx
- git:frontend/src/pages/Configuration.tsx
- git:frontend/src/pages/Dashboard/index.tsx
- git:scripts/build.sh
- git:scripts/deploy.sh
- memory:c8101753-2674-42d9-8849-8e98d325d497
- memory:b84527b2-0fef-4062-897d-bc06cb2b41bc
- memory:2ab0a44e-c56a-4cbc-a82f-c8b8456d5019
- memory:866234ea-0d81-4fd9-912a-6cb68441e1cc
- memory:d0a91595-3be4-4366-a615-58833dd0dff8
- memory:51b5b48b-ac1f-4477-ab2f-dfc46198eb01
- memory:fd164c80-b38b-4984-8008-48b57ba46e61
- memory:fa66c797-a786-4966-8cb1-2eff40e3dc4e
- memory:f0d365e8-4d2c-4d91-bdc0-df4d3d6fa6b3
- memory:a732a5c7-f413-440e-ad41-2c018a68e15f
- memory:ce9c98cd-85c8-4595-9cae-aa019b487893
- memory:e92dbe0b-bb27-4b0e-b5bb-2330a0472fd2
- memory:8c6276e6-d7db-409d-a3cd-5570c2d8fdc5
job_cited_source_ids:
- git:backend/src/iptables.rs
- git:backend/src/main.rs
- git:backend/src/ota.rs
- git:frontend/src/pages/ATConsole.tsx
- git:frontend/src/pages/Configuration.tsx
- git:frontend/src/pages/Dashboard/index.tsx
- git:scripts/build.sh
- git:scripts/deploy.sh
conflicts: []
supersedes:
- summary: Later checkpoint supersedes earlier repository URL
current_source_ids:
- memory:2ab0a44e-c56a-4cbc-a82f-c8b8456d5019
superseded_source_ids:
- memory:c8101753-2674-42d9-8849-8e98d325d497
preferences: []
source_cursor: 87
source_hash: 96f0e4026558c8a03161f53b392fcec7359d4d701c4f33576b44e2f308b0ec5a
prompt_version: 2026-08-12.3
schema_version: '3'
curation_job_id: a9f69899-ee39-4900-b39a-a54d737f9614
created_at: '2026-08-19T03:55:24.360292+00:00'
updated_at: '2026-08-19T18:49:28.001361+00:00'
tags:
- project-cpe
- development
- timeline
---
# 项目时间线(UTC 2026‑08‑19)
| 时间点 | 事件 | 关键变化 |
|--------|------|----------|
| **2025‑12‑03 – 13** | 前端页面初版提交(ATConsole、Configuration、Dashboard 等) | 完成 UI 框架搭建,使用 MUI v7 与 React 19 |
| **2025‑12‑07** | 添加 `usb_switch_demo.sh`(Feishu webhook 监控) | 实现 USB Gadget 状态上报脚本 |
| **2025‑12‑08 – 13** | 后端核心模块实现(`iptables.rs`、`main.rs`、`models.rs`、`ota.rs`、`serial.rs`、`sms_listener.rs`、`sms_push.rs`、`state.rs`、`usb_switch.rs`、`utils.rs`、`webhook.rs`) | 完成后端业务逻辑,加入 SQLite 持久化 |
| **2025‑12‑10 – 13** | 前端功能统一化(统一主题、轮询、错误 Snackbar 等) | UI 交互细节完善,加入全局 Context 与自定义 Hook |
| **2025‑12‑13 12:45 – 12:51** | 脚本最终打磨(`build.sh`、`deploy.sh`、`monitor.sh`、`setup‑env.sh`、`pack-ota.sh`、`pack-userdata.sh`) | 构建、部署与 OTA 打包流程固化 |
| **2026‑08‑19 03:29:30** | 基线检查点 `5736938fa5`:`main`/`cc95e25`、版本 3.5.5、导入 `AGENTS.md`、`README.md`,来源 `https://github.com/1orz/project-cpe.git` | 初始状态记录 |
| **2026‑08‑19 03:36:14** | 记录前一检查点 ID(审计专用) | - |
| **2026‑08‑19 03:38:59** | 检查点 `0af3a08953`:完成迁移至 **MemRelay**,上传 README 与 OTA CI,**仓库 URL 切换** 为 `https://github.com/nixevol/project-cpe.git`,写入 `MEMRELAY_TOKEN` 到 Vaultwarden,更新 `.gitignore`(加入 `AGENTS.md` 与 `aidocs/`) | 冲突解决:以最新声明为准,更新仓库地址 |
| **2026‑08‑19 03:38:59** | 再次确认仓库 URL 迁移完成 | 与上条相同 |
此时间线保留了所有关键里程碑及对应的代码/文档变更,便于追溯与审计。
@@ -0,0 +1,175 @@
---
title: project-cpe 当前状态概览
type: curated
permalink: main/projects/4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0/curated/project-cpe-当前状态概览
stable_id: fe7caa54-0379-47d0-a16d-b85423ebef99
scope: project
project_id: 4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0
workspace_type: development
usage_profile_id: null
preference_context: development
document_type: current_state
revision: 2
source_memory_ids: []
source_checkpoint_ids: []
source_file_ids: []
source_git_commit: de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_git_commits:
- de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_agent_sync_ids: []
model_connection: Sub2API
model_name: openai/gpt-oss-120b
source_count: 188
source_revisions:
memory:2ab0a44e-c56a-4cbc-a82f-c8b8456d5019: '1'
memory:c8101753-2674-42d9-8849-8e98d325d497: '1'
memory:866234ea-0d81-4fd9-912a-6cb68441e1cc: '1'
memory:d0a91595-3be4-4366-a615-58833dd0dff8: '1'
memory:51b5b48b-ac1f-4477-ab2f-dfc46198eb01: '1'
memory:fd164c80-b38b-4984-8008-48b57ba46e61: '1'
memory:fa66c797-a786-4966-8cb1-2eff40e3dc4e: '1'
memory:f0d365e8-4d2c-4d91-bdc0-df4d3d6fa6b3: '1'
memory:a732a5c7-f413-440e-ad41-2c018a68e15f: '1'
memory:ce9c98cd-85c8-4595-9cae-aa019b487893: '1'
memory:e92dbe0b-bb27-4b0e-b5bb-2330a0472fd2: '1'
memory:8c6276e6-d7db-409d-a3cd-5570c2d8fdc5: '1'
source_dispositions:
processed: 188
unchanged: 0
unsupported: 0
skipped: 0
cited_source_ids:
- git:backend/src/config.rs
- git:backend/src/db.rs
- git:backend/src/dbus.rs
- git:backend/src/handlers.rs
- git:backend/src/ota.rs
- git:backend/src/state.rs
- git:backend/src/usb_switch.rs
- git:backend/src/utils.rs
- git:frontend/src/contexts/RefreshContext.tsx
- git:frontend/src/contexts/ThemeContext.tsx
- git:frontend/src/hooks/useAdaptivePolling.ts
- git:frontend/src/pages/Dashboard/index.tsx
- git:frontend/src/pages/ATConsole.tsx
- git:frontend/src/pages/Configuration.tsx
- git:frontend/src/pages/DeviceInfo.tsx
- git:frontend/src/pages/Frp.tsx
- git:frontend/src/pages/InitScript.tsx
- git:frontend/src/pages/Network.tsx
- git:frontend/src/pages/OtaUpdate.tsx
- git:frontend/src/pages/Phone.tsx
- git:frontend/src/pages/SMS.tsx
- git:frontend/src/pages/Terminal.tsx
- git:frontend/vite.config.ts
- git:scripts/build.sh
- git:scripts/deploy.sh
- git:scripts/pack-ota.sh
- git:scripts/pack-userdata.sh
- memory:2ab0a44e-c56a-4cbc-a82f-c8b8456d5019
- memory:c8101753-2674-42d9-8849-8e98d325d497
- memory:866234ea-0d81-4fd9-912a-6cb68441e1cc
- memory:d0a91595-3be4-4366-a615-58833dd0dff8
- memory:51b5b48b-ac1f-4477-ab2f-dfc46198eb01
- memory:fd164c80-b38b-4984-8008-48b57ba46e61
- memory:fa66c797-a786-4966-8cb1-2eff40e3dc4e
- memory:f0d365e8-4d2c-4d91-bdc0-df4d3d6fa6b3
- memory:a732a5c7-f413-440e-ad41-2c018a68e15f
- memory:ce9c98cd-85c8-4595-9cae-aa019b487893
- memory:e92dbe0b-bb27-4b0e-b5bb-2330a0472fd2
- memory:8c6276e6-d7db-409d-a3cd-5570c2d8fdc5
job_cited_source_ids:
- git:backend/src/config.rs
- git:backend/src/db.rs
- git:backend/src/dbus.rs
- git:backend/src/handlers.rs
- git:backend/src/ota.rs
- git:backend/src/state.rs
- git:backend/src/usb_switch.rs
- git:backend/src/utils.rs
- git:frontend/src/contexts/RefreshContext.tsx
- git:frontend/src/contexts/ThemeContext.tsx
- git:frontend/src/hooks/useAdaptivePolling.ts
- git:frontend/src/pages/Dashboard/index.tsx
- git:frontend/src/pages/ATConsole.tsx
- git:frontend/src/pages/Configuration.tsx
- git:frontend/src/pages/DeviceInfo.tsx
- git:frontend/src/pages/Frp.tsx
- git:frontend/src/pages/InitScript.tsx
- git:frontend/src/pages/Network.tsx
- git:frontend/src/pages/OtaUpdate.tsx
- git:frontend/src/pages/Phone.tsx
- git:frontend/src/pages/SMS.tsx
- git:frontend/src/pages/Terminal.tsx
- git:frontend/vite.config.ts
- git:scripts/build.sh
- git:scripts/deploy.sh
- git:scripts/pack-ota.sh
- git:scripts/pack-userdata.sh
conflicts: []
supersedes:
- summary: Later checkpoint supersedes earlier repository URL
current_source_ids:
- memory:2ab0a44e-c56a-4cbc-a82f-c8b8456d5019
superseded_source_ids:
- memory:c8101753-2674-42d9-8849-8e98d325d497
preferences: []
source_cursor: 87
source_hash: 96f0e4026558c8a03161f53b392fcec7359d4d701c4f33576b44e2f308b0ec5a
prompt_version: 2026-08-12.3
schema_version: '3'
curation_job_id: a9f69899-ee39-4900-b39a-a54d737f9614
created_at: '2026-08-19T03:55:22.375228+00:00'
updated_at: '2026-08-19T18:49:23.488327+00:00'
tags:
- project-cpe
- development
- current_state
---
# 当前开发状态
## 后端
- **代码结构**: `backend/src` 目录下实现了配置 (`config.rs`)、数据库 (`db.rs`)、ofono D‑Bus 交互 (`dbus.rs`)、HTTP 处理 (`handlers.rs`)、OTA 逻辑 (`ota.rs`)、FRPC 管理 (`state.rs`)、USB Gadget 切换 (`usb_switch.rs`)、工具函数 (`utils.rs`)、Webhook 与短信推送 (`webhook.rs`, `sms_push.rs`) 等模块。
- **关键实现**:
- 全局串行锁 `with_serial` 防止 ofono `InProgress` 错误。
- `iptables_watchdog` 每 5 s 刷新防火墙规则。
- OTA 包的原子替换与校验(MD5、SHA‑256、架构检查)。
- 配置系统采用 JSON 热加载,部分字段(如 FRPC token、APN password)已脱敏占位。
- **依赖锁定**: 所有依赖记录在 `Cargo.lock` 中,使用的主要 crates 已列于证据表 3.1。
- **构建脚本**: `build.rs` 注入 `APP_VERSION`、`GIT_BRANCH`、`GIT_COMMIT`。
- **未完成项**: 安全存储敏感字段、完整的错误码映射、单元测试覆盖。
## 前端
- **技术栈**: React 19 + TypeScript 5.9,UI 框架 MUI v7,数据获取 TanStack Query 5,构建工具 Vite 7。
- **全局上下文**: `ThemeContext`(亮/暗模式持久化),`RefreshContext`(轮询间隔可配置),自定义 Hook `useAdaptivePolling`、`useApi` 实现可见性感知的轮询。
- **路由与页面**: 通过 `react-router` 懒加载,实现了 Dashboard、ATConsole、Configuration、DeviceInfo、FRP、InitScript、Network、OTA Update、Phone、SMS、Terminal 等十余页面;每个页面对应后端 API 完整封装。
- **布局**: `MainLayout` + `Sidebar` + `TopBar`,固定页头和按钮栏,内部内容可滚动。
- **构建产出**: `vite build` 生成 `dist/`,在 CI 中打包进 OTA 包。
- **未完成项**: 单元/集成测试、错误边界 (`ErrorBoundary`)、i18n 多语言支持、列表虚拟化、全局错误状态码处理。
## CI / 部署
- **GitHub Actions**: `.github/workflows/build-ota.yml` 自动构建后端 Rust 二进制、前端 `dist`,可选 UPX 压缩,生成 `meta.json` 并校验校验和,最终产出 `udx710-ota-3.5.5.tar.gz`。
- **脚本集合** (`scripts/`):
- `build.sh` 完成交叉编译、前端打包、OTA 元数据生成。
- `deploy.sh` 通过 ADB 将产物推送至设备并重启服务。
- `pack-ota.sh` 与 `pack-userdata.sh` 负责 OTA 打包及 UBIFS 制作。
- `monitor.sh` 提供 ofono DBus 实时监控交互界面。
- **Docker**: `docker/gnu-builder.Dockerfile` 基于 Ubuntu 18.04,安装 `gcc-aarch64-linux-gnu` 与 Rust 交叉目标。
## 关键开放事项
| 类别 | 描述 |
|------|------|
| 安全 | AT 网关缺失鉴权、所有 HTTP 错误返回 200、CORS `*`、敏感字段未加密存储 |
| OTA | 未签名、无回滚机制 |
| FRPC | 日志轮转阈值固定、令牌未安全保存 |
| USB | 配置文件无文件锁、热切换标记为实验性 |
| 测试 | 缺乏单元/集成测试、前端缺少错误边界 |
| 性能 | 大表未虚拟化、轮询可见性切换未防抖 |
| 国际化 | 仅中文硬编码 |
以上状态基于截至 2026‑08‑19 的所有证据,任何后续改动应更新相应章节并在文档中记录。
@@ -0,0 +1,92 @@
---
title: project‑cpe 待办事项清单
type: curated
permalink: main/projects/4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0/curated/project-cpe-待办事项清单
stable_id: b428ca3d-fd45-4f03-9546-5e656435db89
scope: project
project_id: 4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0
workspace_type: development
usage_profile_id: null
preference_context: development
document_type: tasks
revision: 2
source_memory_ids: []
source_checkpoint_ids: []
source_file_ids: []
source_git_commit: de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_git_commits:
- de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_agent_sync_ids: []
model_connection: Sub2API
model_name: openai/gpt-oss-120b
source_count: 188
source_revisions:
memory:2ab0a44e-c56a-4cbc-a82f-c8b8456d5019: '1'
memory:e92dbe0b-bb27-4b0e-b5bb-2330a0472fd2: '1'
memory:866234ea-0d81-4fd9-912a-6cb68441e1cc: '1'
memory:d0a91595-3be4-4366-a615-58833dd0dff8: '1'
memory:8c6276e6-d7db-409d-a3cd-5570c2d8fdc5: '1'
memory:f0d365e8-4d2c-4d91-bdc0-df4d3d6fa6b3: '1'
memory:fa66c797-a786-4966-8cb1-2eff40e3dc4e: '1'
memory:fd164c80-b38b-4984-8008-48b57ba46e61: '1'
memory:51b5b48b-ac1f-4477-ab2f-dfc46198eb01: '1'
source_dispositions:
processed: 188
unchanged: 0
unsupported: 0
skipped: 0
cited_source_ids:
- memory:2ab0a44e-c56a-4cbc-a82f-c8b8456d5019
- memory:e92dbe0b-bb27-4b0e-b5bb-2330a0472fd2
- memory:866234ea-0d81-4fd9-912a-6cb68441e1cc
- memory:d0a91595-3be4-4366-a615-58833dd0dff8
- memory:8c6276e6-d7db-409d-a3cd-5570c2d8fdc5
- memory:f0d365e8-4d2c-4d91-bdc0-df4d3d6fa6b3
- memory:fa66c797-a786-4966-8cb1-2eff40e3dc4e
- memory:fd164c80-b38b-4984-8008-48b57ba46e61
- memory:51b5b48b-ac1f-4477-ab2f-dfc46198eb01
job_cited_source_ids: []
conflicts: []
supersedes: []
preferences: []
source_cursor: 87
source_hash: 96f0e4026558c8a03161f53b392fcec7359d4d701c4f33576b44e2f308b0ec5a
prompt_version: 2026-08-12.3
schema_version: '3'
curation_job_id: a9f69899-ee39-4900-b39a-a54d737f9614
created_at: '2026-08-19T03:55:27.224816+00:00'
updated_at: '2026-08-19T18:49:31.225685+00:00'
tags:
- open‑issues
- unresolved
- tasks
- project‑cpe
---
## Open / Unresolved Work (Consolidated)
| Category | Issue | Description | Suggested Next Action | Source IDs |
|----------|-------|-------------|-----------------------|------------|
| **Security** | AT gateway auth | `/api/at` allows arbitrary AT commands. | Add token‑based authentication or whitelist allowed commands. | ["git:backend/src/handlers.rs"] |
| **Credentials** | Redacted sensitive fields | APN password, FRPC token, etc. are stored as `[REDACTED]`. | Store secrets in Vaultwarden or an encrypted config file; provide UI for secure entry. | ["git:backend/src/config.rs", "git:frontend/src/pages/Network.tsx", "git:frontend/src/pages/Frp.tsx"] |
| **OTA** | No signing | OTA packages are unsigned. | Sign OTA tarballs (e.g., GPG) and verify signatures in `ota.rs`. | ["memory:e92dbe0b…"] |
| **OTA** | No rollback | Once applied, the device cannot revert to the previous version. | Implement A/B partitions or keep a backup copy before applying OTA. | ["git:backend/src/ota.rs", "git:frontend/src/pages/OtaUpdate.tsx"] |
| **FRPC** | Log rotation threshold | Logs grow beyond 512 KB. | Make log rotation size configurable or compress old logs. | ["git:backend/src/state.rs"] |
| **USB** | File‑lock missing | `set_usb_mode_config` writes directly to mode files. | Use atomic rename or `flock` for exclusive access. | ["git:backend/src/usb_switch.rs"] |
| **USB Monitor** | Hard‑coded Feishu webhook | Monitor script only posts to a single Feishu URL. | Add a CLI flag for a configurable webhook; support Slack/Discord. | ["usb_switch_demo.sh"] |
| **Testing** | Lack of unit/integration tests | Backend and front‑end have little test coverage. | Add Rust unit tests for utils and Jest/React‑Testing‑Library tests for UI components. | ["git:backend/src/utils.rs", "git:frontend/src/pages/*.tsx"] |
| **API** | HTTP 200 for all errors | Errors are wrapped in JSON but HTTP status is always 200. | Return appropriate HTTP status codes (`400`, `401`, `500`, …). | ["git:backend/src/handlers.rs"] |
| **CORS** | `*` allowed | Development CORS policy is wide open. | Restrict origins to known production hosts before release. | ["git:backend/src/main.rs"] |
| **Refresh** | Aggressive polling on visibility changes | `useAdaptivePolling` may cause rapid extra requests. | Debounce visibility changes (e.g., 500 ms) before adjusting interval. | ["git:frontend/src/hooks/useAdaptivePolling.ts"] |
| **InitScript** | Dangerous commands only warned | Scripts with `rm -rf /` etc. are only highlighted. | Add a confirmation modal for dangerous commands and optionally block save. | ["git:frontend/src/pages/InitScript.tsx"] |
| **Band‑lock UI** | May allow unsupported bands | UI does not surface backend rejections. | Parse backend error and display to the user. | ["git:frontend/src/pages/Network.tsx"] |
| **USB hot‑switch** | Marked experimental | May destabilise the device. | Perform extensive testing; fallback to reboot on failure. | ["git:frontend/src/pages/Configuration.tsx"] |
| **Global Error Boundary** | Missing in React tree | Uncaught render errors crash the UI. | Wrap the root `<App/>` with an `ErrorBoundary` component. | ["git:frontend/src/main.tsx"] |
| **i18n** | No localisation | All UI strings are hard‑coded Chinese. | Introduce `react-i18next` (or similar) and externalise strings. | ["git:frontend/src/**/*.tsx"] |
| **Performance** | Large tables lack virtualization | Cell list may degrade performance. | Use `react-window` or MUI DataGrid virtualization. | ["git:frontend/src/pages/Network.tsx"] |
| **OTA upload cancellation** | No abort controller | Users cannot stop a large OTA upload. | Add `AbortController` support to the upload API wrapper. | ["git:frontend/src/pages/OtaUpdate.tsx"] |
| **USB monitor daemonisation** | Script runs manually | No systemd service provided. | Provide a systemd unit template for `usb_switch_demo.sh`. | ["usb_switch_demo.sh"] |
| **Docker image reproducibility** | Base image `ubuntu:18.04` is outdated | Security updates may be missing. | Upgrade to a newer LTS base (e.g., `ubuntu:24.04`). | ["docker/gnu-builder.Dockerfile"] |
| **Documentation** | No top‑level end‑to‑end guide | New contributors lack a consolidated overview. | Add a high‑level README covering build → deploy → operate workflow. | [] |
**Note**: The table above reflects the consolidated *Open / Unresolved Work* list (Section 7️⃣ of the evidence). Each row is traceable to the cited source IDs.
@@ -0,0 +1,102 @@
---
title: 关键决策与已实现方案
type: curated
permalink: main/projects/4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0/curated/关键决策与已实现方案
stable_id: 7efbeabe-d24c-43de-a01f-769b52610eaa
scope: project
project_id: 4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0
workspace_type: development
usage_profile_id: null
preference_context: development
document_type: decisions
revision: 1
source_memory_ids: []
source_checkpoint_ids: []
source_file_ids: []
source_git_commit: de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_git_commits:
- de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_agent_sync_ids: []
model_connection: Sub2API
model_name: openai/gpt-oss-120b
source_count: 188
source_revisions: {}
source_dispositions:
processed: 188
unchanged: 0
unsupported: 0
skipped: 0
cited_source_ids:
- git:backend/src/dbus.rs
- git:backend/src/serial.rs
- git:backend/src/iptables.rs
- git:backend/src/main.rs
- git:backend/src/ota.rs
- git:backend/src/sms_listener.rs
- git:backend/src/config.rs
- git:backend/src/state.rs
- git:backend/src/usb_switch.rs
- git:frontend/src/pages/DeviceInfo.tsx
- git:frontend/src/pages/Configuration.tsx
- git:frontend/src/pages/Network.tsx
- git:frontend/src/pages/Frp.tsx
- git:frontend/src/components/Layout/TopBar.tsx
- git:scripts/pack-ota.sh
- git:scripts/build.sh
job_cited_source_ids:
- git:backend/src/dbus.rs
- git:backend/src/serial.rs
- git:backend/src/iptables.rs
- git:backend/src/main.rs
- git:backend/src/ota.rs
- git:backend/src/sms_listener.rs
- git:backend/src/config.rs
- git:backend/src/state.rs
- git:backend/src/usb_switch.rs
- git:frontend/src/pages/DeviceInfo.tsx
- git:frontend/src/pages/Configuration.tsx
- git:frontend/src/pages/Network.tsx
- git:frontend/src/pages/Frp.tsx
- git:frontend/src/components/Layout/TopBar.tsx
- git:scripts/pack-ota.sh
- git:scripts/build.sh
conflicts: []
supersedes: []
preferences: []
source_cursor: 87
source_hash: 96f0e4026558c8a03161f53b392fcec7359d4d701c4f33576b44e2f308b0ec5a
prompt_version: 2026-08-12.3
schema_version: '3'
curation_job_id: a9f69899-ee39-4900-b39a-a54d737f9614
created_at: '2026-08-19T18:49:25.643063+00:00'
updated_at: '2026-08-19T18:49:25.643738+00:00'
tags:
- project-cpe
- development
- decisions
---
# 关键决策与已实现方案
| 序号 | 决策主题 | 出现位置 | 根本原因 | 实施方案 | 开放/待办 |
|------|----------|----------|----------|----------|-----------|
| 1 | **串行 AT/D‑Bus 调用** | `backend/src/dbus.rs`、`backend/src/serial.rs` | ofono 并发 AT 命令会返回 `org.ofono.Error.InProgress` | 引入全局锁 `DBUS_LOCK` 与 `with_serial`,所有 DBus/AT 调用走同一串行通道(超时 20 s) | 已实现,无待办 |
| 2 | **iptables 规则自动清理** | `backend/src/iptables.rs`、`backend/src/main.rs` | 进程异常退出后残留 iptables 规则导致网络异常 | `iptables_watchdog` 启动后每 5 s 调用 `flush_iptables()`,在数据连接切换前强制刷新 | 已实现,无待办 |
| 3 | **端口冲突重试** | `backend/src/main.rs` | 端口被其他进程占用导致服务启动失败 | `bind_with_retry()` 在 30 s 内循环尝试绑定,失败则记录警告后继续 | 已实现,无待办 |
| 4 | **OTA 包完整性校验** | `scripts/pack-ota.sh`、`backend/src/ota.rs` | OTA 包可能缺文件、架构错误或校验和不匹配 | `validate_ota_package()` 检查文件、架构 (`aarch64-unknown-linux-gnu`)、版本递增、MD5/SHA‑256 对比;后端安装使用原子临时文件 + `fsync` 再 `rename` | 已实现,无待办 |
| 5 | **SMS 去重与分片 TTL** | `backend/src/sms_listener.rs` | ofono 同时推送文本与 PDU 导致重复记录 | 10 s 去重窗口 + `should_store` 判断;多片 SMS 设置 5 min TTL 自动清理 | 已实现,无待办 |
| 6 | **SIM 卡槽切换 UI 同步** | `frontend/src/pages/DeviceInfo.tsx` | 后端切换需时间,前端立即刷新会显示旧信息 | 在成功请求后 `setTimeout(loadData, 2000)` 延迟重新加载 | 已实现,无待办 |
| 7 | **敏感字段脱敏占位** | `backend/src/config.rs`、前端 `Network.tsx`、`Frp.tsx` | 为防泄漏在源码中屏蔽真实值 | 用 `[REDACTED]` 占位,提示需要安全存储 | **开放**:实现 Vaultwarden 或加密文件存储 |
| 8 | **UI 轮询频率可调** | `frontend/src/components/Layout/TopBar.tsx` | 默认 5 s 轮询对部分用户过于频繁 | `setRefreshInterval` 通过后端 `api.setRefreshConfig` 持久化,用户可在顶部菜单选择 1/3/5/10 s 或手动 | 已实现,无待办 |
| 9 | **USB 热切换实验** | `backend/src/usb_switch.rs`、前端 `Configuration.tsx` | 需要在不重启的情况下切换 USB Gadget 模式 | `switch_usb_mode_advanced` 完成 UDC 停止、清理旧配置、写新描述、重新启用 UDC,并写入持久/临时模式文件 | **开放**:增加文件锁、完善错误回滚 |
| 10 | **FRPC 生命周期管理** | `backend/src/state.rs` | 自动启动可能导致未配置情况下启动 | 仅在 `enabled && auto_start` 为 true 时启动;提供 UI 配置、日志轮转 (512 KB) | 已实现,**开放**:日志轮转阈值可配置 |
| 11 | **全局 CORS 允许 `*`** | `backend/src/main.rs` | 开发阶段便捷跨域 | 设置 `*` 为允许源 | **开放**:生产环境需限制来源 |
| 12 | **AT 网关未鉴权** | `backend/src/handlers.rs` (`/api/at`) | 安全风险 | 暂未实现鉴权,仅记录为待办 | **开放** |
| 13 | **HTTP 错误码统一 200** | `backend/src/handlers.rs` | 前端统一解析 JSON | 所有错误仍返回 `200 OK`,错误信息放在 `ApiResponse` 的 `status` 字段 | **开放**:改为符合 REST 的状态码 |
| 14 | **OTA 未签名** | `scripts/pack-ota.sh` | 防止篡改 | 当前不生成签名 | **开放**:集成 GPG 或 SHA‑256 签名并在 `ota.rs` 验证 |
| 15 | **缺少单元测试** | 整体代码库 | 项目快速迭代导致测试被忽略 | 尚未编写任何 Rust 或前端测试 | **开放**:添加 Jest、React‑Testing‑Library 与 Rust 测试套件 |
| 16 | **UI 错误边界缺失** | `frontend/src/main.tsx` | 未捕获渲染异常会导致整页崩溃 | 暂无实现 | **开放**:在根组件加入 `ErrorBoundary` |
| 17 | **缺少国际化** | 所有 UI 文本硬编码中文 | 仅面向中文用户 | 未使用 i18n 框架 | **开放**:引入 `react-i18next` 并抽离字符串 |
| 18 | **大表未虚拟化** | `Network.tsx` 中的基站列表 | 列表可能非常长,性能下降 | 使用普通 MUI `DataGrid`(未开启虚拟化) | **开放**:改为 `react-window` 或开启 DataGrid 虚拟滚动 |
以上表格记录了所有已知决策、实施细节以及当前开放/未完成的工作项,便于后续评审与排期。
@@ -0,0 +1,227 @@
---
title: 项目概览 – Project CPE (UDX710)
type: curated
permalink: main/projects/4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0/curated/项目概览-project-cpe-udx710
stable_id: 92707336-3381-4d86-b3dd-aed1c7169561
scope: project
project_id: 4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0
workspace_type: development
usage_profile_id: null
preference_context: development
document_type: overview
revision: 1
source_memory_ids: []
source_checkpoint_ids: []
source_file_ids: []
source_git_commit: de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_git_commits:
- de28dc8246094e2bc17cab7c764fb4d4a2da71e0
source_agent_sync_ids: []
model_connection: Sub2API
model_name: openai/gpt-oss-120b
source_count: 188
source_revisions: {}
source_dispositions:
processed: 188
unchanged: 0
unsupported: 0
skipped: 0
cited_source_ids:
- git:.cursorrules
- git:.gitignore
- git:.dockerignore
- git:.gitattributes
- git:README.md
- git:VERSION
- git:backend/.cargo/config.toml
- git:.github/workflows/build-ota.yml
- git:backend/Cargo.toml
- git:backend/Cargo.lock
- git:backend/build.rs
- git:backend/src/config.rs
- git:backend/src/db.rs
- git:backend/src/dbus.rs
- git:backend/src/handlers.rs
- git:backend/src/iptables.rs
- git:backend/src/main.rs
- git:backend/src/models.rs
- git:backend/src/ota.rs
- git:backend/src/serial.rs
- git:backend/src/sms_listener.rs
- git:backend/src/sms_push.rs
- git:backend/src/state.rs
- git:backend/src/usb_switch.rs
- git:backend/src/utils.rs
- git:backend/src/webhook.rs
- git:frontend/.gitignore
- git:frontend/pnpm-lock.yaml
- git:frontend/public/provider/china-broadnet.svg
- git:frontend/public/provider/china-mobile.svg
- git:frontend/public/provider/china-telecom.svg
- git:frontend/public/udx710-logo.svg
- git:frontend/src/App.css
- git:frontend/src/App.tsx
- git:frontend/src/api/index.ts
- git:frontend/src/api/types.ts
- git:frontend/src/assets/react.svg
- git:frontend/src/components/ErrorSnackbar.tsx
- git:frontend/src/components/Layout/MainLayout.tsx
- git:frontend/src/components/Layout/Sidebar.tsx
- git:frontend/src/components/Layout/TopBar.tsx
- git:frontend/src/contexts/RefreshContext.tsx
- git:frontend/src/contexts/ThemeContext.tsx
- git:frontend/src/hooks/useAdaptivePolling.ts
- git:frontend/src/hooks/useApi.ts
- git:frontend/src/index.css
- git:frontend/src/lib/queryClient.ts
- git:frontend/src/main.tsx
- git:frontend/src/pages/ATConsole.tsx
- git:frontend/src/pages/Configuration.tsx
- git:frontend/src/pages/Dashboard/components/DeviceInfoCard.tsx
- git:frontend/src/pages/Dashboard/components/NetworkSpeed.tsx
- git:frontend/src/pages/Dashboard/components/QuickControls.tsx
- git:frontend/src/pages/Dashboard/components/SimCardInfo.tsx
- git:frontend/src/pages/Dashboard/components/StatusOverview.tsx
- git:frontend/src/pages/Dashboard/components/SystemResources.tsx
- git:frontend/src/pages/Dashboard/components/TemperatureMonitor.tsx
- git:frontend/src/pages/Dashboard/components/index.ts
- git:frontend/src/pages/Dashboard/hooks/useDashboardData.ts
- git:frontend/src/pages/Dashboard/index.tsx
- git:frontend/src/pages/Dashboard/utils.ts
- git:frontend/src/pages/DeviceInfo.tsx
- git:frontend/src/pages/Frp.tsx
- git:frontend/src/pages/InitScript.tsx
- git:frontend/src/pages/Network.tsx
- git:frontend/src/pages/OtaUpdate.tsx
- git:frontend/src/pages/Phone.tsx
- git:frontend/src/pages/SMS.tsx
- git:frontend/src/pages/Terminal.tsx
- git:frontend/src/theme.ts
- git:frontend/src/utils/carriers.ts
- git:frontend/src/utils/theme.ts
- git:frontend/tsconfig.app.json
- git:frontend/tsconfig.json
- git:frontend/tsconfig.node.json
- git:frontend/vite.config.ts
- git:scripts/build.sh
- git:scripts/deploy.sh
- git:scripts/monitor.sh
- git:scripts/pack-ota.sh
- git:scripts/pack-userdata.sh
- git:scripts/setup-env.sh
job_cited_source_ids:
- git:.cursorrules
- git:.gitignore
- git:.dockerignore
- git:.gitattributes
- git:README.md
- git:VERSION
- git:backend/.cargo/config.toml
- git:.github/workflows/build-ota.yml
- git:backend/Cargo.toml
- git:backend/Cargo.lock
- git:backend/build.rs
- git:backend/src/config.rs
- git:backend/src/db.rs
- git:backend/src/dbus.rs
- git:backend/src/handlers.rs
- git:backend/src/iptables.rs
- git:backend/src/main.rs
- git:backend/src/models.rs
- git:backend/src/ota.rs
- git:backend/src/serial.rs
- git:backend/src/sms_listener.rs
- git:backend/src/sms_push.rs
- git:backend/src/state.rs
- git:backend/src/usb_switch.rs
- git:backend/src/utils.rs
- git:backend/src/webhook.rs
- git:frontend/.gitignore
- git:frontend/pnpm-lock.yaml
- git:frontend/public/provider/china-broadnet.svg
- git:frontend/public/provider/china-mobile.svg
- git:frontend/public/provider/china-telecom.svg
- git:frontend/public/udx710-logo.svg
- git:frontend/src/App.css
- git:frontend/src/App.tsx
- git:frontend/src/api/index.ts
- git:frontend/src/api/types.ts
- git:frontend/src/assets/react.svg
- git:frontend/src/components/ErrorSnackbar.tsx
- git:frontend/src/components/Layout/MainLayout.tsx
- git:frontend/src/components/Layout/Sidebar.tsx
- git:frontend/src/components/Layout/TopBar.tsx
- git:frontend/src/contexts/RefreshContext.tsx
- git:frontend/src/contexts/ThemeContext.tsx
- git:frontend/src/hooks/useAdaptivePolling.ts
- git:frontend/src/hooks/useApi.ts
- git:frontend/src/index.css
- git:frontend/src/lib/queryClient.ts
- git:frontend/src/main.tsx
- git:frontend/src/pages/ATConsole.tsx
- git:frontend/src/pages/Configuration.tsx
- git:frontend/src/pages/Dashboard/components/DeviceInfoCard.tsx
- git:frontend/src/pages/Dashboard/components/NetworkSpeed.tsx
- git:frontend/src/pages/Dashboard/components/QuickControls.tsx
- git:frontend/src/pages/Dashboard/components/SimCardInfo.tsx
- git:frontend/src/pages/Dashboard/components/StatusOverview.tsx
- git:frontend/src/pages/Dashboard/components/SystemResources.tsx
- git:frontend/src/pages/Dashboard/components/TemperatureMonitor.tsx
- git:frontend/src/pages/Dashboard/components/index.ts
- git:frontend/src/pages/Dashboard/hooks/useDashboardData.ts
- git:frontend/src/pages/Dashboard/index.tsx
- git:frontend/src/pages/Dashboard/utils.ts
- git:frontend/src/pages/DeviceInfo.tsx
- git:frontend/src/pages/Frp.tsx
- git:frontend/src/pages/InitScript.tsx
- git:frontend/src/pages/Network.tsx
- git:frontend/src/pages/OtaUpdate.tsx
- git:frontend/src/pages/Phone.tsx
- git:frontend/src/pages/SMS.tsx
- git:frontend/src/pages/Terminal.tsx
- git:frontend/src/theme.ts
- git:frontend/src/utils/carriers.ts
- git:frontend/src/utils/theme.ts
- git:frontend/tsconfig.app.json
- git:frontend/tsconfig.json
- git:frontend/tsconfig.node.json
- git:frontend/vite.config.ts
- git:scripts/build.sh
- git:scripts/deploy.sh
- git:scripts/monitor.sh
- git:scripts/pack-ota.sh
- git:scripts/pack-userdata.sh
- git:scripts/setup-env.sh
conflicts: []
supersedes: []
preferences: []
source_cursor: 87
source_hash: 96f0e4026558c8a03161f53b392fcec7359d4d701c4f33576b44e2f308b0ec5a
prompt_version: 2026-08-12.3
schema_version: '3'
curation_job_id: a9f69899-ee39-4900-b39a-a54d737f9614
created_at: '2026-08-19T18:49:22.237926+00:00'
updated_at: '2026-08-19T18:49:22.238807+00:00'
tags:
- project-cpe
- development
- overview
---
# 项目概览
- **项目 ID**: `4f53c06a-c6c3-40ec-b2fc-5f019ea45fc0`
- **代码仓库**: `https://github.com/nixevol/project-cpe.git`(2026‑08‑19 03:38:59 切换,最新声明为准)
- **主分支 / 最新提交**: `main` / `cc95e25`
- **当前版本**: `3.5.5`(由 `VERSION` 文件读取)
- **后端技术栈**: Rust 2021, Axum 0.8, Tokio 1.48, zbus 5(用于 ofono D‑Bus)
- **前端技术栈**: React 19, TypeScript 5.9, MUI v7, TanStack Query 5, Vite 7
- **构建流程**: Windows 主机 → Docker(Ubuntu 18.04)→ 交叉编译 `aarch64-unknown-linux-gnu`;LF 行结尾通过 `.gitattributes` 强制
- **CI**: GitHub Actions `build-ota.yml` 完成后端、前端构建、可选 UPX 压缩、生成 OTA 包并上传校验信息
- **开发原则**: KISS & YAGNI,避免投机性依赖;所有凭证写入 Vaultwarden,仅在内存保存名称/用法
- **AI / Git 集成**: 默认禁用,系统不会自行创建 `.git` 目录或加载模型,除非显式开启
- **UI 布局规范**: 窄字段使用 “标签左 / 控件右”,大块使用垂直布局,固定页头+按钮栏,内部区域滚动
- **默认沟通语言**: 中文
- **平台偏好**: Windows + WSL2 + Docker Desktop,所有脚本必须在 Windows 环境可运行
该概览基于所有提供的证据,保留了每一条属性的来源标识,以供审计。