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
24 changes: 14 additions & 10 deletions sftpretty/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,50 +440,54 @@ def _start_transport(self, host, port):
self._transport.set_keepalive(int(keepalive))
self._transport.set_log_channel(host)

# Set compression
compress = self._config.get('compression') or self._cnopts.compress
self._transport.use_compression(compress=bool(compress))
log.debug(f'Compress: [{compress}]')

# Set disabled algorithms
disabled_algorithms = self._cnopts.disabled_algorithms
self._transport.disabled_algorithms = disabled_algorithms
log.debug(f'Disabled Algorithms: [{disabled_algorithms}]')

# Security Options
security_options = self._transport.get_security_options()
Comment thread
byteskeptical marked this conversation as resolved.
# Set allowed ciphers
ciphers = self._config.get('ciphers') or self._cnopts.ciphers
_ciphers = self._transport.get_security_options().ciphers
_ciphers = security_options.ciphers
if not isinstance(ciphers, tuple):
ciphers = tuple(ciphers.split(','))
self._transport.get_security_options().ciphers = tuple(
security_options.ciphers = tuple(
cipher for cipher in ciphers if cipher in _ciphers)
log.debug(f'Ciphers: [{ciphers}]')
# Set compression algorithms
compression = self._cnopts.compression
self._transport.get_security_options().compression = compression
log.debug(f'Compression: [{compression}]')
if bool(compress) and compression != ('none',):
Comment thread
byteskeptical marked this conversation as resolved.
security_options.compression = compression
log.debug(f'Compression: [{security_options.compression}]')
# Set connection digests
digests = self._config.get('macs') or self._cnopts.digests
_digests = self._transport.get_security_options().digests
_digests = security_options.digests
if not isinstance(digests, tuple):
digests = tuple(digests.split(','))
self._transport.get_security_options().digests = tuple(
security_options.digests = tuple(
digest for digest in digests if digest in _digests)
log.debug(f'MACs: [{digests}]')
# Set connection kex
kexs = self._config.get('kexalgorithms') or self._cnopts.kex
_kex = self._transport.get_security_options().kex
_kex = security_options.kex
if not isinstance(kexs, tuple):
kexs = tuple(kexs.split(','))
self._transport.get_security_options().kex = tuple(
security_options.kex = tuple(
kex for kex in kexs if kex in _kex)
log.debug(f'KEX: [{kexs}]')
# Set allowed key types
key_types = self._config.get('pubkeyacceptedalgorithms') or\
self._cnopts.key_types
_key_types = self._transport.get_security_options().key_types
_key_types = security_options.key_types
if not isinstance(key_types, tuple):
key_types = tuple(key_types.split(','))
self._transport.get_security_options().key_types = tuple(
security_options.key_types = tuple(
key_type for key_type in key_types if key_type in _key_types)
log.debug(f'Public Key Types: [{key_types}]')

Expand Down
3 changes: 1 addition & 2 deletions tests/test_compression.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'''test sftpretty.compression param'''

from common import LOCAL, SKIP_IF_CI
from common import LOCAL
from sftpretty import CnOpts, Connection


Expand All @@ -10,7 +10,6 @@ def test_compression_default():
assert sftp.active_compression == ('none', 'none')


@SKIP_IF_CI
Comment thread
byteskeptical marked this conversation as resolved.
def test_compression_enabled():
'''test that compress=True results in compression enabled, assuming
that the server supports compression'''
Expand Down