diff --git a/apps/meshport_lab/android/app/build.gradle.kts b/apps/meshport_lab/android/app/build.gradle.kts
index 6b0513e..bf2d313 100644
--- a/apps/meshport_lab/android/app/build.gradle.kts
+++ b/apps/meshport_lab/android/app/build.gradle.kts
@@ -1,3 +1,5 @@
+import java.util.Properties
+
plugins {
id("com.android.application")
id("kotlin-android")
@@ -5,6 +7,16 @@ plugins {
id("dev.flutter.flutter-gradle-plugin")
}
+val standalone = System.getenv("MESHPORT_ANDROID_STANDALONE") == "1"
+val standaloneSigning = Properties().apply {
+ if (standalone) {
+ val path = requireNotNull(System.getenv("MESHPORT_ANDROID_SIGNING_PROPERTIES")) {
+ "Use scripts/package-lab-android.sh --standalone to prepare signing"
+ }
+ file(path).inputStream().use { load(it) }
+ }
+}
+
android {
buildFeatures { buildConfig = true }
namespace = "com.example.meshport_lab"
@@ -22,7 +34,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
- applicationId = "com.example.meshport_lab"
+ applicationId = if (standalone) "com.meshport.client.standalone" else "com.example.meshport_lab"
+ manifestPlaceholders["meshportAppLabel"] = if (standalone) "MeshPort 独立版" else "MeshPort"
// You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = 26
@@ -36,13 +49,23 @@ android {
versionName = flutter.versionName
}
+ signingConfigs {
+ if (standalone) {
+ create("standalone") {
+ storeFile = file(standaloneSigning.getProperty("storeFile"))
+ storePassword = standaloneSigning.getProperty("storePassword")
+ keyAlias = standaloneSigning.getProperty("keyAlias")
+ keyPassword = standaloneSigning.getProperty("keyPassword")
+ }
+ }
+ }
buildTypes {
debug { ndk { abiFilters.clear(); abiFilters += "arm64-v8a" } }
release {
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
- signingConfig = signingConfigs.getByName("debug")
+ signingConfig = signingConfigs.getByName(if (standalone) "standalone" else "debug")
}
}
externalNativeBuild { cmake { path = file("src/main/cpp/CMakeLists.txt"); version = "3.22.1" } }
diff --git a/apps/meshport_lab/android/app/src/main/AndroidManifest.xml b/apps/meshport_lab/android/app/src/main/AndroidManifest.xml
index 6aed4b1..5fe9e75 100644
--- a/apps/meshport_lab/android/app/src/main/AndroidManifest.xml
+++ b/apps/meshport_lab/android/app/src/main/AndroidManifest.xml
@@ -6,20 +6,20 @@
-
logs;
final VoidCallback onClear;
const LogsPageBody({super.key, required this.logs, required this.onClear});
@override
+ State createState() => _LogsPageBodyState();
+}
+
+class _LogsPageBodyState extends State {
+ bool proxyOnly = false;
+ List get visibleLogs => proxyOnly
+ ? widget.logs
+ .where((line) => line.contains('代理') || line.contains('sing-box'))
+ .toList()
+ : widget.logs;
+ @override
Widget build(BuildContext context) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
- const Text(
- '显示本次应用会话最近 300 条事件。macOS 同步写入系统日志,可在 Console 中筛选 MeshPort / Runtime。复制保留节点地址,隐藏认证信息。',
+ const Text('显示本次会话最近 300 条事件。代理日志包含连接、目标地址、分流出口及引擎错误。复制保留目标地址,隐藏认证信息。'),
+ const SizedBox(height: 12),
+ SegmentedButton(
+ segments: const [
+ ButtonSegment(value: false, label: Text('全部日志')),
+ ButtonSegment(value: true, label: Text('代理日志')),
+ ],
+ selected: {proxyOnly},
+ onSelectionChanged: (selection) =>
+ setState(() => proxyOnly = selection.single),
),
+ if (visibleLogs.isEmpty)
+ const Padding(
+ padding: EdgeInsets.symmetric(vertical: 12),
+ child: Text('暂无日志'),
+ ),
Wrap(
spacing: 12,
children: [
OutlinedButton(
onPressed: () async {
- await Clipboard.setData(ClipboardData(text: logs.join('\n')));
+ await Clipboard.setData(
+ ClipboardData(text: visibleLogs.join('\n')),
+ );
if (context.mounted) {
ScaffoldMessenger.of(
context,
@@ -221,10 +247,10 @@ class LogsPageBody extends StatelessWidget {
},
child: const Text('复制当前范围'),
),
- TextButton(onPressed: onClear, child: const Text('清空显示')),
+ TextButton(onPressed: widget.onClear, child: const Text('清空显示')),
],
),
- for (final line in logs)
+ for (final line in visibleLogs)
Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: SelectableText(
diff --git a/apps/meshport_lab/lib/features/lab_screen.dart b/apps/meshport_lab/lib/features/lab_screen.dart
index 4fe7e13..f895c00 100644
--- a/apps/meshport_lab/lib/features/lab_screen.dart
+++ b/apps/meshport_lab/lib/features/lab_screen.dart
@@ -12,6 +12,7 @@ import 'proxy_panel.dart';
import 'configuration_pages.dart';
import 'detail_pages.dart';
import 'runtime_diagnostics.dart';
+import 'proxy_speed_test.dart';
class LabScreen extends StatefulWidget {
const LabScreen({super.key, this.initializeNative = true});
@@ -70,6 +71,12 @@ class _LabScreenState extends State {
Map status = {'state': 'Stopped', 'peer_count': 0};
Map? result;
final logs = [];
+ final proxySpeedTest = ProxySpeedTest();
+ bool speedTesting = false;
+ ProxySpeedResult? speedResult;
+ String speedError = '';
+ double speedProgressMbps = 0;
+ int speedBytes = 0;
final diagnosticRedactor = DiagnosticRedactor();
String lastProxyState = '';
int proxyEventSequence = 0;
@@ -502,6 +509,9 @@ class _LabScreenState extends State {
}
Future startConfig(String config) async {
+ proxySpeedTest.cancel();
+ speedResult = null;
+ speedError = '';
proxyEventSequence = 0;
if (singBoxEnabled) proxyProfile.validateConnection();
// Validation selects mode from effective flags, avoiding ad-hoc TOML parsing.
@@ -608,9 +618,9 @@ class _LabScreenState extends State {
if (mounted) {
setState(() {
legacyMigrationPending = info?['migration_pending'] == true;
- if (info?['path'] is String) {
+ if (info?['path'] is String) {
localProfilePath = info!['path'] as String;
- }
+ }
});
}
if (legacyMigrationPending) log('旧配置需要迁移,请在设置中点击“迁移旧配置”');
@@ -664,6 +674,7 @@ class _LabScreenState extends State {
}
Future stopActive(MeshPortClient c) async {
+ proxySpeedTest.cancel();
try {
if (c == applicationClient && proxySession != null) {
await proxySession!.stop();
@@ -811,6 +822,7 @@ class _LabScreenState extends State {
@override
void dispose() {
cancel = true;
+ proxySpeedTest.cancel();
timer?.cancel();
subscriptionTimer?.cancel();
unawaited(
@@ -906,6 +918,91 @@ class _LabScreenState extends State {
},
);
+ Future measureProxySpeed() async {
+ if (speedTesting || busy || !running) return;
+ setState(() {
+ speedTesting = true;
+ speedResult = null;
+ speedError = '';
+ speedBytes = 0;
+ speedProgressMbps = 0;
+ });
+ log('代理测速 · 开始 · $runningProxyMode · $runningProxyLabel');
+ var lastUpdate = Duration.zero;
+ try {
+ final measured = await proxySpeedTest.run(
+ port: proxySession?.port ?? 10818,
+ onProgress: (bytes, elapsed) {
+ if (!mounted ||
+ elapsed - lastUpdate < const Duration(milliseconds: 250)) {
+ return;
+ }
+ lastUpdate = elapsed;
+ setState(() {
+ speedBytes = bytes;
+ speedProgressMbps =
+ bytes * 8 / elapsed.inMicroseconds.clamp(1, 1 << 62);
+ });
+ },
+ );
+ if (!mounted) return;
+ setState(() {
+ speedResult = measured;
+ speedBytes = measured.bytes;
+ });
+ log(
+ '代理测速 · ${measured.mbps.toStringAsFixed(1)} Mbps · '
+ '${formatBytes(measured.bytes)} · 首字节 ${measured.firstByte.inMilliseconds} ms',
+ );
+ } catch (e) {
+ if (mounted) {
+ setState(() => speedError = diagnosticRedactor.sanitize('$e'));
+ log('代理测速 · $e');
+ }
+ } finally {
+ if (mounted) setState(() => speedTesting = false);
+ }
+ }
+
+ Widget speedPanel() => panel('代理测速', [
+ Text(
+ speedTesting
+ ? '${speedProgressMbps.toStringAsFixed(1)} Mbps · 已下载 ${formatBytes(speedBytes)}'
+ : speedResult == null
+ ? '尚未测速'
+ : '${speedResult!.mbps.toStringAsFixed(1)} Mbps · '
+ '${(speedResult!.mbps / 8).toStringAsFixed(2)} MB/s',
+ ),
+ if (speedResult != null)
+ Text(
+ '首字节 ${speedResult!.firstByte.inMilliseconds} ms · '
+ '下载 ${formatBytes(speedResult!.bytes)}',
+ ),
+ if (speedTesting) const LinearProgressIndicator(),
+ if (speedError.isNotEmpty) Text(speedError),
+ const Text(
+ '通过当前代理入口下载 Cloudflare 测试资源,遵循当前分流规则。最多 32 MB / 15 秒,会占用带宽;结果不代表视频站点速度。',
+ ),
+ if (!running) const Text('连接代理后可测速'),
+ Wrap(
+ spacing: 12,
+ children: [
+ FilledButton.tonalIcon(
+ onPressed: !running || busy || speedTesting
+ ? null
+ : measureProxySpeed,
+ icon: const Icon(Icons.speed),
+ label: const Text('开始测速'),
+ ),
+ if (speedTesting)
+ TextButton(
+ onPressed: proxySpeedTest.cancel,
+ child: const Text('取消测速'),
+ ),
+ ],
+ ),
+ ]);
+
Widget overview() {
if (proxyProfile.feature != 'proxy') return networkOverview();
final selected = proxyProfile.nodes
@@ -956,6 +1053,7 @@ class _LabScreenState extends State {
],
),
]),
+ speedPanel(),
if (logs.isNotEmpty)
panel('最近事件', logs.take(3).map((line) => Text(line)).toList()),
],
@@ -1005,15 +1103,7 @@ class _LabScreenState extends State {
SelectableText('SOCKS5:${proxySession?.endpoint ?? '—'}'),
const Text('TCP / UDP · 自动公告分流。子网变化时重建引擎,已有代理连接需重连。'),
]),
- metricGroup([
- metric(
- '最近测试耗时',
- result == null
- ? '—'
- : '${(result!['elapsed_ms'] as num).toStringAsFixed(1)} ms',
- ),
- metric('远端节点', '${status['peer_count'] ?? 0}'),
- ]),
+ if (proxyProfile.feature == 'combined') speedPanel(),
panel('网络流量', [
metricGroup([
metric(
@@ -1065,20 +1155,6 @@ class _LabScreenState extends State {
label: const Text('复制网络诊断'),
),
]),
- panel('最近测试趋势', [
- const Text('显示连接或回显耗时,并非持续服务器 RTT'),
- const SizedBox(height: 12),
- SizedBox(height: 140, child: CustomPaint(painter: _Trend(latencies))),
- ]),
- panel('快速测试', [
- Text('目标 ${target.text}'),
- const SizedBox(height: 12),
- FilledButton.icon(
- onPressed: () => openDetail('网络诊断', tests),
- icon: const Icon(Icons.play_arrow),
- label: const Text('打开连接测试'),
- ),
- ]),
panel(
'最近事件',
logs
@@ -1689,44 +1765,3 @@ class _LabScreenState extends State {
);
}
}
-
-class _Trend extends CustomPainter {
- final List samples;
- _Trend(this.samples);
- @override
- void paint(Canvas canvas, Size size) {
- final grid = Paint()
- ..color = const Color(0xffe9e6e0)
- ..strokeWidth = 1;
- for (var i = 0; i < 5; i++) {
- final y = size.height * i / 4;
- canvas.drawLine(Offset(0, y), Offset(size.width, y), grid);
- }
- if (samples.length < 2) {
- return;
- }
- final max = samples.reduce((a, b) => a > b ? a : b) * 1.2 + 1;
- final path = Path();
- for (var i = 0; i < samples.length; i++) {
- final p = Offset(
- size.width * i / (samples.length - 1),
- size.height * (1 - samples[i] / max),
- );
- if (i == 0) {
- path.moveTo(p.dx, p.dy);
- } else {
- path.lineTo(p.dx, p.dy);
- }
- }
- canvas.drawPath(
- path,
- Paint()
- ..color = const Color(0xff087d8e)
- ..style = PaintingStyle.stroke
- ..strokeWidth = 2,
- );
- }
-
- @override
- bool shouldRepaint(_Trend oldDelegate) => true;
-}
diff --git a/apps/meshport_lab/lib/features/proxy_speed_test.dart b/apps/meshport_lab/lib/features/proxy_speed_test.dart
new file mode 100644
index 0000000..5eea15c
--- /dev/null
+++ b/apps/meshport_lab/lib/features/proxy_speed_test.dart
@@ -0,0 +1,74 @@
+import 'dart:async';
+import 'dart:io';
+
+class ProxySpeedResult {
+ final int bytes;
+ final Duration elapsed;
+ final Duration firstByte;
+ const ProxySpeedResult(this.bytes, this.elapsed, this.firstByte);
+ double get mbps => bytes * 8 / elapsed.inMicroseconds.clamp(1, 1 << 62);
+}
+
+/// Explicit loopback HTTP proxy only: never fall back to a physical connection.
+class ProxySpeedTest {
+ HttpClient? _client;
+ bool _cancelled = false;
+ static const maxBytes = 32 * 1024 * 1024;
+
+ void cancel() {
+ _cancelled = true;
+ _client?.close(force: true);
+ }
+
+ Future run({
+ required int port,
+ Uri? resource,
+ Duration limit = const Duration(seconds: 15),
+ void Function(int bytes, Duration elapsed)? onProgress,
+ }) async {
+ if (_client != null) throw StateError('测速正在进行');
+ if (port < 1 || port > 65535) throw ArgumentError('无效代理端口');
+ _cancelled = false;
+ final client = HttpClient()..connectionTimeout = const Duration(seconds: 8);
+ _client = client;
+ client.findProxy = (_) => 'PROXY 127.0.0.1:$port';
+ final clock = Stopwatch()..start();
+ var bytes = 0;
+ Duration? firstByte;
+ var timedOut = false;
+ final timeout = Timer(limit, () {
+ timedOut = true;
+ client.close(force: true);
+ });
+ try {
+ final request = await client.getUrl(
+ resource ??
+ Uri.parse('https://speed.cloudflare.com/__down?bytes=$maxBytes'),
+ );
+ request.followRedirects = false;
+ request.headers.set(HttpHeaders.acceptEncodingHeader, 'identity');
+ final response = await request.close();
+ if (response.statusCode != HttpStatus.ok) {
+ throw HttpException('测速资源返回 HTTP ${response.statusCode}');
+ }
+ await for (final chunk in response) {
+ if (_cancelled) throw StateError('测速已取消');
+ firstByte ??= clock.elapsed;
+ bytes += chunk.length;
+ onProgress?.call(bytes, clock.elapsed);
+ if (bytes >= maxBytes) break;
+ }
+ } catch (_) {
+ if (_cancelled) throw StateError('测速已取消');
+ if (!timedOut || bytes == 0) rethrow;
+ } finally {
+ timeout.cancel();
+ clock.stop();
+ client.close(force: true);
+ _client = null;
+ }
+ if (_cancelled) throw StateError('测速已取消');
+ if (bytes == 0) throw StateError('测速未收到数据');
+ return ProxySpeedResult(bytes, clock.elapsed, firstByte ?? clock.elapsed);
+ }
+}
diff --git a/apps/meshport_lab/test/proxy_overview_logs_test.dart b/apps/meshport_lab/test/proxy_overview_logs_test.dart
new file mode 100644
index 0000000..2213b49
--- /dev/null
+++ b/apps/meshport_lab/test/proxy_overview_logs_test.dart
@@ -0,0 +1,43 @@
+import 'package:flutter/material.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:meshport_lab/features/detail_pages.dart';
+import 'package:meshport_lab/features/lab_screen.dart';
+
+void main() {
+ testWidgets('overview offers explicit speed measurement after connection', (
+ tester,
+ ) async {
+ await tester.pumpWidget(
+ const MaterialApp(home: LabScreen(initializeNative: false)),
+ );
+ expect(find.text('代理测速'), findsOneWidget);
+ expect(find.text('连接代理后可测速'), findsOneWidget);
+ expect(
+ tester
+ .widget(find.widgetWithText(FilledButton, '开始测速'))
+ .onPressed,
+ isNull,
+ );
+ });
+
+ testWidgets('proxy log view excludes unrelated mesh events', (tester) async {
+ await tester.pumpWidget(
+ MaterialApp(
+ home: Scaffold(
+ body: LogsPageBody(
+ logs: const [
+ '12:00:00 代理 · outbound connection',
+ '12:00:01 穿透 · peer connected',
+ ],
+ onClear: () {},
+ ),
+ ),
+ ),
+ );
+ expect(find.text('12:00:01 穿透 · peer connected'), findsOneWidget);
+ await tester.tap(find.text('代理日志'));
+ await tester.pump();
+ expect(find.text('12:00:01 穿透 · peer connected'), findsNothing);
+ expect(find.text('12:00:00 代理 · outbound connection'), findsOneWidget);
+ });
+}
diff --git a/apps/meshport_lab/test/proxy_speed_test_test.dart b/apps/meshport_lab/test/proxy_speed_test_test.dart
new file mode 100644
index 0000000..8e54c7b
--- /dev/null
+++ b/apps/meshport_lab/test/proxy_speed_test_test.dart
@@ -0,0 +1,77 @@
+import 'dart:io';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:meshport_lab/features/proxy_speed_test.dart';
+
+void main() {
+ test('download uses explicit proxy without resolving the target', () async {
+ final proxy = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);
+ addTearDown(() => proxy.close(force: true));
+ var calls = 0;
+ proxy.listen((request) async {
+ calls++;
+ expect(request.uri.host, 'speed-test.invalid');
+ request.response.add(List.filled(65536, 42));
+ await request.response.close();
+ });
+ final result = await ProxySpeedTest().run(
+ port: proxy.port,
+ resource: Uri.parse('http://speed-test.invalid/download'),
+ );
+ expect(calls, 1);
+ expect(result.bytes, 65536);
+ expect(result.mbps, greaterThan(0));
+ });
+
+ test('unavailable proxy never falls back to direct origin', () async {
+ final origin = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);
+ addTearDown(() => origin.close(force: true));
+ var calls = 0;
+ origin.listen((request) {
+ calls++;
+ request.response.close();
+ });
+ final reserved = await ServerSocket.bind(InternetAddress.loopbackIPv4, 0);
+ final port = reserved.port;
+ await reserved.close();
+ await expectLater(
+ ProxySpeedTest().run(
+ port: port,
+ resource: Uri.parse('http://127.0.0.1:${origin.port}/'),
+ ),
+ throwsA(isA()),
+ );
+ expect(calls, 0);
+ });
+
+ test(
+ 'cancellation and error responses do not produce a speed result',
+ () async {
+ final proxy = await HttpServer.bind(InternetAddress.loopbackIPv4, 0);
+ addTearDown(() => proxy.close(force: true));
+ proxy.listen((request) async {
+ if (request.uri.path == '/failure') {
+ request.response.statusCode = 503;
+ } else {
+ request.response.add(List.filled(65536, 42));
+ }
+ await request.response.close();
+ });
+ final speed = ProxySpeedTest();
+ await expectLater(
+ speed.run(
+ port: proxy.port,
+ resource: Uri.parse('http://speed-test.invalid/failure'),
+ ),
+ throwsA(isA()),
+ );
+ await expectLater(
+ speed.run(
+ port: proxy.port,
+ resource: Uri.parse('http://speed-test.invalid/download'),
+ onProgress: (_, _) => speed.cancel(),
+ ),
+ throwsStateError,
+ );
+ },
+ );
+}
diff --git a/docs/android.md b/docs/android.md
index 39cafb2..2d6916c 100644
--- a/docs/android.md
+++ b/docs/android.md
@@ -12,6 +12,12 @@ scripts/package-lab-android.sh
脚本先编译含 system-vpn 功能的 Rust 库,再打包 Flutter APK,输出到 outputs/android。当前使用开发签名,适合本机安装验证。正式发行需配置自己的签名和应用 ID。原生库与 JNI 桥接使用 16 KB ELF 页面对齐;当前真机为 4 KB 页面,16 KB 设备运行尚未验证。
+## 签名冲突时使用独立版
+
+无法取得旧版签名时,可执行 `sh scripts/package-lab-android.sh --standalone` 打包“MeshPort 独立版”。其应用 ID 为 `com.meshport.client.standalone`,使用独立持久签名,可与原应用共存;需要重新导入配置,不读取旧应用的私有数据。原应用无需卸载。系统仍只能同时连接一个 VPN。
+
+独立版签名保存在被 Git 忽略的 `work/android-signing/`,构建缓存清理脚本会保留此目录。请备份整个目录,后续独立版升级必须复用该密钥。脚本在密钥或属性文件缺失时拒绝重新生成不完整身份。此签名用于本地分发,不代表已经完成应用商店发布配置。
+
## 两种模式
- 应用内:通过 meshport_flutter SDK 的 TCP/UDP 接口通信,不创建系统 VPN。
diff --git a/docs/client-runtime.md b/docs/client-runtime.md
index 295f3b8..27dd2dd 100644
--- a/docs/client-runtime.md
+++ b/docs/client-runtime.md
@@ -76,3 +76,9 @@ Go 测试包含真实 SOCKS/直连通信、三种模式的组网优先、DNS 域
## 尚未完成
Android 单一 VPN 真机通信与网络切换、macOS 互联网统一模式全局 DNS 和网络切换、相机及真实登录启动恢复、长时间和后台稳定性测试仍需验证。规则集、扫码/文件导入、自动订阅更新与应用启动自动连接已接入,见 [高级客户端功能](advanced-client-features.md)。自动测速选出口按用户要求不实现。原有 Android 独立组网真机测试与本轮新增代理联合模式测试是不同范围。
+
+## 概览测速与代理日志
+
+概览移除测试耗时、测试趋势和快速连接测试入口;原有诊断工具仍可从详情页访问。代理及联合模式增加手动测速卡片,通过本机 127.0.0.1 的受管理 HTTP/SOCKS 混合入口下载 Cloudflare 资源,不回退到直接连接。最多下载 32 MB,15 秒停止,支持取消;重连清除前次结果。显示端到端平均下载 Mbps / MB/s 和首字节耗时。测速占用带宽、遵循当前分流规则;直连模式或命中直连规则时不代表节点性能,结果也不代表 YouTube CDN 吞吐。
+
+代理引擎收集 info 及以上级别的连接、出口和错误事件,原始输出保持写入空设备,只有脱敏事件返回界面。引擎保留最近 128 条,界面保留最近 300 条会话日志;日志页可筛选代理日志并复制当前范围。应用内与统一 VPN 共用该采集路径。不会收集数据包内容,目标地址保留,已知密码、UUID、URL 认证与查询参数隐藏。
diff --git a/engines/singbox/bridge/config.go b/engines/singbox/bridge/config.go
index d182d23..f6f0630 100644
--- a/engines/singbox/bridge/config.go
+++ b/engines/singbox/bridge/config.go
@@ -528,7 +528,7 @@ func (c Config) managedJSONForPlatform(platform string) ([]byte, error) {
map[string]any{"network": "udp", "port": 443, "protocol": "quic", "domain_suffix": []string{"googlevideo.com"}, "action": "reject"},
)
}
- inbounds := []any{map[string]any{"type": "socks", "tag": "local", "listen": "127.0.0.1", "listen_port": c.ListenPort}}
+ inbounds := []any{map[string]any{"type": "mixed", "tag": "local", "listen": "127.0.0.1", "listen_port": c.ListenPort}}
route := map[string]any{"rules": routeRules, "final": final}
if len(ruleSets) > 0 {
route["rule_set"] = ruleSets
diff --git a/engines/singbox/bridge/engine.go b/engines/singbox/bridge/engine.go
index 2689f25..69ac5e2 100644
--- a/engines/singbox/bridge/engine.go
+++ b/engines/singbox/bridge/engine.go
@@ -154,7 +154,7 @@ func (e *Engine) Start(parent context.Context, config Config) error {
// Collect bounded, credential-redacted warning/error events in memory.
// Raw upstream logs must never go to stderr or a user's log file.
if !e.selfTestTrace {
- options.Log = &option.LogOptions{Level: "warn", Output: os.DevNull}
+ options.Log = &option.LogOptions{Level: "info", Output: os.DevNull}
}
instance, err := box.New(box.Options{Options: options, Context: ctx})
if err != nil {
diff --git a/engines/singbox/bridge/http_entry_test.go b/engines/singbox/bridge/http_entry_test.go
new file mode 100644
index 0000000..2dd986e
--- /dev/null
+++ b/engines/singbox/bridge/http_entry_test.go
@@ -0,0 +1,56 @@
+package bridge
+
+import (
+ "bufio"
+ "context"
+ "io"
+ "net"
+ "net/http"
+ "strings"
+ "testing"
+ "time"
+)
+
+func TestMixedHTTPEntryUsesSelectedProxyAndCapturesConnections(t *testing.T) {
+ upstream, count := socksEcho(t)
+ defer upstream.Close()
+ entry, port := reservePort(t)
+ entry.Close()
+ var engine Engine
+ if err := engine.Start(context.Background(), Config{
+ ListenPort: port, Feature: "proxy", Mode: "global",
+ Proxy: map[string]any{"type": "socks", "server": "127.0.0.1", "server_port": upstream.Addr().(*net.TCPAddr).Port},
+ }); err != nil {
+ t.Fatal(err)
+ }
+ defer engine.Close()
+ conn, err := net.Dial("tcp", entry.Addr().String())
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer conn.Close()
+ conn.SetDeadline(time.Now().Add(5 * time.Second))
+ io.WriteString(conn, "CONNECT 198.51.100.8:443 HTTP/1.1\r\nHost: 198.51.100.8:443\r\n\r\n")
+ reader := bufio.NewReader(conn)
+ response, err := http.ReadResponse(reader, &http.Request{Method: "CONNECT"})
+ if err != nil || response.StatusCode != 200 {
+ t.Fatalf("CONNECT: %v %v", response, err)
+ }
+ io.WriteString(conn, "proxy-download")
+ echoed := make([]byte, len("proxy-download"))
+ if _, err = io.ReadFull(reader, echoed); err != nil || string(echoed) != "proxy-download" {
+ t.Fatal("proxy tunnel failed", err)
+ }
+ if count.Load() != 1 {
+ t.Fatal("download did not use selected outbound")
+ }
+ found := false
+ for _, event := range engine.Snapshot().RuntimeEvents {
+ if strings.Contains(event.Message, "198.51.100.8") {
+ found = true
+ }
+ }
+ if !found {
+ t.Fatal("connection missing from runtime logs")
+ }
+}
diff --git a/engines/singbox/bridge/inbound.go b/engines/singbox/bridge/inbound.go
index 41aea0a..c72fd7f 100644
--- a/engines/singbox/bridge/inbound.go
+++ b/engines/singbox/bridge/inbound.go
@@ -11,6 +11,7 @@ import (
C "github.com/sagernet/sing-box/constant"
"github.com/sagernet/sing-box/log"
"github.com/sagernet/sing-box/option"
+ "github.com/sagernet/sing-box/protocol/mixed"
"github.com/sagernet/sing-box/protocol/socks"
N "github.com/sagernet/sing/common/network"
)
@@ -61,7 +62,8 @@ func (s *connectionSet) closeAll() {
}
type trackedInbound struct {
- *socks.Inbound
+ adapter.Inbound
+ handler adapter.TCPInjectableInbound
listener *listener.Listener
connections connectionSet
}
@@ -73,13 +75,23 @@ func registerTrackedInbound(registry *inbound.Registry) {
if err != nil {
return nil, err
}
- tracked := &trackedInbound{Inbound: delegate.(*socks.Inbound), connections: connectionSet{connections: make(map[*trackedConnection]struct{})}}
+ tracked := &trackedInbound{Inbound: delegate, handler: delegate.(*socks.Inbound), connections: connectionSet{connections: make(map[*trackedConnection]struct{})}}
// The delegate only handles the protocol. This listener owns the
// accepted TCP controls; its options also constrain UDP association
// allocation through the delegate's original packet-listener helper.
tracked.listener = listener.New(listener.Options{Context: ctx, Logger: logger, Network: []string{N.NetworkTCP}, Listen: options.ListenOptions, ConnectionHandler: tracked})
return tracked, nil
})
+ inbound.Register[option.HTTPMixedInboundOptions](registry, C.TypeMixed,
+ func(ctx context.Context, router adapter.Router, logger log.ContextLogger, tag string, options option.HTTPMixedInboundOptions) (adapter.Inbound, error) {
+ delegate, err := mixed.NewInbound(ctx, router, logger, tag, options)
+ if err != nil {
+ return nil, err
+ }
+ tracked := &trackedInbound{Inbound: delegate, handler: delegate.(*mixed.Inbound), connections: connectionSet{connections: make(map[*trackedConnection]struct{})}}
+ tracked.listener = listener.New(listener.Options{Context: ctx, Logger: logger, Network: []string{N.NetworkTCP}, Listen: options.ListenOptions, ConnectionHandler: tracked})
+ return tracked, nil
+ })
}
func (h *trackedInbound) Start(stage adapter.StartStage, scope *adapter.Scope) error {
@@ -103,5 +115,5 @@ func (h *trackedInbound) NewConnection(ctx context.Context, conn net.Conn, metad
_ = conn.Close()
return
}
- h.Inbound.NewConnection(ctx, tracked, metadata, onClose)
+ h.handler.NewConnection(ctx, tracked, metadata, onClose)
}
diff --git a/engines/singbox/bridge/runtime_logs.go b/engines/singbox/bridge/runtime_logs.go
index 7b86cb6..efdbf00 100644
--- a/engines/singbox/bridge/runtime_logs.go
+++ b/engines/singbox/bridge/runtime_logs.go
@@ -47,7 +47,7 @@ func (r *runtimeLogs) configure(node map[string]any) {
}
func (r *runtimeLogs) WriteMessage(level log.Level, message string) {
- if level > log.LevelWarn {
+ if level > log.LevelInfo {
return
}
r.mu.Lock()
@@ -63,8 +63,8 @@ func (r *runtimeLogs) WriteMessage(level log.Level, message string) {
}
r.sequence++
r.events = append(r.events, RuntimeEvent{Sequence: r.sequence, Message: message})
- if len(r.events) > 32 {
- r.events = append([]RuntimeEvent(nil), r.events[len(r.events)-32:]...)
+ if len(r.events) > 128 {
+ r.events = append([]RuntimeEvent(nil), r.events[len(r.events)-128:]...)
}
}
diff --git a/engines/singbox/bridge/runtime_logs_test.go b/engines/singbox/bridge/runtime_logs_test.go
index 65d348f..6f86ea4 100644
--- a/engines/singbox/bridge/runtime_logs_test.go
+++ b/engines/singbox/bridge/runtime_logs_test.go
@@ -9,12 +9,12 @@ import (
func TestRuntimeLogsBoundedAndRedacted(t *testing.T) {
var logs runtimeLogs
logs.configure(map[string]any{"uuid": "secret-uuid", "password": "secret-password"})
- logs.WriteMessage(log.LevelInfo, "ignored")
- for i := 0; i < 40; i++ {
+ logs.WriteMessage(log.LevelInfo, "connection opened")
+ for i := 0; i < 140; i++ {
logs.WriteMessage(log.LevelError, "failure secret-uuid secret-password https://u:p@example.test/?token=secret-token")
}
events := logs.snapshot()
- if len(events) != 32 || events[0].Sequence != 9 {
+ if len(events) != 128 || events[0].Sequence != 14 {
t.Fatal("unbounded or incorrect log sequence")
}
for _, e := range events {
@@ -34,3 +34,14 @@ func TestRuntimeLogsRedactOverlappingCredentialValues(t *testing.T) {
t.Fatal("short credential prevented full password redaction")
}
}
+
+func TestRuntimeLogsCaptureConnectionsButSkipDebug(t *testing.T) {
+ var logs runtimeLogs
+ logs.configure(map[string]any{"password": "example-secret"})
+ logs.WriteMessage(log.LevelDebug, "debug packet")
+ logs.WriteMessage(log.LevelInfo, "outbound connection example-secret")
+ events := logs.snapshot()
+ if len(events) != 1 || strings.Contains(events[0].Message, "example-secret") {
+ t.Fatal("connection logs missing or credentials exposed")
+ }
+}
diff --git a/outputs/validation/android-standalone-20261013.md b/outputs/validation/android-standalone-20261013.md
new file mode 100644
index 0000000..34410b3
--- /dev/null
+++ b/outputs/validation/android-standalone-20261013.md
@@ -0,0 +1,10 @@
+# Android independent package — 2026-10-13
+
+- App: MeshPort 独立版; application ID `com.meshport.client.standalone`.
+- Build: 0.1.0 / 1791938964, ARM64 Release, Android 8.0/API 26 minimum.
+- Artifact: `outputs/android/MeshPort-Standalone-0.1.0-1791938964-release.apk`.
+- APK SHA-256: `fb252396aeca83cf3340445046b7698f9db7f92c3b8c2979ecab4a7c1e319557`.
+- New persistent RSA 3072 signing identity; certificate SHA-256: `ab8bc33b6441aec319fb7b585038efb1f1550f12d1fc5b9de8fd11d4302b7c4d`.
+- APK Signature Scheme v2 verification, archive integrity, public bundled configuration, AOT packaging, ZIP 16 KB alignment and native ELF alignment passed. Manifest confirms the original fully qualified MainActivity and MeshVpnService implementations, with a distinct app ID and receiver permission.
+- Build command: `sh scripts/package-lab-android.sh --standalone`. Signing files are under ignored `work/android-signing/`, preserved by cache cleanup; retain/back up this directory for compatible future independent-app updates.
+- Original app and its profiles are untouched. Independent app has its own sandbox and needs configuration imported again; this package does not update the old app. No device was available, so actual installation, VPN connection and video throughput were not tested.
diff --git a/outputs/validation/latest-packages-20261013.md b/outputs/validation/latest-packages-20261013.md
new file mode 100644
index 0000000..16af70c
--- /dev/null
+++ b/outputs/validation/latest-packages-20261013.md
@@ -0,0 +1,20 @@
+# Latest macOS and Android packages — 2026-10-13
+
+These packages include the new overview proxy speed card, removal of overview test widgets, proxy log filtering and info-level redacted engine logging, along with the earlier local profile storage, macOS helper authorization reuse and video TCP fallback.
+
+## macOS
+
+- Artifact: `outputs/macos/MeshPort-0.1.0-1791957009-arm64-release.zip` (contains `MeshPort.app`). Expanded bundle also retained under the same versioned output name.
+- SHA-256: `8aab1f5a32324947ef6f9c1605b9d2425ec69081e5311e60d7462e686ee9cb4c`.
+- Version 0.1.0 / 1791957009; Apple Silicon, macOS 12+.
+- Apple Development signed; deep/strict signature verification passed. Not Developer ID/notarized. Helper included; ZIP integrity and exact public default configuration verified.
+
+## Android
+
+- Artifact: `outputs/android/MeshPort-Standalone-0.1.0-1791957094-release.apk`.
+- SHA-256: `030bc2a85c9d04064c8d02fe2cfa54a9132eea6e80e871c7de25e6e912207e0d`.
+- App label MeshPort 独立版; ID `com.meshport.client.standalone`; version 0.1.0 / 1791957094; ARM64, Android 8.0+.
+- Persistent signing certificate SHA-256 `ab8bc33b6441aec319fb7b585038efb1f1550f12d1fc5b9de8fd11d4302b7c4d`, matching the preceding independent APK. Intended to update that independent app while keeping its profiles, or install alongside the original app with a separate sandbox.
+- APK signature v2, archive integrity, AOT, exact public default configuration, 16 KB ZIP alignment and all six native ELF library alignments passed.
+
+Flutter tests (55 passed / 6 skipped), analyzer, Go bridge suite/race and vet passed before packaging. Both full Release builds passed. No existing app was replaced or launched, and no device/VPN/WAN speed test was performed. These builds supersede the preceding validation note that no updated installer had been produced.
diff --git a/outputs/validation/proxy-overview-speed-logs-20261013.md b/outputs/validation/proxy-overview-speed-logs-20261013.md
new file mode 100644
index 0000000..418d788
--- /dev/null
+++ b/outputs/validation/proxy-overview-speed-logs-20261013.md
@@ -0,0 +1,8 @@
+# Proxy overview, speed measurement and logs — 2026-10-13
+
+- Removed network overview test latency, trends and quick-test launcher. Added manual proxy speed card for proxy/combined use, with progress, cancellation, Mbps/MB/s and first-byte timing.
+- Speed download uses a loopback HTTP proxy on the existing managed port; the inbound now supports HTTP and SOCKS while retaining tracked connection limits and cleanup. No direct fallback; existing routing rules remain in effect. Maximum 32 MB / 15 seconds from Cloudflare, so results reflect current routing and endpoint conditions, not guaranteed node or video-CDN throughput.
+- Proxy logging now includes info-level connection/outbound messages, retaining redaction and bounded buffers (128 native / 300 UI). Application-mode refresh includes proxy runtime events. Log UI offers all/proxy scopes and copies the visible scope.
+- Go bridge suite and race tests passed, vet passed. Real HTTP CONNECT fixture confirms selected SOCKS outbound and actual connection log collection; existing TCP/UDP, lifecycle, routing and QUIC tests passed.
+- Final Flutter suite: 55 passed / 6 skipped; analyzer clean. Overview/log UI tests passed. Three speed tests cover explicit proxy use without target DNS, unavailable proxy without direct fallback, failed responses and cancellation.
+- No real device, privileged TUN speed measurement or WAN bandwidth test performed. No updated installer produced for these UI/engine changes; preceding independent APK predates them.
diff --git a/packages/meshport_client_core/lib/src/mesh_proxy_session.dart b/packages/meshport_client_core/lib/src/mesh_proxy_session.dart
index 4bb1f35..c95e2f7 100644
--- a/packages/meshport_client_core/lib/src/mesh_proxy_session.dart
+++ b/packages/meshport_client_core/lib/src/mesh_proxy_session.dart
@@ -85,7 +85,7 @@ class MeshProxySession {
if (_active) {
await _sync(meshAvailable ? snapshot : {});
}
- return snapshot;
+ return {...snapshot, if (_active) 'proxy': await proxy.status()};
} catch (_) {
if (_active || _ownsNetwork) await _fail();
rethrow;
diff --git a/scripts/build-lab-android.sh b/scripts/build-lab-android.sh
index 1585de8..dbc417c 100755
--- a/scripts/build-lab-android.sh
+++ b/scripts/build-lab-android.sh
@@ -30,6 +30,8 @@ cd apps/meshport_lab
flutter build apk "$mode" --target-platform android-arm64 --build-number="$build_number"
cd ../..
mkdir -p outputs/android
-output="$PWD/outputs/android/MeshPort-0.1.0-$build_number-$profile.apk"
+prefix=MeshPort
+if [ "${MESHPORT_ANDROID_STANDALONE:-0}" = 1 ]; then prefix=MeshPort-Standalone; fi
+output="$PWD/outputs/android/$prefix-0.1.0-$build_number-$profile.apk"
cp "apps/meshport_lab/build/app/outputs/flutter-apk/app-$profile.apk" "$output"
printf '%s\n' "$output"
diff --git a/scripts/package-lab-android.sh b/scripts/package-lab-android.sh
index 6a7e5d1..46da1d5 100755
--- a/scripts/package-lab-android.sh
+++ b/scripts/package-lab-android.sh
@@ -1,6 +1,15 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
+case "${1:-}" in
+ "") ;;
+ --standalone)
+ python3 scripts/prepare-android-standalone-signing.py
+ export MESHPORT_ANDROID_STANDALONE=1
+ export MESHPORT_ANDROID_SIGNING_PROPERTIES="$PWD/work/android-signing/standalone.properties"
+ ;;
+ *) printf '%s\n' 'usage: package-lab-android.sh [--standalone]' >&2; exit 2 ;;
+esac
config=apps/meshport_lab/assets/config/default.toml
saved=$(mktemp)
had_config=0
@@ -12,5 +21,7 @@ restore_config() {
trap restore_config EXIT HUP INT TERM
build_number=$(date +%s)
MESHPORT_PUBLIC_CONFIG=1 MESHPORT_BUILD_NUMBER="$build_number" sh scripts/build-lab-android.sh --release
-output="outputs/android/MeshPort-0.1.0-$build_number-release.apk"
+prefix=MeshPort
+if [ "${MESHPORT_ANDROID_STANDALONE:-0}" = 1 ]; then prefix=MeshPort-Standalone; fi
+output="outputs/android/$prefix-0.1.0-$build_number-release.apk"
shasum -a 256 "$output" > "$output.sha256"
diff --git a/scripts/prepare-android-standalone-signing.py b/scripts/prepare-android-standalone-signing.py
new file mode 100644
index 0000000..25ea90f
--- /dev/null
+++ b/scripts/prepare-android-standalone-signing.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python3
+"""Create a persistent local signing identity for the independent Android app."""
+import os
+from pathlib import Path
+import secrets
+import shutil
+import subprocess
+
+root = Path(__file__).resolve().parents[1]
+directory = root / "work/android-signing"
+directory.mkdir(parents=True, exist_ok=True, mode=0o700)
+directory.chmod(0o700)
+properties = directory / "standalone.properties"
+keystore = directory / "standalone.jks"
+if properties.exists() and keystore.exists():
+ print("Reusing the independent app signing identity")
+elif properties.exists() or keystore.exists():
+ raise SystemExit("Incomplete signing identity; restore its backup instead of generating a new key")
+else:
+ java_home = os.environ.get("JAVA_HOME", "/Applications/Android Studio.app/Contents/jbr/Contents/Home")
+ keytool = Path(java_home) / "bin/keytool"
+ if not keytool.is_file():
+ keytool = shutil.which("keytool")
+ if not keytool:
+ raise SystemExit("Set JAVA_HOME to a JDK containing keytool")
+ password = secrets.token_hex(32)
+ environment = dict(os.environ, MESHPORT_SIGNING_PASSWORD=password)
+ subprocess.run([
+ str(keytool), "-genkeypair", "-keystore", str(keystore),
+ "-storetype", "JKS", "-storepass:env", "MESHPORT_SIGNING_PASSWORD",
+ "-keypass:env", "MESHPORT_SIGNING_PASSWORD", "-alias", "meshportstandalone",
+ "-keyalg", "RSA", "-keysize", "3072", "-validity", "10000",
+ "-dname", "CN=MeshPort Standalone, O=MeshPort", "-noprompt",
+ ], env=environment, check=True)
+ keystore.chmod(0o600)
+ with properties.open("x") as output:
+ properties.chmod(0o600)
+ output.write(f"storeFile={keystore}\nstorePassword={password}\n"
+ f"keyAlias=meshportstandalone\nkeyPassword={password}\n")
+ print("Created the independent app signing identity; keep work/android-signing for future upgrades")