Add network debugging functionality and enhance packet capture monitoring
This commit is contained in:
@@ -73,7 +73,7 @@ class ProtocolBlockingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Monitor peer traffic directly using tcpdump on wg0 interface
|
// Monitor peer traffic directly using tcpdump on ALL interfaces
|
||||||
await _monitorPeerTraffic();
|
await _monitorPeerTraffic();
|
||||||
|
|
||||||
if (_scanCount % 100 == 0) {
|
if (_scanCount % 100 == 0) {
|
||||||
@@ -82,6 +82,9 @@ class ProtocolBlockingService {
|
|||||||
if (_scanCount == 100) {
|
if (_scanCount == 100) {
|
||||||
await _testPeerConnectivity();
|
await _testPeerConnectivity();
|
||||||
}
|
}
|
||||||
|
if (_scanCount == 200) {
|
||||||
|
await _debugNetworking();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('❌ Error monitoring peer traffic: $e');
|
print('❌ Error monitoring peer traffic: $e');
|
||||||
@@ -89,12 +92,12 @@ class ProtocolBlockingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> _monitorPeerTraffic() async {
|
static Future<void> _monitorPeerTraffic() async {
|
||||||
// Capture ANY packet on wg0 interface and print it
|
// Capture ANY packet on ALL interfaces and print it
|
||||||
try {
|
try {
|
||||||
final process = await Process.start('timeout', [
|
final process = await Process.start('timeout', [
|
||||||
'0.1', // Very short timeout
|
'0.1', // Very short timeout
|
||||||
'tcpdump',
|
'tcpdump',
|
||||||
'-i', 'wg0',
|
'-i', 'any', // Monitor ALL interfaces
|
||||||
'-c', '1',
|
'-c', '1',
|
||||||
'-v', // Verbose
|
'-v', // Verbose
|
||||||
]);
|
]);
|
||||||
@@ -109,7 +112,7 @@ class ProtocolBlockingService {
|
|||||||
|
|
||||||
if (exitCode == 0 && output.isNotEmpty) {
|
if (exitCode == 0 && output.isNotEmpty) {
|
||||||
final packetData = output.join().trim();
|
final packetData = output.join().trim();
|
||||||
print('📦 PACKET DETECTED: $packetData');
|
print('📦 PACKET DETECTED ON ANY INTERFACE: $packetData');
|
||||||
|
|
||||||
// Check if it's from our monitored peers
|
// Check if it's from our monitored peers
|
||||||
for (final peerIP in _activePeerIPs) {
|
for (final peerIP in _activePeerIPs) {
|
||||||
@@ -251,6 +254,60 @@ class ProtocolBlockingService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Future<void> _debugNetworking() async {
|
||||||
|
print('🔧 NETWORK DEBUGGING...');
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Check all network interfaces
|
||||||
|
print('📡 Available network interfaces:');
|
||||||
|
final ifaceResult = await Process.run('ip', ['link', 'show']);
|
||||||
|
if (ifaceResult.exitCode == 0) {
|
||||||
|
print(ifaceResult.stdout.toString().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check specifically for wg0
|
||||||
|
print('\n🔍 WireGuard wg0 interface details:');
|
||||||
|
final wg0Result = await Process.run('ip', ['addr', 'show', 'wg0']);
|
||||||
|
if (wg0Result.exitCode == 0) {
|
||||||
|
print(wg0Result.stdout.toString().trim());
|
||||||
|
} else {
|
||||||
|
print('❌ wg0 interface not found: ${wg0Result.stderr}');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check WireGuard status
|
||||||
|
print('\n📋 WireGuard peer status:');
|
||||||
|
final wgResult = await Process.run('wg', ['show']);
|
||||||
|
if (wgResult.exitCode == 0) {
|
||||||
|
print(wgResult.stdout.toString().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try tcpdump on different interfaces
|
||||||
|
print('\n🕵️ Testing packet capture capabilities:');
|
||||||
|
|
||||||
|
// Test Docker internal interface
|
||||||
|
final dockerTest = await Process.run('timeout', ['2', 'tcpdump', '-i', 'any', '-c', '1']);
|
||||||
|
if (dockerTest.exitCode == 0 && dockerTest.stdout.toString().isNotEmpty) {
|
||||||
|
print('✅ Can capture on "any" interface');
|
||||||
|
print(' Sample: ${dockerTest.stdout.toString().trim()}');
|
||||||
|
} else {
|
||||||
|
print('❌ Cannot capture on "any" interface');
|
||||||
|
print(' Error: ${dockerTest.stderr}');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test if we need different interface name
|
||||||
|
final ethTest = await Process.run('timeout', ['2', 'tcpdump', '-i', 'eth0', '-c', '1']);
|
||||||
|
if (ethTest.exitCode == 0 && ethTest.stdout.toString().isNotEmpty) {
|
||||||
|
print('✅ Traffic detected on eth0');
|
||||||
|
print(' Sample: ${ethTest.stdout.toString().trim()}');
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
print('❌ Network debugging error: $e');
|
||||||
|
}
|
||||||
|
|
||||||
|
print('🔧 Network debugging complete\n');
|
||||||
|
}
|
||||||
|
|
||||||
static List<Connection> _parseConnections(String output, String protocol) {
|
static List<Connection> _parseConnections(String output, String protocol) {
|
||||||
final connections = <Connection>[];
|
final connections = <Connection>[];
|
||||||
final lines = output.split('\n');
|
final lines = output.split('\n');
|
||||||
|
|||||||
Reference in New Issue
Block a user