Show ASCII translation for each hex line
This commit is contained in:
@@ -166,7 +166,23 @@ class ProtocolBlockingService {
|
||||
// If this is hex data and we're tracking a peer packet
|
||||
else if (packetLine.contains('0x') && _currentPeerIP != null) {
|
||||
_currentPacketHex.add(packetLine);
|
||||
print('📦 HEX LINE: $packetLine');
|
||||
|
||||
// Extract and show ASCII for this hex line
|
||||
final hexPattern = RegExp(r'0x[0-9a-f]+:\s*([0-9a-f\s]+)', caseSensitive: false);
|
||||
final match = hexPattern.firstMatch(packetLine);
|
||||
if (match != null) {
|
||||
final hexData = match.group(1)?.replaceAll(' ', '') ?? '';
|
||||
String ascii = '';
|
||||
for (int i = 0; i < hexData.length; i += 2) {
|
||||
if (i + 1 < hexData.length) {
|
||||
final byte = int.tryParse(hexData.substring(i, i + 2), radix: 16) ?? 0;
|
||||
ascii += (byte >= 32 && byte <= 126) ? String.fromCharCode(byte) : '.';
|
||||
}
|
||||
}
|
||||
print('📦 HEX LINE: $packetLine | ASCII: $ascii');
|
||||
} else {
|
||||
print('📦 HEX LINE: $packetLine');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user