Files
MeshPort/docs/architecture.md
T
shenleiandClaude Haiku 5.5 2f185f914d Snapshot uncommitted work: proxy UI, sing-box integration, socks bridge
- Lab app: proxy panel, node editor, configuration and detail pages,
  responsive layout, and related tests
- Add meshport-socks crate and sing-box bridge scripts/docs
- Add singbox_flutter binding and meshport_client_core package
- FFI, VPN helper (unified mac path), and Android/macOS runner updates
- Docs for architecture, client runtime, UI design, and validation
- UI design output artifacts under outputs/ui

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-12 10:06:15 +09:00

22 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 架构
本文描述当前实现。下一阶段 sing-box 组合客户端方案见 [组网与代理组合架构](next-stage-architecture.md),配套页面见 [移动端 UI V4](ui-design.md)。
已新增可选的应用内 [SOCKS 桥接](socks-bridge.md):通过 Rust 数据面并发转发本机 SOCKS5 TCP/UDP,C ABI/Dart 只负责启动、停止和状态。[sing-box Go 封装与本机联调](singbox-integration.md)已通过;客户端统一 TUN 尚未接入,现有普通 JSON I/O 的串行限制仍保留。
Flutter Lab → Dart SDK → C ABI → MeshPort → EasyTier 原生实例与其 smoltcp 数据面。
当前上游已经提供 `data_plane_tcp_connect`、`data_plane_tcp_bind`、`data_plane_udp_bind`。因此第一版不维护第二套 TCP/IP 栈;netstack crate 是适配边界,可在以后替换实现。
核心上游依赖禁用默认 features,仅开启 aes-gcm、ffi-dataplane、dhcp-ipv4、tcp-hole-punch、proxy-cidr-monitor。默认未启用 tun、magic-dns、linux-netlink、UPnP、出口节点和配置服务器集成。应用内模式强制 no_tun/use_smoltcp/加密。显式 system-vpn feature 可启用 macOS TUN,系统模式拒绝 DNS 和出口。两种模式共享公告子网过滤策略:应用内模式限制数据面发送,系统模式同步安装及删除 OS 路由。
每个 FFI context 有独立的两线程 Tokio runtime,实例与资源属于该 context。context free 从全局注册表移除句柄;正在执行的调用通过 Arc 保持资源活着,完成后再析构。句柄不复用。停止节点前清理 TCP/UDP 资源;关闭实例使上游会话失效。
第一版 JSON ABI 的用途是正确性与生命周期验证,数据以 byte array 传递,非零拷贝。单 context 串行,read 等待期间其他操作也会等待;停止不会抢占在途读操作。需在后续改为异步提交/取消/完成队列,并支持连接级并发。不同 context 可独立运行。
UI 仅显示实测状态与结果。连接耗时与 echo 往返耗时分开标识,不当成持续 RTT。默认配置不保存密钥;macOS 可 opt-in 保存完整配置到 Keychain,日志不记录配置原文。
选路优化在 vendor/easytier/easytier-core 的连接及下一跳选择层执行,适配层负责严格配置和实际路由快照。质量测量通过公开 Rust/C ABI/Dart API 发起真实 UDP echo,不改系统网络,详见 [优化说明](optimization.md)。
系统模式:Flutter → Dart Unix 控制通道 → macOS 特权 helper → 同一 C ABI → EasyTier TUN;其他应用通过普通系统 socket 使用虚拟网段。详见 [系统组网](system-vpn.md)。