mirror of
https://github.com/markqvist/rnsh.git
synced 2025-02-25 01:20:00 -05:00
Added support for dynamic link MTU discovery
This commit is contained in:
parent
c28adee5ac
commit
6567c3a09d
@ -448,21 +448,23 @@ async def initiate(configdir: str, identitypath: str, verbosity: int, quietness:
|
|||||||
chunk_segment = None
|
chunk_segment = None
|
||||||
|
|
||||||
chunk_segment = None
|
chunk_segment = None
|
||||||
|
max_data_len = channel.mdu - protocol.StreamDataMessage.OVERHEAD
|
||||||
while chunk_len > 32 and comp_try < comp_tries:
|
while chunk_len > 32 and comp_try < comp_tries:
|
||||||
chunk_segment_length = int(chunk_len/comp_try)
|
chunk_segment_length = int(chunk_len/comp_try)
|
||||||
compressed_chunk = bz2.compress(buf[:chunk_segment_length])
|
compressed_chunk = bz2.compress(buf[:chunk_segment_length])
|
||||||
compressed_length = len(compressed_chunk)
|
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
|
comp_success = True
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
comp_try += 1
|
comp_try += 1
|
||||||
|
|
||||||
if comp_success:
|
if comp_success:
|
||||||
|
diff = max_data_len - len(compressed_chunk)
|
||||||
chunk = compressed_chunk
|
chunk = compressed_chunk
|
||||||
processed_length = chunk_segment_length
|
processed_length = chunk_segment_length
|
||||||
else:
|
else:
|
||||||
chunk = bytes(buf[:protocol.StreamDataMessage.MAX_DATA_LEN])
|
chunk = bytes(buf[:max_data_len])
|
||||||
processed_length = len(chunk)
|
processed_length = len(chunk)
|
||||||
|
|
||||||
return comp_success, processed_length, chunk
|
return comp_success, processed_length, chunk
|
||||||
|
@ -218,21 +218,23 @@ class ListenerSession:
|
|||||||
chunk_segment = None
|
chunk_segment = None
|
||||||
|
|
||||||
chunk_segment = None
|
chunk_segment = None
|
||||||
|
max_data_len = self.channel.mdu - protocol.StreamDataMessage.OVERHEAD
|
||||||
while chunk_len > 32 and comp_try < comp_tries:
|
while chunk_len > 32 and comp_try < comp_tries:
|
||||||
chunk_segment_length = int(chunk_len/comp_try)
|
chunk_segment_length = int(chunk_len/comp_try)
|
||||||
compressed_chunk = bz2.compress(buf[:chunk_segment_length])
|
compressed_chunk = bz2.compress(buf[:chunk_segment_length])
|
||||||
compressed_length = len(compressed_chunk)
|
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
|
comp_success = True
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
comp_try += 1
|
comp_try += 1
|
||||||
|
|
||||||
if comp_success:
|
if comp_success:
|
||||||
|
diff = max_data_len - len(compressed_chunk)
|
||||||
chunk = compressed_chunk
|
chunk = compressed_chunk
|
||||||
processed_length = chunk_segment_length
|
processed_length = chunk_segment_length
|
||||||
else:
|
else:
|
||||||
chunk = bytes(buf[:protocol.StreamDataMessage.MAX_DATA_LEN])
|
chunk = bytes(buf[:max_data_len])
|
||||||
processed_length = len(chunk)
|
processed_length = len(chunk)
|
||||||
|
|
||||||
return comp_success, processed_length, chunk
|
return comp_success, processed_length, chunk
|
||||||
|
Loading…
x
Reference in New Issue
Block a user