diff --git a/docs/api.rst b/docs/api.rst index d1d8a705..1b6b0b58 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -562,7 +562,7 @@ Router Class a password is requested, :py:class:`mitogen.sudo.PasswordError` is raised. - .. method:: ssh (hostname, username=None, ssh_path=None, port=None, check_host_keys=True, password=None, identity_file=None, \**kwargs) + .. method:: ssh (hostname, username=None, ssh_path=None, port=None, check_host_keys=True, password=None, identity_file=None, compression_level=6, \**kwargs) Arrange for a context to be constructed over a ``ssh`` invocation. The ``ssh`` process is started in a newly allocated pseudo-terminal, and @@ -594,6 +594,10 @@ Router Class the SSH client to perform authenticaion; agent authentication is automatically disabled, as is reading the default private key from ``~/.ssh/id_rsa``, or ``~/.ssh/id_dsa``. + :param int compression_level: + Integer 0-9 representing the zlib compression level to use on the + connection, with 0 indicating compression is disabled. Defaults to + 6. Context Class diff --git a/mitogen/ssh.py b/mitogen/ssh.py index adab955d..a1bc8f18 100644 --- a/mitogen/ssh.py +++ b/mitogen/ssh.py @@ -59,7 +59,7 @@ class Stream(mitogen.parent.Stream): def construct(self, hostname, username=None, ssh_path=None, port=None, check_host_keys=True, password=None, identity_file=None, - **kwargs): + compression_level=6, **kwargs): super(Stream, self).construct(**kwargs) self.hostname = hostname self.username = username @@ -67,6 +67,7 @@ class Stream(mitogen.parent.Stream): self.check_host_keys = check_host_keys self.password = password self.identity_file = identity_file + self.compression_level = compression_level if ssh_path: self.ssh_path = ssh_path @@ -82,6 +83,11 @@ class Stream(mitogen.parent.Stream): bits += ['-o', 'IdentitiesOnly yes'] if self.identity_file: bits += ['-i', self.identity_file] + if self.compression_level: + bits += [ + '-o', 'Compression yes', + '-o', 'CompressionLevel %d' % (self.compression_level,) + ] if not self.check_host_keys: bits += [ '-o', 'StrictHostKeyChecking no',