Add peer connectivity testing to protocol blocking service
This commit is contained in:
@@ -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<void> _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 = <String>[];
|
||||
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<Connection> _parseConnections(String output, String protocol) {
|
||||
final connections = <Connection>[];
|
||||
final lines = output.split('\n');
|
||||
|
||||
Reference in New Issue
Block a user