Refactor RepeaterHandler path management and enhance packet validation

- Removed redundant call to mark_seen() for duplicate packets.
- Added validation to ensure hop count does not exceed the maximum limit before appending to the packet path.
- Updated logic to check for path size constraints when appending hash bytes, improving packet processing efficiency.
This commit is contained in:
agessaman
2026-03-05 16:52:43 -08:00
parent c150b9a9bf
commit 0217a49ed2
16 changed files with 12 additions and 52 deletions
+5 -4
View File
@@ -1031,10 +1031,6 @@ GOOD_PACKETS = [
"Flood, path has 1 prior hop",
lambda: _make_flood_packet(payload=b"\xDE\xAD", path=b"\x42")),
("good_flood_path_near_max",
"Flood, path = MAX_PATH_SIZE - 1 (room for our hash)",
lambda: _make_flood_packet(payload=b"\xFF", path=bytes(range(MAX_PATH_SIZE - 1)))),
("good_flood_binary_payload",
"Flood, all-zero payload",
lambda: _make_flood_packet(payload=b"\x00" * 16)),
@@ -1112,6 +1108,11 @@ BAD_PACKETS = [
lambda: _make_flood_packet(payload=b"\x01", path=bytes(range(MAX_PATH_SIZE))),
"Path length"),
("bad_flood_path_near_max",
"Flood, path = MAX_PATH_SIZE - 1 (63 hops; path_len encodes 0-63, cannot append)",
lambda: _make_flood_packet(payload=b"\xFF", path=bytes(range(MAX_PATH_SIZE - 1))),
"cannot append"),
("bad_path_over_max",
"Path exceeds MAX_PATH_SIZE",
lambda: _make_flood_packet(payload=b"\x01", path=bytes(range(MAX_PATH_SIZE + 5))),