35 lines
1010 B
Dart
35 lines
1010 B
Dart
import 'package:supabase/supabase.dart';
|
|
import 'package:waylume_server/config/supabase_config.dart';
|
|
|
|
class VpnSessionService {
|
|
|
|
/// Detects existing VPN sessions for this server and prints their IDs
|
|
static Future<void> detectSessions() async {
|
|
try {
|
|
final serverId = fromEnivronment('SERVER_ID');
|
|
|
|
if (serverId == null) {
|
|
print('ERROR: SERVER_ID environment variable not set');
|
|
return;
|
|
}
|
|
|
|
// Get all sessions for this server
|
|
final sessions = await SUPABASE_CLIENT
|
|
.from('vpn_sessions')
|
|
.select('id')
|
|
.eq('server_id', serverId);
|
|
|
|
if (sessions.isEmpty) {
|
|
print('No VPN sessions found for server: $serverId');
|
|
} else {
|
|
print('Found ${sessions.length} VPN sessions for server: $serverId');
|
|
for (final session in sessions) {
|
|
print('Session ID: ${session['id']}');
|
|
}
|
|
}
|
|
|
|
} catch (e) {
|
|
print('Error detecting sessions: $e');
|
|
}
|
|
}
|
|
} |