diff --git a/lib/services/protocol_blocking_service.dart b/lib/services/protocol_blocking_service.dart index 643bc6e..2dc9596 100644 --- a/lib/services/protocol_blocking_service.dart +++ b/lib/services/protocol_blocking_service.dart @@ -34,27 +34,48 @@ class ProtocolBlockingService { } static void _startConnectionMonitoring() { + print('📡 Starting connection monitoring timer (100ms intervals)...'); _monitorTimer = Timer.periodic(Duration(milliseconds: 100), (_) async { await _scanForNewConnections(); }); } static Future _scanForNewConnections() async { + static int scanCount = 0; + scanCount++; + try { // Monitor both TCP and UDP connections final tcpResult = await Process.run('ss', ['-tnp', 'state', 'syn-sent,established']); final udpResult = await Process.run('ss', ['-unp']); + if (scanCount % 100 == 0) { // Log every 10 seconds + print('🔍 Scan #$scanCount - TCP exit code: ${tcpResult.exitCode}, UDP exit code: ${udpResult.exitCode}'); + } + + if (tcpResult.exitCode != 0) { + print('❌ TCP ss command failed: ${tcpResult.stderr}'); + return; + } + if (udpResult.exitCode != 0) { + print('❌ UDP ss command failed: ${udpResult.stderr}'); + return; + } + final tcpConnections = _parseConnections(tcpResult.stdout.toString(), 'tcp'); final udpConnections = _parseConnections(udpResult.stdout.toString(), 'udp'); + if (scanCount % 100 == 0) { + print('🔍 Found ${tcpConnections.length} TCP + ${udpConnections.length} UDP connections'); + } + for (final conn in [...tcpConnections, ...udpConnections]) { if (_isNewConnection(conn)) { await _handleNewConnection(conn); } } } catch (e) { - print('Error scanning for connections: $e'); + print('❌ Error scanning for connections: $e'); } }