Repository navigation
Exclude version bytes from hex dump for opcode 0x09 - #8
Merged
Merged
Conversation
For opcode 0x09 (auth with firmware version), the hex dump now only includes the first 86 bytes (opcode + address + signature), excluding the variable-length version bytes which may contain non-printable characters that garble the terminal. The authenticated device log already shows the sanitized firmware version as readable text (fw=...), so the version bytes don't need to be in the hex dump. Changes: - Modified TCPClient to detect opcode 0x09 and limit dump to 86 bytes - Added suffix annotation for excluded bytes: '...(+Nb version)' - Ensures hex dump only contains hex characters, never raw bytes - Added 3 test cases verifying hex dump safety for 0x09 packets - Wire format and legacy 0x07 auth unchanged Co-authored-by: James Brown <JamesSmartCell@users.noreply.github.com>
The terminal garbling was caused by Unicode ellipsis '...' (U+2026, UTF-8 bytes E2 80 A6) and em-dash '--' (U+2014) being misinterpreted by non-UTF-8 terminals (e.g. journalctl/ccze). Replaced all non-ASCII characters in log output: - '...' (U+2026) -> '...' (ASCII periods) - '--' (U+2014) -> '--' (ASCII hyphens) Files updated: - TCPClient.ts: hex dump truncation suffixes - ASyncTCPService.ts: connection rejection log messages - passkey-store.ts: error/warning messages Added test verifying all log output is ASCII-only (printable ASCII chars 32-126), ensuring compatibility with all terminal encodings. Co-authored-by: James Brown <JamesSmartCell@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the terminal garbling issue in the hex dump logging for opcode 0x09 TCP authentication packets by excluding variable-length firmware version bytes that may contain non-printable characters.
Problem
The
--> <hex>dump line in TCPClient was including the entire packet for opcode 0x09, including firmware version bytes which could contain control characters (e.g.,\x00,\x01) that garble the terminal output.Example of garbled output:
The authenticated device log already shows the sanitized firmware version as readable text (
Authenticated #X 0xabc123 fw=e2e-abc123), so the version bytes don't need to be in the hex dump.Solution
Modified TCPClient to detect opcode 0x09 and limit the hex dump to the first 86 bytes:
Total: 86 bytes of hex-safe data
The version bytes (which start at byte 87) are now excluded from the dump and indicated with a suffix annotation:
…(+Nb version)Changes
src/service/TCPClient.ts
…(+Nb version)to indicate excluded version bytessrc/tests/tcp-auth.test.ts
Added 3 new test cases in "Hex Dump Safety (opcode 0x09)" suite:
Test Results
All tests pass:
npm run typecheck:toolspasses with no errorsExample Output
Before:
After:
The firmware version is shown in readable, sanitized form in the authentication log line, while the hex dump remains clean and terminal-safe.