fix(client): 连接态延迟只认内核 urltest,跳过直连实测(对齐 Windows 方法)
连接页延迟显示 ~3ms:连接态下 _measure 的直连 TCP 实测被全局 TUN 在本地接住, connect() 几毫秒即返回(假值),覆盖了内核 urltest 经 setLivePing 回写的真实 RTT (macOS system 栈 TUN 尤其明显)。Windows 端延迟本就取 sing-box urltest(clash API /proxies 的 history delay),macOS 经 libbox writeGroups 的 item.urlTestDelay 同源。 修复:_measure 在 connectionProvider.phase==on 时直接返回,不做直连实测——连接态延迟 只认 urltest(与 Windows 一致),断开后再恢复直连实测。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import '../models/node.dart';
|
||||
import '../services/api_config.dart';
|
||||
import '../services/latency_probe.dart';
|
||||
import 'auth_provider.dart';
|
||||
import 'connection_provider.dart';
|
||||
|
||||
// ── 节点列表 AsyncNotifier ────────────────────────────────────────
|
||||
|
||||
@@ -101,6 +102,10 @@ class NodesNotifier extends AsyncNotifier<List<Node>> {
|
||||
/// 不把已知延迟覆盖成空——否则连上后节点列表延迟会整列消失。
|
||||
Future<void> _measure(List<Node> list) async {
|
||||
if (list.isEmpty) return;
|
||||
// 连接态:全局 TUN 把「到节点的直连 TCP 握手」在本地接住,connect() 几毫秒就返回
|
||||
// (假值,非真实 RTT)。这会覆盖掉内核 urltest 经 setLivePing 回写的真实延迟(连接页
|
||||
// 因此显示 ~3ms)。连接时延迟只认 urltest,跳过直连实测;断开后再恢复实测。
|
||||
if (ref.read(connectionProvider).phase == VpnPhase.on) return;
|
||||
final pings = await probeAll(
|
||||
[for (final n in list) (uuid: n.uuid, host: n.host, port: n.port)],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user