fix(client): 节点列表延迟探测失败时保留旧值,修连接后整列延迟消失
返工引入的回归:看门狗连接态周期 refresh→_measure 重测所有节点 TCP ping,但连接态 全局 TUN 把到节点的握手接住→probeAll 返回 0→pings[uuid]??n.ping 因 0 非 null 覆盖成空。 改:探测返回 0 时保留旧 ping。连接态保留上次延迟,断开态正常刷新。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -56,13 +56,18 @@ class NodesNotifier extends AsyncNotifier<List<Node>> {
|
||||
}
|
||||
|
||||
/// 后台实测各节点延迟,完成后回填(notifier 未销毁才更新)。
|
||||
/// 探测失败(返回 0,如连接态全局 TUN 把到节点的 TCP 握手接住)时**保留旧 ping**,
|
||||
/// 不把已知延迟覆盖成空——否则连上后节点列表延迟会整列消失。
|
||||
Future<void> _measure(List<Node> list) async {
|
||||
if (list.isEmpty) return;
|
||||
final pings = await probeAll(
|
||||
[for (final n in list) (uuid: n.uuid, host: n.host, port: n.port)],
|
||||
);
|
||||
if (_disposed) return;
|
||||
final updated = [for (final n in list) n.copyWith(ping: pings[n.uuid] ?? n.ping)];
|
||||
final updated = [
|
||||
for (final n in list)
|
||||
n.copyWith(ping: (pings[n.uuid] ?? 0) > 0 ? pings[n.uuid]! : n.ping)
|
||||
];
|
||||
state = AsyncData(updated);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user