// vpn_bridge.dart — sing-box libbox 的 Dart 侧封装 // // 关键约束(§3.1):[start] 接收的 [configJson] 必须原样透传, // 禁止在 Dart 层对任何字段做增删改——组装逻辑全在服务端。 // // M6 联调状态:stub 实现。 // TODO(11C): 替换为真实 gomobile libbox 绑定。 // tsk_nuoKSM4Vt-zK // ignore_for_file: avoid_print /// [VpnBridge] 封装 sing-box libbox 的启动与停止。 /// /// 每次创建新实例(非单例),便于单测注入与隔离。 class VpnBridge { String? _lastConfigJson; /// 以原样 [configJson] 启动 sing-box 隧道。 /// /// **禁止在此修改 configJson**(§3.1 透传约束:客户端零组装)。 /// 当前为 stub;11C 完成后替换为 `libbox.start(configJson)` 原生调用。 Future start(String configJson) async { _lastConfigJson = configJson; // TODO(11C): await _libbox.start(configJson); print('[VpnBridge] start — length=${configJson.length} (stub, libbox pending 11C)'); } /// 停止隧道。当前为 stub。 Future stop() async { _lastConfigJson = null; // TODO(11C): await _libbox.stop(); print('[VpnBridge] stop (stub)'); } /// 最近一次传入 [start] 的原始 JSON 字符串。 /// 仅供测试验证透传约束,生产代码不应依赖此字段。 // @visibleForTesting String? get lastConfigJson => _lastConfigJson; }