fix(client): 登出(主动/被强退/会话过期)一律断开隧道
bug:logout() 只清 token,不碰隧道 → 被强制下线/正常退出后 VPN 还连着、继续用数据面。 修:ConnectionController 监听 authProvider,isLoggedIn 由 true→false 时断开隧道(_disconnect)。 一处覆盖所有登出路径(设置页登出/会话轮询强退/token 续期失败登出);token 续期仍登录不触发。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -81,12 +81,21 @@ class ConnectionController extends StateNotifier<ConnectionState> {
|
||||
_statusSub = _bridge.statusStream.listen(_onKernelStatus);
|
||||
// 订阅内核 stats:连接态把 urltest 实测回写连接节点的 ping,让连接页与节点列表同源一致。
|
||||
_statsSub = _bridge.statsStream.listen(_onStats);
|
||||
// 登出(主动退出 / 被强制下线 / 会话过期)→ 一律断开隧道:别让已登出/被踢的设备继续用
|
||||
// 数据面。一处监听 auth 覆盖所有登出路径。token 续期(仍登录)不触发。
|
||||
_authSub = _ref.listen<AuthState>(authProvider, (prev, next) {
|
||||
if ((prev?.isLoggedIn ?? false) && !next.isLoggedIn) {
|
||||
_userDisconnect = true; // 视为「非节点异常」的主动断开,不弹「节点异常」
|
||||
unawaited(_disconnect());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final Ref _ref;
|
||||
final VpnBridge _bridge;
|
||||
StreamSubscription<VpnStatus>? _statusSub;
|
||||
StreamSubscription<VpnStatsEvent>? _statsSub;
|
||||
ProviderSubscription<AuthState>? _authSub;
|
||||
Timer? _elapsed;
|
||||
Timer? _watchdog;
|
||||
bool _probing = false;
|
||||
@@ -346,6 +355,7 @@ class ConnectionController extends StateNotifier<ConnectionState> {
|
||||
void dispose() {
|
||||
_statusSub?.cancel();
|
||||
_statsSub?.cancel();
|
||||
_authSub?.close();
|
||||
_stopElapsed();
|
||||
_stopWatchdog();
|
||||
_api?.dispose();
|
||||
|
||||
Reference in New Issue
Block a user