From fd7a97d720d36b1726768d1d9af525de828d82f2 Mon Sep 17 00:00:00 2001 From: joostjm Date: Thu, 28 Apr 2022 14:07:48 +0200 Subject: [PATCH] BUG: apply checks to ProxyConnection Info connectionInfo is allowed to be of type other than ProxyConnectionInfo. --- src/Renci.SshNet/Connection/ProxyConnector.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Renci.SshNet/Connection/ProxyConnector.cs b/src/Renci.SshNet/Connection/ProxyConnector.cs index a79826820..d4eef27a8 100644 --- a/src/Renci.SshNet/Connection/ProxyConnector.cs +++ b/src/Renci.SshNet/Connection/ProxyConnector.cs @@ -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); @@ -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 @@ -64,7 +64,7 @@ public override Socket Connect(IConnectionInfo connectionInfo) #if FEATURE_TAP public override async Task ConnectAsync(IConnectionInfo connectionInfo, CancellationToken cancellationToken) { - ProxyConnection = GetConnector(connectionInfo); + ProxyConnection = GetProxyConnector(connectionInfo.ProxyConnection); var socket = await ProxyConnection.ConnectAsync(connectionInfo.ProxyConnection, cancellationToken).ConfigureAwait(false); try