Skip to content

Commit

Permalink
BUG: Fix error in connection to SSH Proxy
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JoostJM committed May 27, 2022
1 parent 1d96189 commit 8e42e10
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Renci.SshNet/Connection/SshConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@ public SshConnector(IServiceFactory serviceFactory, ISocketFactory socketFactory

public override Socket Connect(IConnectionInfo connectionInfo)
{
if (connectionInfo == null)
throw new ArgumentNullException("connectionInfo");
if (connectionInfo.GetType() != typeof(ConnectionInfo))
var proxyConnection = connectionInfo.ProxyConnection;
if (proxyConnection == null)
throw new ArgumentNullException("connectionInfo.ProxyConnection");
if (proxyConnection.GetType() != typeof(ConnectionInfo))
throw new ArgumentException("Expecting connectionInfo to be of type ConnectionInfo");

_jumpSession = new Session((ConnectionInfo)connectionInfo, ServiceFactory, SocketFactory);
_jumpSession = new Session((ConnectionInfo)proxyConnection, ServiceFactory, SocketFactory);
_jumpSession.Connect();
_jumpChannel = new JumpChannel(_jumpSession, connectionInfo.Host, (uint)connectionInfo.Port);
return _jumpChannel.Connect();
Expand Down

0 comments on commit 8e42e10

Please sign in to comment.