fix(client): 连接态把内核 urltest 回写连接节点 ping,修延迟显示 — + 保持同源一致
1.0.32 纯 direct node.ping 的代价:auto-connect 太快连上、没有断开窗口让 direct TCP 量到 延迟 → node.ping 一直 0 → 显示 —。修:ConnectionController 订阅 stats,连接态把内核 urltest 最小正延迟回写连接节点的 node.ping(setLivePing)。连接页与节点列表都读 node.ping → 同一个数; 连接节点有实时 urltest 值、其余节点保留 direct 实测。断开态仍 direct TCP。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -55,6 +55,20 @@ class NodesNotifier extends AsyncNotifier<List<Node>> {
|
||||
if (result.hasValue) state = result; // 成功才换;失败保留旧列表
|
||||
}
|
||||
|
||||
/// 回写某节点的实测延迟(ms)。连接态由 ConnectionController 用内核 urltest 回填连接节点,
|
||||
/// 让「连接页延迟」与「节点列表延迟」同源(都读 node.ping)、显示一致。ms<=0 忽略。
|
||||
void setLivePing(String uuid, int ms) {
|
||||
if (ms <= 0 || _disposed) return;
|
||||
final list = state.valueOrNull;
|
||||
if (list == null) return;
|
||||
var changed = false;
|
||||
final updated = [
|
||||
for (final n in list)
|
||||
if (n.uuid == uuid && n.ping != ms) (() { changed = true; return n.copyWith(ping: ms); })() else n
|
||||
];
|
||||
if (changed) state = AsyncData(updated);
|
||||
}
|
||||
|
||||
/// 后台实测各节点延迟,完成后回填(notifier 未销毁才更新)。
|
||||
/// 探测失败(返回 0,如连接态全局 TUN 把到节点的 TCP 握手接住)时**保留旧 ping**,
|
||||
/// 不把已知延迟覆盖成空——否则连上后节点列表延迟会整列消失。
|
||||
|
||||
Reference in New Issue
Block a user