mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-10-22 14:01:14 +00:00
feat(packet_capture): enhance MQTT packet publishing controls and path length decoding
- Added configuration options `mqtt_skip_unparseable_packets` and `advert_require_valid_signature` to control MQTT publishing behavior based on packet validity. - Updated `decode_path_len_byte` function to return `None` for reserved size codes, improving path length validation. - Implemented logic in `PacketCaptureService` to skip publishing unparseable packets and ADVERT packets with invalid signatures. - Introduced `verify_meshcore_advert_ed25519` function for signature verification of ADVERT packets, with corresponding unit tests to ensure functionality. - Enhanced documentation to reflect new configuration options and their effects on packet processing.
This commit is contained in:
1 parent
5a484d1db2
commit
263c73c2e2
7 files changed
+219
-41
No files matched your search
@@ -1350,7 +1350,13 @@ class MessageHandler:
|
||||
path_len_byte = byte_data[offset]
|
||||
offset += 1
|
||||
# Decode per firmware: low 6 bits = hop count, high 2 bits = size code (bytes_per_hop = code+1)
|
||||
path_byte_length, bytes_per_hop = decode_path_len_byte(path_len_byte)
|
||||
path_parts = decode_path_len_byte(path_len_byte)
|
||||
if path_parts is None:
|
||||
self.logger.debug(
|
||||
"decode_meshcore_packet: invalid path_len byte (firmware would reject)"
|
||||
)
|
||||
return None
|
||||
path_byte_length, bytes_per_hop = path_parts
|
||||
|
||||
# Check if we have enough data for the full path
|
||||
if len(byte_data) < offset + path_byte_length:
|
||||
@@ -1375,7 +1381,7 @@ class MessageHandler:
|
||||
# Extract payload type (bits 2-5)
|
||||
payload_type = PayloadType((header >> 2) & 0x0F)
|
||||
|
||||
# Chunk path by bytes_per_hop from packet (1, 2, or 3; legacy fallback uses 1)
|
||||
# Chunk path by bytes_per_hop from packet (1, 2, or 3)
|
||||
path_hex, path_values = self._path_bytes_to_nodes(path_bytes, prefix_hex_chars=bytes_per_hop * 2)
|
||||
|
||||
# Process path based on packet type
|
||||
|
||||
Reference in new issue
Block a user