From aa5b609d091062b6cd9a7957182ff2851f8efb3f Mon Sep 17 00:00:00 2001 From: ImBenji Date: Fri, 29 Aug 2025 01:48:45 +0100 Subject: [PATCH] Enhance traffic capture testing with longer timeouts and additional checks --- lib/services/protocol_blocking_service.dart | 42 +++++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/lib/services/protocol_blocking_service.dart b/lib/services/protocol_blocking_service.dart index 0e97cba..78c6eab 100644 --- a/lib/services/protocol_blocking_service.dart +++ b/lib/services/protocol_blocking_service.dart @@ -187,12 +187,15 @@ class ProtocolBlockingService { return; } - // Test very basic traffic capture from peer + print('🔍 Testing live traffic capture for peer $peerIP...'); + + // Test very basic traffic capture from peer - longer timeout final process = await Process.start('timeout', [ - '3', + '10', // Longer timeout to catch browsing traffic 'tcpdump', '-i', 'wg0', - '-c', '1', + '-c', '5', // Capture multiple packets + '-v', // Verbose output 'host $peerIP', ]); @@ -205,11 +208,36 @@ class ProtocolBlockingService { process.kill(); if (exitCode == 0 && output.isNotEmpty) { - print('✅ Can see traffic from peer $peerIP on wg0'); - print(' Sample: ${output.join().trim()}'); + print('✅ LIVE TRAFFIC DETECTED from peer $peerIP:'); + print('${output.join().trim()}'); + print('───────────────────────────────────────'); } else { - print('❌ No traffic detected from peer $peerIP on wg0 in 3 seconds'); - print(' This suggests the peer is inactive or traffic routing issue'); + print('❌ No traffic detected from peer $peerIP in 10 seconds'); + print(' Try browsing a website now...'); + + // Also test ANY traffic on wg0 + print('🔍 Testing if wg0 interface has ANY traffic...'); + final anyTrafficProcess = await Process.start('timeout', [ + '5', + 'tcpdump', + '-i', 'wg0', + '-c', '3', + ]); + + final anyOutput = []; + await for (final data in anyTrafficProcess.stdout) { + anyOutput.add(String.fromCharCodes(data)); + } + + final anyExitCode = await anyTrafficProcess.exitCode; + anyTrafficProcess.kill(); + + if (anyExitCode == 0 && anyOutput.isNotEmpty) { + print('✅ wg0 has traffic, but not from expected peer IP:'); + print('${anyOutput.join().trim()}'); + } else { + print('❌ No traffic at all on wg0 interface'); + } } } catch (e) { print('❌ Error testing peer $peerIP connectivity: $e');