Skip to content

Commit 8e42e10

Browse files
committed
BUG: Fix error in connection to SSH Proxy
The SSH connector erroneously started a connection to the final destination host, instead of the intended proxy (or jump) host. Fix this error to prevent an infinite recursion.
1 parent 1d96189 commit 8e42e10

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/Renci.SshNet/Connection/SshConnector.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ public SshConnector(IServiceFactory serviceFactory, ISocketFactory socketFactory
2424

2525
public override Socket Connect(IConnectionInfo connectionInfo)
2626
{
27-
if (connectionInfo == null)
28-
throw new ArgumentNullException("connectionInfo");
29-
if (connectionInfo.GetType() != typeof(ConnectionInfo))
27+
var proxyConnection = connectionInfo.ProxyConnection;
28+
if (proxyConnection == null)
29+
throw new ArgumentNullException("connectionInfo.ProxyConnection");
30+
if (proxyConnection.GetType() != typeof(ConnectionInfo))
3031
throw new ArgumentException("Expecting connectionInfo to be of type ConnectionInfo");
3132

32-
_jumpSession = new Session((ConnectionInfo)connectionInfo, ServiceFactory, SocketFactory);
33+
_jumpSession = new Session((ConnectionInfo)proxyConnection, ServiceFactory, SocketFactory);
3334
_jumpSession.Connect();
3435
_jumpChannel = new JumpChannel(_jumpSession, connectionInfo.Host, (uint)connectionInfo.Port);
3536
return _jumpChannel.Connect();

0 commit comments

Comments
 (0)