Android CI / android (push) Canceled after 0s
VpnConnection._init() started a 30 s /health poll from the constructor with no lifecycle gating, so it ran for the life of the app process - backgrounded, and whether or not the user ever connected. The app is excluded from its own tunnel, so those requests left in the clear. A periodic request that fires while the user is deliberately not connected is an avoidable fingerprint, and rule 60 already ruled probes out: reachability is meant to be passive. All it bought was the status dot before the first connect, and it got that wrong in both directions - "Offline" on a transient resolver failure against a server that was fine. Reachability now comes from a session sync that succeeded. serverHealthy is isConnected && hasSyncedOnce, so a green dot means a working session rather than a check made beforehand; while disconnected the bar reads "Ready" and claims nothing either way. checkHealth() goes with it. Nothing calls it, and leaving a probe helper in place invites its reuse. Pinned in test/session_lifecycle_regression_test.dart so it cannot come back as a tidy-up. flutter analyze clean, 10/10 tests pass. Co-Authored-By: Claude Opus 5 <[email protected]>
157 lines
5.4 KiB
Dart
157 lines
5.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:revoltvpn/components/online_dot.dart';
|
|
import 'package:revoltvpn/logic/app_colors.dart';
|
|
import 'package:revoltvpn/logic/session_timer.dart';
|
|
import 'package:revoltvpn/logic/vpn_connection.dart';
|
|
|
|
// The one line worth showing right now, and whether it is a problem.
|
|
class _StatusDetail {
|
|
const _StatusDetail(this.text, {this.isProblem = false});
|
|
|
|
final String text;
|
|
final bool isProblem;
|
|
}
|
|
|
|
_StatusDetail? _detail(VpnConnection vpn, SessionTimer timer) {
|
|
final error = vpn.errorMessage;
|
|
if (error != null && error.isNotEmpty) {
|
|
return _StatusDetail(error.replaceAll('\n', ' '), isProblem: true);
|
|
}
|
|
|
|
if (vpn.status == VpnStatus.connecting ||
|
|
vpn.status == VpnStatus.disconnecting) {
|
|
return _StatusDetail(vpn.statusMessage);
|
|
}
|
|
|
|
// Control plane only - the tunnel still carries traffic.
|
|
if (vpn.status == VpnStatus.connected && timer.serverUnreachable) {
|
|
return const _StatusDetail(
|
|
'Can\'t reach the server — still connected',
|
|
isProblem: true,
|
|
);
|
|
}
|
|
|
|
if (vpn.status != VpnStatus.connected) {
|
|
final ended = timer.lastEndMessage;
|
|
if (ended != null) return _StatusDetail(ended, isProblem: true);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
class StatusBar extends StatelessWidget {
|
|
const StatusBar({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Consumer2<VpnConnection, SessionTimer>(
|
|
builder: (context, vpn, timer, _) {
|
|
final isConnected = vpn.status == VpnStatus.connected;
|
|
final isConnecting = vpn.status == VpnStatus.connecting;
|
|
// Rule 60: reachability is known only from a session sync that
|
|
// succeeded, never from a probe. While disconnected the app knows
|
|
// nothing about the server, so it claims nothing either way.
|
|
final serverHealthy = isConnected && timer.hasSyncedOnce;
|
|
|
|
final statusLabel = isConnected
|
|
? (timer.hasSyncedOnce ? 'Online' : 'Syncing…')
|
|
: (isConnecting ? 'Connecting…' : 'Ready');
|
|
|
|
final detail = _detail(vpn, timer);
|
|
|
|
return Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 24),
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: [
|
|
Container(
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 20, vertical: 12),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.bgCard,
|
|
borderRadius: BorderRadius.circular(16),
|
|
border: Border.all(color: AppColors.slate15),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
Image.asset(
|
|
'assets/finland_flag_256.png',
|
|
width: 20,
|
|
height: 20,
|
|
),
|
|
const SizedBox(width: 8),
|
|
const Expanded(
|
|
child: Text(
|
|
'Helsinki, Finland',
|
|
style: TextStyle(
|
|
color: AppColors.accent,
|
|
fontWeight: FontWeight.w600,
|
|
fontSize: 13,
|
|
letterSpacing: 0.5,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Container(
|
|
padding:
|
|
const EdgeInsets.symmetric(horizontal: 20, vertical: 10),
|
|
decoration: BoxDecoration(
|
|
color: AppColors.bgCard,
|
|
borderRadius: BorderRadius.circular(16),
|
|
border: Border.all(color: AppColors.slate15),
|
|
),
|
|
child: Row(
|
|
children: [
|
|
OnlineDot(
|
|
isOnline: serverHealthy,
|
|
label: statusLabel,
|
|
),
|
|
const Spacer(),
|
|
if (vpn.networkTransport != 'unknown' &&
|
|
vpn.networkTransport != 'none')
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 8),
|
|
child: Text(
|
|
vpn.networkTransport,
|
|
style: const TextStyle(
|
|
color: AppColors.textDim,
|
|
fontSize: 11,
|
|
),
|
|
),
|
|
),
|
|
if (isConnected)
|
|
const Icon(
|
|
Icons.lock,
|
|
color: AppColors.green50,
|
|
size: 14,
|
|
),
|
|
],
|
|
),
|
|
),
|
|
// Errors and session-end reasons used to render nowhere.
|
|
if (detail != null)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 6),
|
|
child: Text(
|
|
detail.text,
|
|
textAlign: TextAlign.center,
|
|
style: TextStyle(
|
|
color: detail.isProblem
|
|
? AppColors.red
|
|
: AppColors.textDim,
|
|
fontSize: 11,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|