feat(routing): 存档案后连接态自动重连使新规则生效
Task 9: RoutingProfileNotifier._persist() 保存成功后,若 connectionProvider.phase == on,触发 ConnectionController.reapplyRoutingProfile()(disconnect→connect, 不改选中节点)重连,让服务端按新档案渲染的规则生效;off 态不触发。 新增 l10n 键 routingRulesReconnecting(单源 design/i18n/strings.json → codegen), 「规则已更新,正在重连…」区别于既有 nodeReconnecting(弱网抖动语义)。 reapplyRoutingProfile 内先置 _userDisconnect=true 再 disconnect,避免其触发的 kernel off 事件被 _onKernelStatus 误判「意外掉线」、再抢跑一次 watchdog 自动重连。
This commit is contained in:
@@ -182,6 +182,24 @@ class ConnectionController extends StateNotifier<ConnectionState> {
|
||||
}
|
||||
}
|
||||
|
||||
/// 分流档案保存成功后触发(Task 9):仅当前已连接(on)才重连,使服务端按新档案
|
||||
/// 渲染的规则生效;off 态不触发(下次连接自然拿到新配置)。复刻 onNodeChanged 的
|
||||
/// disconnect→connect 序列(不改选中节点),附加「规则已更新」瞬态提示 ——
|
||||
/// 与 _tryAutoReconnectCurrent 同法:重连发起后若仍在握手/已连上(非 off),把
|
||||
/// error 字段临时置成提示文案,连上后随下一次 copyWith(仅 phase/elapsed)自然清除。
|
||||
Future<void> reapplyRoutingProfile() async {
|
||||
if (state.phase != VpnPhase.on) return;
|
||||
// 标记「非节点异常」的主动断开:否则 bridge.stop() 触发的 kernel off 事件会被
|
||||
// _onKernelStatus 当成意外掉线,拉着 _handleUnexpectedOff 再抢跑一次自动重连,
|
||||
// 与这里的 _connect() 撞车、多连一次(同 toggle() 主动断开时的用法)。
|
||||
_userDisconnect = true;
|
||||
await _disconnect();
|
||||
await _connect();
|
||||
if (mounted && state.phase != VpnPhase.off) {
|
||||
state = ConnectionState(phase: state.phase, error: _ref.read(appTextProvider).routingRulesReconnecting);
|
||||
}
|
||||
}
|
||||
|
||||
// ── 内部 ─────────────────────────────────────────────────────
|
||||
|
||||
Future<void> _connect() async {
|
||||
|
||||
Reference in New Issue
Block a user