Two-box throttle system + support top-up
- Server: two Xray inbounds (vless-normal / vless-throttled), 4GB threshold, management loop moves users between boxes instead of hard-killing. /session/status returns dynamic vless_path + is_throttled. Support ad callback (ad_type: support) extends session +30min +2GB. No hard quota kill — only 60-min expiry removes sessions. - App: session_timer detects vless_path change in 5s poll, triggers silent reconnect (skipCleanup, skipAdBypass, quickReconnect). New support_button.dart for top-up rewarded ads. hivemind_service uses server vless_path instead of hardcoded constant. vpn_connection: skipAdBypass, quickReconnect, skipCleanup params. - Config: Xray two-inbound template, nginx /tunnel-throttled with limit_rate 187k (1.5 Mbps). Updated AGENTS.md + SERVER_SETUP.md.
This commit is contained in:
1 parent
6825a264a5
commit
efcfe6e706
6 files changed
+282
-63
No files matched your search
@@ -22,6 +22,10 @@ class SessionTimer extends ChangeNotifier {
|
||||
bool _isDisconnecting = false;
|
||||
bool _userInitiatedStop = false;
|
||||
|
||||
String? _currentPath;
|
||||
bool _isThrottled = false;
|
||||
bool _pathSwitchInProgress = false;
|
||||
|
||||
static const int _maxConsecutiveFailures = 3;
|
||||
|
||||
static const int _maxOfflineSeconds = 120;
|
||||
@@ -236,6 +240,29 @@ class SessionTimer extends ChangeNotifier {
|
||||
_lastUsedBytes = _usedBytes;
|
||||
|
||||
|
||||
// ── Detect path changes (throttle engage / disengage) ──────
|
||||
final serverPath = data['vless_path'] as String?;
|
||||
if (serverPath != null &&
|
||||
_currentPath != null &&
|
||||
serverPath != _currentPath &&
|
||||
!_pathSwitchInProgress) {
|
||||
debugPrint('[Timer] Path changed $_currentPath → $serverPath — reconnecting…');
|
||||
_currentPath = serverPath;
|
||||
_isThrottled = data['is_throttled'] ?? false;
|
||||
_pathSwitchInProgress = true;
|
||||
|
||||
_timer?.cancel();
|
||||
_isDisconnecting = true; // block _stopInternal during relocation
|
||||
await vpnConnection.disconnect(skipCleanup: true);
|
||||
await vpnConnection.connect(skipAdBypass: true, quickReconnect: true);
|
||||
|
||||
_resumeTicking();
|
||||
_pathSwitchInProgress = false;
|
||||
return;
|
||||
}
|
||||
_currentPath = serverPath;
|
||||
_isThrottled = data['is_throttled'] ?? false;
|
||||
|
||||
_consecutiveFailures = 0;
|
||||
_offlineSeconds = 0;
|
||||
_hasSyncedOnce = true;
|
||||
|
||||
Reference in new issue
Block a user