Browse Source

Merge remote-tracking branch 'remotes/origin/develop'

drieseng 5 years ago
parent
commit
cca8255255

+ 18 - 0
src/Renci.SshNet.Silverlight/Renci.SshNet.Silverlight.csproj

@@ -1121,6 +1121,12 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup14Sha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroup14Sha1.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup14Sha256.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroup14Sha256.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup16Sha512.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroup16Sha512.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup1Sha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroup1Sha1.cs</Link>
     </Compile>
@@ -1136,6 +1142,15 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroupSha1.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha256.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha256.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha512.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha512.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupShaBase.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupShaBase.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeEC.cs">
       <Link>Security\KeyExchangeEC.cs</Link>
     </Compile>
@@ -1154,6 +1169,9 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeECDH521.cs">
       <Link>Security\KeyExchangeECDH521.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeHash.cs">
+      <Link>Security\KeyExchangeHash.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyHostAlgorithm.cs">
       <Link>Security\KeyHostAlgorithm.cs</Link>
     </Compile>

+ 19 - 1
src/Renci.SshNet.Silverlight5/Renci.SshNet.Silverlight5.csproj

@@ -1127,6 +1127,12 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup14Sha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroup14Sha1.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup14Sha256.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroup14Sha256.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup16Sha512.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroup16Sha512.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup1Sha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroup1Sha1.cs</Link>
     </Compile>
@@ -1142,6 +1148,15 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroupSha1.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha256.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha256.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha512.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha512.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupShaBase.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupShaBase.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeEC.cs">
       <Link>Security\KeyExchangeEC.cs</Link>
     </Compile>
@@ -1160,6 +1175,9 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeECDH521.cs">
       <Link>Security\KeyExchangeECDH521.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeHash.cs">
+      <Link>Security\KeyExchangeHash.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyHostAlgorithm.cs">
       <Link>Security\KeyHostAlgorithm.cs</Link>
     </Compile>
@@ -1390,7 +1408,7 @@
       <FlavorProperties GUID="{A1591282-1198-4647-A2B1-27E5FF5F6F3B}">
         <SilverlightProjectProperties />
       </FlavorProperties>
-      <UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" />
+      <UserProperties ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
     </VisualStudio>
   </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 49 - 0
src/Renci.SshNet.Tests/Classes/SessionTest.cs

@@ -3,9 +3,11 @@ using System.Globalization;
 using System.Net;
 using System.Net.Sockets;
 using System.Text;
+using System.Threading;
 using Microsoft.VisualStudio.TestTools.UnitTesting;
 using Moq;
 using Renci.SshNet.Common;
+using Renci.SshNet.Messages.Transport;
 using Renci.SshNet.Tests.Common;
 using Renci.SshNet.Tests.Properties;
 
@@ -98,6 +100,53 @@ namespace Renci.SshNet.Tests.Classes
             }
         }
 
+        [TestMethod]
+        public void ConnectShouldImmediatelySendIdentificationStringWhenConnectionHasBeenEstablised()
+        {
+            var serverEndPoint = new IPEndPoint(IPAddress.Loopback, 8122);
+            var connectionInfo = CreateConnectionInfo(serverEndPoint, TimeSpan.FromSeconds(5));
+
+            using (var serverStub = new AsyncSocketListener(serverEndPoint))
+            {
+                serverStub.Connected += socket =>
+                    {
+                        var identificationBytes = new byte[2048];
+                        var bytesReceived = socket.Receive(identificationBytes);
+
+                        if (bytesReceived > 0)
+                        {
+                            var identificationSttring = Encoding.ASCII.GetString(identificationBytes, 0, bytesReceived);
+                            Console.WriteLine("STRING=" + identificationSttring);
+                            Console.WriteLine("DONE");
+
+                            socket.Send(Encoding.ASCII.GetBytes("\r\n"));
+                            socket.Send(Encoding.ASCII.GetBytes("WELCOME banner\r\n"));
+                            socket.Send(Encoding.ASCII.GetBytes("SSH-666-SshStub\r\n"));
+                        }
+
+                        socket.Shutdown(SocketShutdown.Send);
+                    };
+                serverStub.Start();
+
+                using (var session = new Session(connectionInfo, _serviceFactoryMock.Object))
+                {
+                    try
+                    {
+                        session.Connect();
+                        Assert.Fail();
+                    }
+                    catch (SshConnectionException ex)
+                    {
+                        Assert.IsNull(ex.InnerException);
+                        Assert.AreEqual("Server version '666' is not supported.", ex.Message);
+
+                        Assert.AreEqual("SSH-666-SshStub", connectionInfo.ServerVersion);
+                    }
+                }
+            }
+        }
+
+
         [TestMethod]
         public void ConnectShouldSupportProtocolIdentificationStringThatDoesNotEndWithCrlf()
         {

+ 18 - 3
src/Renci.SshNet.UAP10/Renci.SshNet.UAP10.csproj

@@ -867,9 +867,6 @@
     <Compile Include="..\Renci.SshNet\Security\BouncyCastle\util\encoders\HexEncoder.cs">
       <Link>Security\Cryptography\BouncyCastle\util\encoders\HexEncoder.cs</Link>
     </Compile>
-    <Compile Include="..\Renci.SshNet\Security\BouncyCastle\util\Enums.cs">
-      <Link>Security\Cryptography\BouncyCastle\util\Enums.cs</Link>
-    </Compile>
     <Compile Include="..\Renci.SshNet\Security\BouncyCastle\util\IMemoable.cs">
       <Link>Security\Cryptography\BouncyCastle\util\IMemoable.cs</Link>
     </Compile>
@@ -1203,6 +1200,12 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup14Sha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroup14Sha1.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup14Sha256.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroup14Sha256.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup16Sha512.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroup16Sha512.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup1Sha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroup1Sha1.cs</Link>
     </Compile>
@@ -1218,6 +1221,15 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroupSha1.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha256.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha256.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha512.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha512.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupShaBase.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupShaBase.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeEC.cs">
       <Link>Security\KeyExchangeEC.cs</Link>
     </Compile>
@@ -1236,6 +1248,9 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeECDH521.cs">
       <Link>Security\KeyExchangeECDH521.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeHash.cs">
+      <Link>Security\KeyExchangeHash.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyHostAlgorithm.cs">
       <Link>Security\KeyHostAlgorithm.cs</Link>
     </Compile>

+ 18 - 0
src/Renci.SshNet.WindowsPhone/Renci.SshNet.WindowsPhone.csproj

@@ -1106,6 +1106,12 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup14Sha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroup14Sha1.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup14Sha256.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroup14Sha256.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup16Sha512.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroup16Sha512.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup1Sha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroup1Sha1.cs</Link>
     </Compile>
@@ -1121,6 +1127,15 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroupSha1.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha256.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha256.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha512.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha512.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupShaBase.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupShaBase.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeEC.cs">
       <Link>Security\KeyExchangeEC.cs</Link>
     </Compile>
@@ -1139,6 +1154,9 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeECDH521.cs">
       <Link>Security\KeyExchangeECDH521.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeHash.cs">
+      <Link>Security\KeyExchangeHash.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyHostAlgorithm.cs">
       <Link>Security\KeyHostAlgorithm.cs</Link>
     </Compile>

+ 19 - 1
src/Renci.SshNet.WindowsPhone8/Renci.SshNet.WindowsPhone8.csproj

@@ -1159,6 +1159,12 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup14Sha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroup14Sha1.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup14Sha256.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroup14Sha256.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup16Sha512.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroup16Sha512.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroup1Sha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroup1Sha1.cs</Link>
     </Compile>
@@ -1174,6 +1180,15 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha1.cs">
       <Link>Security\KeyExchangeDiffieHellmanGroupSha1.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha256.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha256.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupSha512.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupSha512.cs</Link>
+    </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeDiffieHellmanGroupShaBase.cs">
+      <Link>Security\KeyExchangeDiffieHellmanGroupShaBase.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeEC.cs">
       <Link>Security\KeyExchangeEC.cs</Link>
     </Compile>
@@ -1192,6 +1207,9 @@
     <Compile Include="..\Renci.SshNet\Security\KeyExchangeECDH521.cs">
       <Link>Security\KeyExchangeECDH521.cs</Link>
     </Compile>
+    <Compile Include="..\Renci.SshNet\Security\KeyExchangeHash.cs">
+      <Link>Security\KeyExchangeHash.cs</Link>
+    </Compile>
     <Compile Include="..\Renci.SshNet\Security\KeyHostAlgorithm.cs">
       <Link>Security\KeyHostAlgorithm.cs</Link>
     </Compile>
@@ -1423,7 +1441,7 @@
   <Import Project="$(MSBuildExtensionsPath)\Microsoft\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\Microsoft.$(TargetFrameworkIdentifier).CSharp.targets" />
   <ProjectExtensions>
     <VisualStudio>
-      <UserProperties ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" />
+      <UserProperties ProjectLinkerExcludeFilter="\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$" ProjectLinkReference="2f5f8c90-0bd1-424f-997c-7bc6280919d1" />
     </VisualStudio>
   </ProjectExtensions>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

+ 25 - 24
src/Renci.SshNet/Session.cs

@@ -577,14 +577,14 @@ namespace Renci.SshNet
 
                 lock (this)
                 {
-                    //  If connected don't connect again
+                    // If connected don't connect again
                     if (IsConnected)
                         return;
 
-                    // reset connection specific information
+                    // Reset connection specific information
                     Reset();
 
-                    //  Build list of available messages while connecting
+                    // Build list of available messages while connecting
                     _sshMessageFactory = new SshMessageFactory();
 
                     switch (ConnectionInfo.ProxyType)
@@ -606,10 +606,14 @@ namespace Renci.SshNet
                             break;
                     }
 
+                    // Immediately send the identification string since the spec states both sides MUST send an identification string
+                    // when the connection has been established
+                    SocketAbstraction.Send(_socket, Encoding.UTF8.GetBytes(string.Format(CultureInfo.InvariantCulture, "{0}\x0D\x0A", ClientVersion)));
+
                     Match versionMatch;
 
-                    //  Get server version from the server,
-                    //  ignore text lines which are sent before if any
+                    // Get server version from the server,
+                    // ignore text lines which are sent before if any
                     while (true)
                     {
                         var serverVersion = SocketReadLine(_socket, ConnectionInfo.Timeout);
@@ -623,11 +627,11 @@ namespace Renci.SshNet
                         }
                     }
 
-                    //  Set connection versions
+                    // Set connection versions
                     ConnectionInfo.ServerVersion = ServerVersion;
                     ConnectionInfo.ClientVersion = ClientVersion;
 
-                    //  Get server SSH version
+                    // Get server SSH version
                     var version = versionMatch.Result("${protoversion}");
 
                     var softwareName = versionMatch.Result("${softwareversion}");
@@ -639,9 +643,7 @@ namespace Renci.SshNet
                         throw new SshConnectionException(string.Format(CultureInfo.CurrentCulture, "Server version '{0}' is not supported.", version), DisconnectReason.ProtocolVersionNotSupported);
                     }
 
-                    SocketAbstraction.Send(_socket, Encoding.UTF8.GetBytes(string.Format(CultureInfo.InvariantCulture, "{0}\x0D\x0A", ClientVersion)));
-
-                    //  Register Transport response messages
+                    // Register Transport response messages
                     RegisterMessage("SSH_MSG_DISCONNECT");
                     RegisterMessage("SSH_MSG_IGNORE");
                     RegisterMessage("SSH_MSG_UNIMPLEMENTED");
@@ -650,29 +652,29 @@ namespace Renci.SshNet
                     RegisterMessage("SSH_MSG_KEXINIT");
                     RegisterMessage("SSH_MSG_NEWKEYS");
 
-                    //  Some server implementations might sent this message first, prior establishing encryption algorithm
+                    // Some server implementations might sent this message first, prior to establishing encryption algorithm
                     RegisterMessage("SSH_MSG_USERAUTH_BANNER");
 
-                    // mark the message listener threads as started
+                    // Mark the message listener threads as started
                     _messageListenerCompleted.Reset();
 
-                    //  Start incoming request listener
+                    // Start incoming request listener
                     ThreadAbstraction.ExecuteThread(() => MessageListener());
 
-                    //  Wait for key exchange to be completed
+                    // Wait for key exchange to be completed
                     WaitOnHandle(_keyExchangeCompletedWaitHandle);
 
-                    //  If sessionId is not set then its not connected
+                    // If sessionId is not set then its not connected
                     if (SessionId == null)
                     {
                         Disconnect();
                         return;
                     }
 
-                    //  Request user authorization service
+                    // Request user authorization service
                     SendMessage(new ServiceRequestMessage(ServiceName.UserAuthentication));
 
-                    //  Wait for service to be accepted
+                    // Wait for service to be accepted
                     WaitOnHandle(_serviceAccepted);
 
                     if (string.IsNullOrEmpty(ConnectionInfo.Username))
@@ -687,7 +689,7 @@ namespace Renci.SshNet
                     ConnectionInfo.Authenticate(this, _serviceFactory);
                     _isAuthenticated = true;
 
-                    //  Register Connection messages
+                    // Register Connection messages
                     RegisterMessage("SSH_MSG_REQUEST_SUCCESS");
                     RegisterMessage("SSH_MSG_REQUEST_FAILURE");
                     RegisterMessage("SSH_MSG_CHANNEL_OPEN_CONFIRMATION");
@@ -1935,9 +1937,10 @@ namespace Renci.SshNet
                         break;
                     }
 
+#if FEATURE_SOCKET_POLL || FEATURE_SOCKET_SELECT
                     try
                     {
-    #if FEATURE_SOCKET_POLL
+#if FEATURE_SOCKET_POLL
                         // Block until either data is available or the socket is closed
                         var connectionClosedOrDataAvailable = socket.Poll(-1, SelectMode.SelectRead);
                         if (connectionClosedOrDataAvailable && socket.Available == 0)
@@ -1945,7 +1948,7 @@ namespace Renci.SshNet
                             // connection with SSH server was closed or connection was reset
                             break;
                         }
-    #elif FEATURE_SOCKET_SELECT
+#elif FEATURE_SOCKET_SELECT
                         var readSockets = new List<Socket> { socket };
 
                         // if the socket is already disposed when Select is invoked, then a SocketException
@@ -1981,10 +1984,7 @@ namespace Renci.SshNet
                             // break out of the message loop
                             break;
                         }
-    #else
-                        #error Blocking wait on either socket data to become available or connection to be 
-                        #error closed is not implemented.
-    #endif // FEATURE_SOCKET_SELECT
+#endif // FEATURE_SOCKET_SELECT
                     }
                     catch (ObjectDisposedException)
                     {
@@ -1994,6 +1994,7 @@ namespace Renci.SshNet
                         // * a SSH_MSG_DISCONNECT received from server
                         break;
                     }
+#endif // FEATURE_SOCKET_POLL || FEATURE_SOCKET_SELECT
 
                     var message = ReceiveMessage(socket);
                     if (message == null)