Skip to content
Snippets Groups Projects
Commit fbd252532ab7 authored by Noah Pederson's avatar Noah Pederson
Browse files

Allow Transport factory to SSHClient.connect

Adds a transport_factory argument to `SSHClient.connect` that allows you
to dynamically generate a Transport instance without, and therefore
modify inner connection parameters before a connection gets established.

This should address some of the issues in #2054 with minial changes to
the API and no changes to Transport while allowing for arbitrary control
over Transports API.
parent 93049b53913d
Branches
No related tags found
No related merge requests found
......@@ -237,6 +237,7 @@
gss_trust_dns=True,
passphrase=None,
disabled_algorithms=None,
transport_factory=Transport,
):
"""
Connect to an SSH server and authenticate to it. The server's host key
......@@ -314,6 +315,10 @@
:param dict disabled_algorithms:
an optional dict passed directly to `.Transport` and its keyword
argument of the same name.
:param transport_factory: an optional callable that takes in a new `socket`
`gss_kex`, `gss_deleg_creds`, `disabled_algorithms` and generates a
`.Transport` instance to be used by this client. Defaults to
`.Transport.__init__`.
:raises:
`.BadHostKeyException` -- if the server's host key could not be
......@@ -371,7 +376,7 @@
if len(errors) == len(to_try):
raise NoValidConnectionsError(errors)
t = self._transport = Transport(
t = self._transport = transport_factory(
sock,
gss_kex=gss_kex,
gss_deleg_creds=gss_deleg_creds,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment