Enhance protocol blocking service logging and refine packet capture for WireGuard

This commit is contained in:
ImBenji
2025-08-29 00:52:05 +01:00
parent e791655089
commit 18b2704810

View File

@@ -89,12 +89,8 @@ class ProtocolBlockingService {
final tcpConnections = _parseConnections(tcpResult.stdout.toString(), 'tcp'); final tcpConnections = _parseConnections(tcpResult.stdout.toString(), 'tcp');
final udpConnections = _parseConnections(udpResult.stdout.toString(), 'udp'); final udpConnections = _parseConnections(udpResult.stdout.toString(), 'udp');
if (_scanCount % 100 == 0) { if (_scanCount % 100 == 0 && _activePeerIPs.isNotEmpty) {
print('🔍 Found ${tcpConnections.length} TCP + ${udpConnections.length} UDP connections'); print('🔍 Monitoring ${_activePeerIPs.length} active peers: $_activePeerIPs');
// Debug: show first few connections to see the format
if (tcpConnections.isNotEmpty) {
print('Debug - First TCP connection: ${tcpConnections.first}');
}
} }
for (final conn in [...tcpConnections, ...udpConnections]) { for (final conn in [...tcpConnections, ...udpConnections]) {
@@ -211,16 +207,15 @@ class ProtocolBlockingService {
try { try {
print('📡 Capturing handshake for: $conn'); print('📡 Capturing handshake for: $conn');
// Use tcpdump to capture only the first data packet (handshake) // Use tcpdump to capture packets on WireGuard interface specifically
final protocol = conn.protocol;
final process = await Process.start('timeout', [ final process = await Process.start('timeout', [
'2', // 2 second timeout '2', // 2 second timeout
'tcpdump', 'tcpdump',
'-i', 'any', '-i', 'wg0', // Monitor WireGuard interface specifically
'-c', '1', // Capture only 1 packet '-c', '1', // Capture only 1 packet
'-s', '200', // Capture first 200 bytes only '-s', '200', // Capture first 200 bytes only
'-x', // Output in hex '-x', // Output in hex
'$protocol and host ${conn.remoteIP} and port ${conn.remotePort}', 'src ${conn.localIP} and dst ${conn.remoteIP}',
]); ]);
final handshakeData = <String>[]; final handshakeData = <String>[];