-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change compression to be disabled by default
This commit changes compression to default to off when AsyncSSH is acting as a client, only enabling it if the server requires it. This matches the OpenSSH default and avoids a potential bottleneck where running with compression enabled can actually slow down performance signficantly on high-bandwidth connections. This also cleans up some unintended cosmetic differences between the documentation for client and server connection options.
- Loading branch information
Showing
4 changed files
with
41 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Copyright (c) 2013-2021 by Ron Frederick <[email protected]> and others. | ||
# Copyright (c) 2013-2024 by Ron Frederick <[email protected]> and others. | ||
# | ||
# This program and the accompanying materials are made available under | ||
# the terms of the Eclipse Public License v2.0 which accompanies this | ||
|
@@ -149,9 +149,9 @@ def get_decompressor(alg: bytes) -> Optional[Decompressor]: | |
|
||
return _cmp_decompressors[alg]() | ||
|
||
register_compression_alg(b'none', | ||
_none, _none, False, True) | ||
register_compression_alg(b'[email protected]', | ||
_ZLibCompress, _ZLibDecompress, True, True) | ||
register_compression_alg(b'zlib', | ||
_ZLibCompress, _ZLibDecompress, False, False) | ||
register_compression_alg(b'none', | ||
_none, _none, False, True) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1848,8 +1848,9 @@ async def test_dropbear_client(self): | |
"""Test reduced dropbear send packet size""" | ||
|
||
with patch('asyncssh.connection.SSHServerChannel', _ServerChannel): | ||
async with self.connect(client_version='dropbear', | ||
max_pktsize=32759) as conn: | ||
async with self.connect( | ||
client_version='dropbear', max_pktsize=32759, | ||
compression_algs=['[email protected]']) as conn: | ||
_, stdout, _ = await conn.open_session('send_pktsize') | ||
self.assertEqual((await stdout.read()), '32758') | ||
|
||
|
@@ -1875,7 +1876,8 @@ async def test_dropbear_server(self): | |
"""Test reduced dropbear send packet size""" | ||
|
||
with patch('asyncssh.connection.SSHClientChannel', _ClientChannel): | ||
async with self.connect() as conn: | ||
async with self.connect( | ||
compression_algs='[email protected]') as conn: | ||
stdin, _, _ = await conn.open_session() | ||
self.assertEqual(stdin.channel.get_send_pktsize(), 32758) | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1260,6 +1260,24 @@ def send_newkeys(self, k, h): | |
with self.assertRaises(asyncssh.ProtocolError): | ||
await self.connect() | ||
|
||
@asynctest | ||
async def test_client_decompression_failure(self): | ||
"""Test client decompression failure""" | ||
|
||
def send_packet(self, pkttype, *args, **kwargs): | ||
"""Send an SSH packet""" | ||
|
||
asyncssh.connection.SSHConnection.send_packet( | ||
self, pkttype, *args, **kwargs) | ||
|
||
if pkttype == MSG_USERAUTH_SUCCESS: | ||
self._compressor = None | ||
self.send_debug('Test') | ||
|
||
with patch('asyncssh.connection.SSHServerConnection.send_packet', | ||
send_packet): | ||
await self.connect(compression_algs=['[email protected]']) | ||
|
||
@asynctest | ||
async def test_packet_decode_error(self): | ||
"""Test SSH packet decode error""" | ||
|