From 9e8432293ecb10c686d41f98186d44d883818376 Mon Sep 17 00:00:00 2001 From: ImBenji Date: Fri, 29 Aug 2025 00:58:12 +0100 Subject: [PATCH] Add peer connectivity testing to protocol blocking service --- lib/services/protocol_blocking_service.dart | 47 +++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/services/protocol_blocking_service.dart b/lib/services/protocol_blocking_service.dart index 90ba771..653f61d 100644 --- a/lib/services/protocol_blocking_service.dart +++ b/lib/services/protocol_blocking_service.dart @@ -78,6 +78,10 @@ class ProtocolBlockingService { if (_scanCount % 100 == 0) { print('๐Ÿ” Monitoring ${_activePeerIPs.length} active peers: $_activePeerIPs'); + // Test if we can see ANY traffic from peers + if (_scanCount == 100) { + await _testPeerConnectivity(); + } } } catch (e) { print('โŒ Error monitoring peer traffic: $e'); @@ -170,6 +174,49 @@ class ProtocolBlockingService { } } + static Future _testPeerConnectivity() async { + print('๐Ÿงช Testing peer connectivity on wg0 interface...'); + for (final peerIP in _activePeerIPs) { + try { + // Check if wg0 interface exists and peer can be seen + final wgResult = await Process.run('ip', ['addr', 'show', 'wg0']); + if (wgResult.exitCode == 0) { + print('โœ… wg0 interface exists'); + } else { + print('โŒ wg0 interface not found'); + return; + } + + // Test very basic traffic capture from peer + final process = await Process.start('timeout', [ + '3', + 'tcpdump', + '-i', 'wg0', + '-c', '1', + 'host $peerIP', + ]); + + final output = []; + await for (final data in process.stdout) { + output.add(String.fromCharCodes(data)); + } + + final exitCode = await process.exitCode; + process.kill(); + + if (exitCode == 0 && output.isNotEmpty) { + print('โœ… Can see traffic from peer $peerIP on wg0'); + print(' Sample: ${output.join().trim()}'); + } else { + print('โŒ No traffic detected from peer $peerIP on wg0 in 3 seconds'); + print(' This suggests the peer is inactive or traffic routing issue'); + } + } catch (e) { + print('โŒ Error testing peer $peerIP connectivity: $e'); + } + } + } + static List _parseConnections(String output, String protocol) { final connections = []; final lines = output.split('\n');