Skip to content

Commit

Permalink
BUG: apply checks to ProxyConnection Info
Browse files Browse the repository at this point in the history
connectionInfo is allowed to be of type other than ProxyConnectionInfo.
  • Loading branch information
JoostJM committed Apr 28, 2022
1 parent d972a5e commit fd7a97d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Renci.SshNet/Connection/ProxyConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public ProxyConnector(IServiceFactory serviceFactory, ISocketFactory socketFacto
{
}

protected internal IConnector GetConnector(IConnectionInfo connectionInfo)
protected internal IConnector GetProxyConnector(IConnectionInfo proxyConnectionInfo)
{
if (connectionInfo == null)
throw new ArgumentNullException("connectionInfo");
if (connectionInfo.GetType() != typeof(IProxyConnectionInfo))
throw new ArgumentException("Expecting connectionInfo to be of type IProxyConnectionInfo");
return ServiceFactory.CreateConnector(connectionInfo.ProxyConnection, SocketFactory);
if (proxyConnectionInfo == null)
throw new ArgumentNullException("connectionInfo.ProxyConnection");
if (proxyConnectionInfo.GetType() != typeof(IProxyConnectionInfo))
throw new ArgumentException("Expecting ProxyConnection to be of type IProxyConnectionInfo");
return ServiceFactory.CreateConnector(proxyConnectionInfo, SocketFactory);
}

protected abstract void HandleProxyConnect(IConnectionInfo connectionInfo, Socket socket);
Expand All @@ -44,7 +44,7 @@ protected virtual Task HandleProxyConnectAsync(IConnectionInfo connectionInfo, S

public override Socket Connect(IConnectionInfo connectionInfo)
{
ProxyConnection = GetConnector(connectionInfo);
ProxyConnection = GetProxyConnector(connectionInfo.ProxyConnection);
var socket = ProxyConnection.Connect(connectionInfo.ProxyConnection);

try
Expand All @@ -64,7 +64,7 @@ public override Socket Connect(IConnectionInfo connectionInfo)
#if FEATURE_TAP
public override async Task<Socket> ConnectAsync(IConnectionInfo connectionInfo, CancellationToken cancellationToken)
{
ProxyConnection = GetConnector(connectionInfo);
ProxyConnection = GetProxyConnector(connectionInfo.ProxyConnection);
var socket = await ProxyConnection.ConnectAsync(connectionInfo.ProxyConnection, cancellationToken).ConfigureAwait(false);

try
Expand Down

0 comments on commit fd7a97d

Please sign in to comment.