Enhance Dockerfile to include tcpdump for network monitoring
This commit is contained in:
@@ -34,27 +34,48 @@ class ProtocolBlockingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void _startConnectionMonitoring() {
|
static void _startConnectionMonitoring() {
|
||||||
|
print('📡 Starting connection monitoring timer (100ms intervals)...');
|
||||||
_monitorTimer = Timer.periodic(Duration(milliseconds: 100), (_) async {
|
_monitorTimer = Timer.periodic(Duration(milliseconds: 100), (_) async {
|
||||||
await _scanForNewConnections();
|
await _scanForNewConnections();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<void> _scanForNewConnections() async {
|
static Future<void> _scanForNewConnections() async {
|
||||||
|
static int scanCount = 0;
|
||||||
|
scanCount++;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Monitor both TCP and UDP connections
|
// Monitor both TCP and UDP connections
|
||||||
final tcpResult = await Process.run('ss', ['-tnp', 'state', 'syn-sent,established']);
|
final tcpResult = await Process.run('ss', ['-tnp', 'state', 'syn-sent,established']);
|
||||||
final udpResult = await Process.run('ss', ['-unp']);
|
final udpResult = await Process.run('ss', ['-unp']);
|
||||||
|
|
||||||
|
if (scanCount % 100 == 0) { // Log every 10 seconds
|
||||||
|
print('🔍 Scan #$scanCount - TCP exit code: ${tcpResult.exitCode}, UDP exit code: ${udpResult.exitCode}');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tcpResult.exitCode != 0) {
|
||||||
|
print('❌ TCP ss command failed: ${tcpResult.stderr}');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (udpResult.exitCode != 0) {
|
||||||
|
print('❌ UDP ss command failed: ${udpResult.stderr}');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
print('🔍 Found ${tcpConnections.length} TCP + ${udpConnections.length} UDP connections');
|
||||||
|
}
|
||||||
|
|
||||||
for (final conn in [...tcpConnections, ...udpConnections]) {
|
for (final conn in [...tcpConnections, ...udpConnections]) {
|
||||||
if (_isNewConnection(conn)) {
|
if (_isNewConnection(conn)) {
|
||||||
await _handleNewConnection(conn);
|
await _handleNewConnection(conn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error scanning for connections: $e');
|
print('❌ Error scanning for connections: $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user