audit #13: notification fix, sync guard, bypass gate, responsive layout, dynamic version, dart format, clock_display to backups, stats race fix, new locks, nginx swarm block
This commit is contained in:
1 parent
e1c5d5b106
commit
54609a3119
11 files changed
+132
-67
No files matched your search
@@ -1,115 +0,0 @@
|
||||
// =============================================================================
|
||||
// clock_display.dart — EDUCATIONAL REFERENCE (not used in production)
|
||||
// =============================================================================
|
||||
//
|
||||
// This widget was the original combined timer + speed + syncing display.
|
||||
// It was replaced by the separate TimerBox and SpeedBox widgets in the
|
||||
// Reality-era UI refactor.
|
||||
//
|
||||
// What's worth studying here:
|
||||
//
|
||||
// 1. TEXT GLOW EFFECT — the yellow glow around the countdown timer:
|
||||
// ```
|
||||
// shadows: [Shadow(color: AppColors.accent50, blurRadius: 16)]
|
||||
// ```
|
||||
// This exact effect was ported to timer_box.dart and is what gives
|
||||
// the countdown its signature pulsing-yellow look.
|
||||
//
|
||||
// 2. SYNCING PLACEHOLDER — conditional spinner + label when the first
|
||||
// server poll hasn't returned yet. Shows "Syncing…" with a small
|
||||
// CircularProgressIndicator instead of flashing 00:00:00.
|
||||
//
|
||||
// 3. COMBINED DISPLAY — clock + speed stacked in a Column inside a
|
||||
// fixed 200×200 SizedBox. The modern UI split these into separate
|
||||
// boxes for the stacked layout, but the stacking approach here is
|
||||
// a good reference for compact combined displays.
|
||||
//
|
||||
// Kept in the repo for reference. Safe to delete if you're pruning.
|
||||
// =============================================================================
|
||||
|
||||
// import 'package:flutter/material.dart';
|
||||
// import 'package:provider/provider.dart';
|
||||
// import 'package:revoltvpn/logic/app_colors.dart';
|
||||
// import 'package:revoltvpn/logic/session_timer.dart';
|
||||
|
||||
// class ClockDisplay extends StatelessWidget {
|
||||
// const ClockDisplay({super.key});
|
||||
|
||||
// @override
|
||||
// Widget build(BuildContext context) {
|
||||
// return Consumer<SessionTimer>(
|
||||
// builder: (context, timer, _) {
|
||||
// final bool showSyncing = !timer.hasSyncedOnce;
|
||||
|
||||
// return SizedBox(
|
||||
// width: 200,
|
||||
// height: 200,
|
||||
// child: Stack(
|
||||
// alignment: Alignment.center,
|
||||
// children: [
|
||||
// Column(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// if (showSyncing) ...[
|
||||
// const SizedBox(
|
||||
// width: 32,
|
||||
// height: 32,
|
||||
// child: CircularProgressIndicator(
|
||||
// strokeWidth: 2,
|
||||
// color: AppColors.accent50,
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 10),
|
||||
// const Text(
|
||||
// 'Syncing…',
|
||||
// style: TextStyle(
|
||||
// fontSize: 16,
|
||||
// fontWeight: FontWeight.w600,
|
||||
// color: AppColors.accent60,
|
||||
// letterSpacing: 1.5,
|
||||
// ),
|
||||
// ),
|
||||
// ] else ...[
|
||||
// Text(
|
||||
// timer.formatted,
|
||||
// style: const TextStyle(
|
||||
// fontSize: 40,
|
||||
// fontWeight: FontWeight.w800,
|
||||
// color: AppColors.textWhite,
|
||||
// letterSpacing: 2,
|
||||
// shadows: [
|
||||
// Shadow(
|
||||
// color: AppColors.accent50,
|
||||
// blurRadius: 16,
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
// const SizedBox(height: 6),
|
||||
// Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// const Icon(Icons.speed, color: AppColors.textDim, size: 14),
|
||||
// const SizedBox(width: 4),
|
||||
// Text(
|
||||
// timer.currentSpeedKBps > 0.5
|
||||
// ? '${timer.currentSpeedKBps.toStringAsFixed(1)} KB/s'
|
||||
// : 'Idle',
|
||||
// style: const TextStyle(
|
||||
// fontSize: 12,
|
||||
// color: AppColors.textDim,
|
||||
// fontWeight: FontWeight.w500,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ],
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
@@ -6,6 +6,7 @@ import 'package:revoltvpn/components/sidebar_contents/info_button.dart';
|
||||
import 'package:revoltvpn/components/sidebar_contents/discord_link_button.dart';
|
||||
import 'package:revoltvpn/components/sidebar_contents/website_button.dart';
|
||||
import 'package:revoltvpn/logic/updater.dart';
|
||||
import 'package:revoltvpn/main.dart';
|
||||
|
||||
class SidebarDrawer extends StatelessWidget {
|
||||
const SidebarDrawer({super.key});
|
||||
@@ -108,7 +109,7 @@ class SidebarDrawer extends StatelessWidget {
|
||||
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Text('ReVoltVPN · v2.0.7', textAlign: TextAlign.center,
|
||||
child: Text('ReVoltVPN · v${ReVoltApp.appVersion}', textAlign: TextAlign.center,
|
||||
style: TextStyle(color: AppColors.slate, fontSize: 11, letterSpacing: 1),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -46,4 +46,11 @@ abstract final class AppConfig {
|
||||
|
||||
// ── AdMob ──────────────────────────────────────────────────────────────
|
||||
static const String adUnitId = 'ca-app-pub-0000000000000000/0000000000'; // REPLACE
|
||||
|
||||
// ── Debug ──────────────────────────────────────────────────────────────
|
||||
/// When true, the client skips the real AdMob flow and sends a fake SSV
|
||||
/// callback directly to the server (requires ADMOB_BYPASS=True server-side).
|
||||
/// Set to false in production — the Dart compiler tree-shakes the bypass
|
||||
/// code entirely when this is a compile-time constant false.
|
||||
static const bool enableAdBypass = false;
|
||||
}
|
||||
@@ -37,7 +37,7 @@ class HivemindService {
|
||||
final url = _url('/session/status?device_id=$deviceId');
|
||||
|
||||
// ── AD BYPASS (debug only) ────────────────────────────────────────
|
||||
if (kDebugMode && !skipAdBypass) {
|
||||
if (AppConfig.enableAdBypass && !skipAdBypass) {
|
||||
try {
|
||||
final customData = jsonEncode({'device_id': deviceId, 'nonce': nonce});
|
||||
final fakeUrl = _url(
|
||||
|
||||
@@ -20,6 +20,7 @@ class SessionTimer extends ChangeNotifier {
|
||||
int _consecutiveFailures = 0;
|
||||
bool _isDisconnecting = false;
|
||||
bool _userInitiatedStop = false;
|
||||
bool _syncInProgress = false;
|
||||
|
||||
|
||||
int? _currentPort;
|
||||
@@ -183,9 +184,10 @@ class SessionTimer extends ChangeNotifier {
|
||||
|
||||
|
||||
Future<void> _syncWithHivemind() async {
|
||||
// Never sync while the user is explicitly disconnecting.
|
||||
if (_isDisconnecting) return;
|
||||
|
||||
// Never sync while the user is explicitly disconnecting,
|
||||
// or while another sync is already in flight.
|
||||
if (_isDisconnecting || _syncInProgress) return;
|
||||
_syncInProgress = true;
|
||||
try {
|
||||
final deviceId = await CryptoService.getDeviceId();
|
||||
final url = Uri.parse(
|
||||
@@ -248,6 +250,8 @@ class SessionTimer extends ChangeNotifier {
|
||||
} catch (e) {
|
||||
debugPrint('Hivemind sync error: $e');
|
||||
_markSyncFailure();
|
||||
} finally {
|
||||
_syncInProgress = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -268,6 +272,7 @@ class SessionTimer extends ChangeNotifier {
|
||||
_currentSpeedKBps = 0.0;
|
||||
_hasSyncedOnce = false;
|
||||
_remainingSeconds = 0;
|
||||
VpnNotificationManager.cancel();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,8 @@ class VpnConnection extends ChangeNotifier {
|
||||
|
||||
// Periodic server health check
|
||||
_checkHealth();
|
||||
_healthTimer = Timer.periodic(const Duration(seconds: 30), (_) => _checkHealth());
|
||||
_healthTimer =
|
||||
Timer.periodic(const Duration(seconds: 30), (_) => _checkHealth());
|
||||
|
||||
// Check if VPN was already running (app killed and reopened)
|
||||
try {
|
||||
@@ -102,7 +103,8 @@ class VpnConnection extends ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> connect({bool skipAdBypass = false, bool quickReconnect = false}) async {
|
||||
Future<bool> connect(
|
||||
{bool skipAdBypass = false, bool quickReconnect = false}) async {
|
||||
if (_status == VpnStatus.connected || _status == VpnStatus.connecting) {
|
||||
return false;
|
||||
}
|
||||
@@ -130,7 +132,8 @@ class VpnConnection extends ChangeNotifier {
|
||||
quickReconnect: quickReconnect,
|
||||
onAttempt: (attempt, total) {
|
||||
if (!quickReconnect) {
|
||||
_setStatus(VpnStatus.connecting, 'Contacting server ($attempt/$total)…');
|
||||
_setStatus(
|
||||
VpnStatus.connecting, 'Contacting server ($attempt/$total)…');
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -140,11 +143,15 @@ class VpnConnection extends ChangeNotifier {
|
||||
if (raw.contains('Cancelled')) {
|
||||
// User tapped disconnect — silently abort
|
||||
return false;
|
||||
} else if (raw.contains('timed out') || raw.contains('Session not activated')) {
|
||||
_errorMessage = 'The server did not respond in time.\nCheck your connection and try again.';
|
||||
} else if (raw.contains('timed out') ||
|
||||
raw.contains('Session not activated')) {
|
||||
_errorMessage =
|
||||
'The server did not respond in time.\nCheck your connection and try again.';
|
||||
_setStatus(VpnStatus.error, 'Server unreachable');
|
||||
} else if (raw.contains('SocketException') || raw.contains('Failed host lookup')) {
|
||||
_errorMessage = 'Cannot reach the server.\nMake sure you have internet access.';
|
||||
} else if (raw.contains('SocketException') ||
|
||||
raw.contains('Failed host lookup')) {
|
||||
_errorMessage =
|
||||
'Cannot reach the server.\nMake sure you have internet access.';
|
||||
_setStatus(VpnStatus.error, 'No internet');
|
||||
} else {
|
||||
_errorMessage = raw;
|
||||
@@ -186,7 +193,8 @@ class VpnConnection extends ChangeNotifier {
|
||||
}
|
||||
|
||||
if (!sessionOk) {
|
||||
debugPrint('[VPN] Tunnel started but no server session — tearing down.');
|
||||
debugPrint(
|
||||
'[VPN] Tunnel started but no server session — tearing down.');
|
||||
try {
|
||||
await _vless.stopVless();
|
||||
} catch (_) {}
|
||||
@@ -209,7 +217,8 @@ class VpnConnection extends ChangeNotifier {
|
||||
Future<void> disconnect({bool skipCleanup = false}) async {
|
||||
_cancelled = true;
|
||||
HivemindService.cancel(); // abort any in-progress polling
|
||||
if (_status == VpnStatus.disconnected || _status == VpnStatus.disconnecting) {
|
||||
if (_status == VpnStatus.disconnected ||
|
||||
_status == VpnStatus.disconnecting) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -223,9 +232,9 @@ class VpnConnection extends ChangeNotifier {
|
||||
|
||||
try {
|
||||
await _vless.stopVless().timeout(
|
||||
const Duration(seconds: 5),
|
||||
onTimeout: () => debugPrint('[VPN] stopVless() timed out.'),
|
||||
);
|
||||
const Duration(seconds: 5),
|
||||
onTimeout: () => debugPrint('[VPN] stopVless() timed out.'),
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('[VPN] VLESS stop error: $e');
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:ui';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:google_mobile_ads/google_mobile_ads.dart';
|
||||
import 'package:package_info_plus/package_info_plus.dart';
|
||||
|
||||
import 'package:revoltvpn/logic/vpn_connection.dart';
|
||||
import 'package:revoltvpn/logic/session_timer.dart';
|
||||
@@ -35,12 +36,19 @@ void main() async {
|
||||
await ConsentManager.requestConsentIfNeeded();
|
||||
await MobileAds.instance.initialize();
|
||||
|
||||
final packageInfo = await PackageInfo.fromPlatform();
|
||||
ReVoltApp.appVersion = packageInfo.version;
|
||||
|
||||
runApp(const ReVoltApp());
|
||||
}
|
||||
|
||||
class ReVoltApp extends StatelessWidget {
|
||||
const ReVoltApp({super.key});
|
||||
|
||||
/// Set at startup from PackageInfo — used by sidebar and anywhere
|
||||
/// the app version needs to be displayed.
|
||||
static String appVersion = '';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MultiProvider(
|
||||
|
||||
@@ -29,61 +29,70 @@ class MainScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: Stack(
|
||||
children: [
|
||||
// ── Lightning — behind rain so drops stay visible during flash ──
|
||||
const Positioned.fill(child: LightningEffect()),
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
// Proportional positioning — fractions of available height.
|
||||
// On the reference device (~700 dp) this produces the exact
|
||||
// original pixel positions (100, 175, 250, 520) and scales
|
||||
// proportionally on taller/shorter screens.
|
||||
final h = constraints.maxHeight;
|
||||
return Stack(
|
||||
children: [
|
||||
// ── Lightning — behind rain so drops stay visible during flash ──
|
||||
const Positioned.fill(child: LightningEffect()),
|
||||
|
||||
// ── Rain effect — behind all UI, baked into the background ──
|
||||
const Positioned.fill(child: RainEffect()),
|
||||
// ── Rain effect — behind all UI, baked into the background ──
|
||||
const Positioned.fill(child: RainEffect()),
|
||||
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 4,
|
||||
child: Builder(
|
||||
builder: (ctx) => IconButton(
|
||||
icon: const Icon(Icons.menu, color: AppColors.textWhite, size: 28),
|
||||
onPressed: () => Scaffold.of(ctx).openEndDrawer(),
|
||||
tooltip: 'Menu', splashRadius: 24,
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 4,
|
||||
child: Builder(
|
||||
builder: (ctx) => IconButton(
|
||||
icon: const Icon(Icons.menu, color: AppColors.textWhite, size: 28),
|
||||
onPressed: () => Scaffold.of(ctx).openEndDrawer(),
|
||||
tooltip: 'Menu', splashRadius: 24,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
top: 100, // <-- CHANGE ME: timer distance from top
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: const Center(child: TimerBox()),
|
||||
),
|
||||
Positioned(
|
||||
top: h * 0.143,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: const Center(child: TimerBox()),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
top: 175, // <-- CHANGE ME: support button from top
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: const Center(child: SupportButton()),
|
||||
),
|
||||
Positioned(
|
||||
top: h * 0.250,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: const Center(child: SupportButton()),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
top: 250, // <-- CHANGE ME: connect button from top
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: const Center(child: ConnectButton()),
|
||||
),
|
||||
Positioned(
|
||||
top: h * 0.357,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: const Center(child: ConnectButton()),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
top: 520, // <-- CHANGE ME: speed box from top
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: const Center(child: SpeedBox()),
|
||||
),
|
||||
Positioned(
|
||||
top: h * 0.743,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: const Center(child: SpeedBox()),
|
||||
),
|
||||
|
||||
Positioned(
|
||||
bottom: 16, // <-- CHANGE ME: status bar from bottom
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: const StatusBar(),
|
||||
),
|
||||
],
|
||||
const Positioned(
|
||||
bottom: 16,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: StatusBar(),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user