Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[tool.poetry]
name = "rnsh"
version = "0.1.4"
version = "0.1.5"
description = "Shell over Reticulum"
authors = ["acehoss <acehoss@acehoss.net>"]
license = "MIT"
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.7"
rns = ">=0.7.4"
rns = ">=0.9.0"

[tool.poetry.scripts]
rnsh = 'rnsh.rnsh:rnsh_cli'
Expand Down
6 changes: 4 additions & 2 deletions rnsh/initiator.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,21 +448,23 @@ def compress_adaptive(buf: bytes):
chunk_segment = None

chunk_segment = None
max_data_len = channel.mdu - protocol.StreamDataMessage.OVERHEAD
while chunk_len > 32 and comp_try < comp_tries:
chunk_segment_length = int(chunk_len/comp_try)
compressed_chunk = bz2.compress(buf[:chunk_segment_length])
compressed_length = len(compressed_chunk)
if compressed_length < protocol.StreamDataMessage.MAX_DATA_LEN and compressed_length < chunk_segment_length:
if compressed_length < max_data_len and compressed_length < chunk_segment_length:
comp_success = True
break
else:
comp_try += 1

if comp_success:
diff = max_data_len - len(compressed_chunk)
chunk = compressed_chunk
processed_length = chunk_segment_length
else:
chunk = bytes(buf[:protocol.StreamDataMessage.MAX_DATA_LEN])
chunk = bytes(buf[:max_data_len])
processed_length = len(chunk)

return comp_success, processed_length, chunk
Expand Down
6 changes: 4 additions & 2 deletions rnsh/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,21 +218,23 @@ def compress_adaptive(buf: bytes):
chunk_segment = None

chunk_segment = None
max_data_len = self.channel.mdu - protocol.StreamDataMessage.OVERHEAD
while chunk_len > 32 and comp_try < comp_tries:
chunk_segment_length = int(chunk_len/comp_try)
compressed_chunk = bz2.compress(buf[:chunk_segment_length])
compressed_length = len(compressed_chunk)
if compressed_length < protocol.StreamDataMessage.MAX_DATA_LEN and compressed_length < chunk_segment_length:
if compressed_length < max_data_len and compressed_length < chunk_segment_length:
comp_success = True
break
else:
comp_try += 1

if comp_success:
diff = max_data_len - len(compressed_chunk)
chunk = compressed_chunk
processed_length = chunk_segment_length
else:
chunk = bytes(buf[:protocol.StreamDataMessage.MAX_DATA_LEN])
chunk = bytes(buf[:max_data_len])
processed_length = len(chunk)

return comp_success, processed_length, chunk
Expand Down
Loading