Move mesh networking logic into the SDK and fix lifecycle bugs
SDK: - Add build_config/migrate_config, mesh_cidrs, route_generation, health and start_bridged; expose abi_info (capability revision 2). - Add wait_routes long-poll; stop wakes waiters, and context_free now stops the network immediately instead of waiting for waiters to time out. Hosts: - Dart: waitRoutes(), MeshProxySession route watcher, ABI capability check. - Android: fix a deadlock where every VPN request waited on its own single-thread worker; requests are now async, status is served from a snapshot, and combined mode reports Partial when the mesh stops. - macOS helper: mesh-only unified mode stops when the mesh is lost; installed_subnet_routes excludes the overlay. - Lab: restore Partial sessions, write migrated profiles back, remove the unreachable TOML import dialog; native test now connects via the form. Docs updated accordingly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
29d236f3fe
commit
dc1bfc99d2
@@ -33,13 +33,15 @@ macOS 统一 VPN 的仅组网模式使用 IPv4 TUN,只安装合规公告及会
|
||||
|
||||
## 生命周期与保护
|
||||
|
||||
组网启动顺序为 MeshPort → Rust SOCKS 桥接 → Go 引擎。停止顺序相反。启动失败回滚已有资源,网络停止失败保留所有权以便重试。`close()` 等待队列并释放代理上下文;宿主最终关闭 MeshPort。
|
||||
组网启动由 SDK `start_bridged` 一步完成 MeshPort 与 Rust SOCKS 桥接(失败由 SDK 一并回滚),再启动 Go 引擎;停止顺序相反。会话只在 `start_bridged` 成功后取得 context 所有权,context 已被占用时不会误停对方网络。网络停止失败保留所有权以便重试。组网配置由 SDK `build_config` 生成,旧版保存的配置经 `migrate_config` 迁移。`close()` 等待队列并释放代理上下文;宿主最终关闭 MeshPort。
|
||||
|
||||
每 2 秒读取当前虚拟 IPv4 和 `platform_network.subnet_routes`,只采用 `accepted_projection`。规范化后有变化才重建 Go 配置,无需手动远端子网列表。重建关闭已有代理连接,尚非无损热更新。
|
||||
宿主状态轮询直接读取 SDK 的 `platform_network.mesh_cidrs`(虚拟网段加已接受公告子网,已规范化),并用 `health.mesh_routable` 判断组网是否可用;客户端不再自行解析或掩码计算前缀。集合变化才重建 Go 配置,无需手动远端子网列表。`MeshProxySession` 启动后另开一个 `wait_routes` 长轮询循环,路由一变化就排队重建,不必等下一次宿主轮询;宿主轮询仍负责健康检查。Android 服务用独立线程长轮询 `wait_routes`,把路由应用投递到服务的 worker 线程。重建关闭已有代理连接,尚非无损热更新。
|
||||
|
||||
本次连接期间见过的合规组网前缀形成保护集合。有效前缀先走组网,撤销的已知前缀被拒绝,不能落入普通代理或直连;显式停止会话后清空集合。SDK 数据面也独立验证当前有效公告。
|
||||
|
||||
应用内联合模式中,组网暂不可用时普通代理可继续运行,状态为 `Partial`,组网目标保持拒绝。仅组网出现故障则清理会话。Android 服务故障目前整体停止,恢复行为尚需真机验证。
|
||||
应用内联合模式中,组网暂不可用时普通代理可继续运行,状态为 `Partial`,组网目标保持拒绝。仅组网出现故障则清理会话。Android 单一 VPN 同样按 `health.mesh_routable` 处理:联合(combined)模式下组网停止只撤掉组网路由、代理继续,状态报告 `Partial`(Lab 仍视为已连接,可断开);仅组网模式与系统 VPN 整体停止。该行为尚需真机验证。
|
||||
|
||||
Android `MeshVpnService` 的所有状态只在其 worker 线程上修改:Activity 发来的请求、2 秒健康检查、底层网络回调与路由更新都在这一个线程串行执行。请求接口为异步回调,不在 worker 上阻塞等待;每次 worker 任务结束后刷新状态快照,`status` 请求直接返回快照,不会被耗时的重建阻塞。`installed_subnet_routes` 在 Android 与 macOS 辅助进程中含义一致:只含已安装的公告子网,不含虚拟网段。
|
||||
|
||||
## DNS
|
||||
|
||||
|
||||
Reference in New Issue
Block a user