From 70105742d3f74da7fd5e4afe553844d4cf8bcd0d Mon Sep 17 00:00:00 2001 From: olegkap_cp Date: Thu, 25 Aug 2011 14:00:39 +0000 Subject: [PATCH] Add project for future .NET 3.5 support --- .../Channels/ChannelDirectTcpip.NET35.cs | 27 + .../Common/Extensions.NET35.cs | 26 + .../ForwardedPortLocal.NET35.cs | 94 +++ .../ForwardedPortRemote.NET35.cs | 16 + ...KeyboardInteractiveConnectionInfo.NET35.cs | 16 + .../PasswordConnectionInfo.NET35.cs | 16 + .../Properties/AssemblyInfo.cs | 36 + .../Renci.SshNet.NET35.csproj | 710 ++++++++++++++++++ .../Renci.SshNet.NET35.csproj.vspscc | 10 + .../Renci.SshNet.NET35/Session.NET35.cs | 139 ++++ .../Renci.SshNet.NET35/SftpClient.NET35.cs | 16 + .../Renci.SshNet.NET35/Shell.NET35.cs | 16 + .../Renci.SshNet.NET35/SshCommand.NET35.cs | 16 + Renci.SshClient/Renci.SshNet.sln | 29 +- .../Renci.SshNet/Common/SshData.cs | 4 +- .../Messages/Authentication/FailureMessage.cs | 2 +- .../Transport/KeyExchangeInitMessage.cs | 20 +- Renci.SshClient/Renci.SshNet/Session.cs | 16 +- 18 files changed, 1175 insertions(+), 34 deletions(-) create mode 100644 Renci.SshClient/Renci.SshNet.NET35/Channels/ChannelDirectTcpip.NET35.cs create mode 100644 Renci.SshClient/Renci.SshNet.NET35/Common/Extensions.NET35.cs create mode 100644 Renci.SshClient/Renci.SshNet.NET35/ForwardedPortLocal.NET35.cs create mode 100644 Renci.SshClient/Renci.SshNet.NET35/ForwardedPortRemote.NET35.cs create mode 100644 Renci.SshClient/Renci.SshNet.NET35/KeyboardInteractiveConnectionInfo.NET35.cs create mode 100644 Renci.SshClient/Renci.SshNet.NET35/PasswordConnectionInfo.NET35.cs create mode 100644 Renci.SshClient/Renci.SshNet.NET35/Properties/AssemblyInfo.cs create mode 100644 Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj create mode 100644 Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj.vspscc create mode 100644 Renci.SshClient/Renci.SshNet.NET35/Session.NET35.cs create mode 100644 Renci.SshClient/Renci.SshNet.NET35/SftpClient.NET35.cs create mode 100644 Renci.SshClient/Renci.SshNet.NET35/Shell.NET35.cs create mode 100644 Renci.SshClient/Renci.SshNet.NET35/SshCommand.NET35.cs diff --git a/Renci.SshClient/Renci.SshNet.NET35/Channels/ChannelDirectTcpip.NET35.cs b/Renci.SshClient/Renci.SshNet.NET35/Channels/ChannelDirectTcpip.NET35.cs new file mode 100644 index 00000000..9c06f067 --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/Channels/ChannelDirectTcpip.NET35.cs @@ -0,0 +1,27 @@ +using System; +using System.Net.Sockets; +using System.Threading; + +namespace Renci.SshNet.Channels +{ + /// + /// Implements "direct-tcpip" SSH channel. + /// + internal partial class ChannelDirectTcpip + { + partial void ExecuteThread(Action action) + { + ThreadPool.QueueUserWorkItem((o) => { action(); }); + } + + partial void InternalSocketReceive(byte[] buffer, ref int read) + { + read = this._socket.Receive(buffer); + } + + partial void InternalSocketSend(byte[] data) + { + this._socket.Send(data, 0, data.Length, SocketFlags.None); + } + } +} diff --git a/Renci.SshClient/Renci.SshNet.NET35/Common/Extensions.NET35.cs b/Renci.SshClient/Renci.SshNet.NET35/Common/Extensions.NET35.cs new file mode 100644 index 00000000..f7cdd2e8 --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/Common/Extensions.NET35.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Renci.SshNet.Common +{ + public static class ExtensionsNET35 + { + internal static bool IsNullOrWhiteSpace(this string s) + { + if (s == null) + return true; + + for (var i = 0; i < s.Length; i++) + { + if (!char.IsWhiteSpace(s, i)) + { + return false; + } + } + + return true; + } + } +} diff --git a/Renci.SshClient/Renci.SshNet.NET35/ForwardedPortLocal.NET35.cs b/Renci.SshClient/Renci.SshNet.NET35/ForwardedPortLocal.NET35.cs new file mode 100644 index 00000000..86a534fc --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/ForwardedPortLocal.NET35.cs @@ -0,0 +1,94 @@ +using System; +using System.Net.Sockets; +using System.Net; +using System.Threading; +using Renci.SshNet.Channels; + +namespace Renci.SshNet +{ + /// + /// Provides functionality for local port forwarding + /// + public partial class ForwardedPortLocal + { + private TcpListener _listener; + + partial void ExecuteThread(Action action) + { + ThreadPool.QueueUserWorkItem((o) => { action(); }); + } + + partial void InternalStart() + { + // If port already started don't start it again + if (this.IsStarted) + return; + + var ep = new IPEndPoint(Dns.GetHostAddresses(this.BoundHost)[0], (int)this.BoundPort); + + this._listener = new TcpListener(ep); + this._listener.Start(); + + this._listenerTaskCompleted = new ManualResetEvent(false); + this.ExecuteThread(() => + { + try + { + while (true) + { + var socket = this._listener.AcceptSocket(); + + this.ExecuteThread(() => + { + try + { + IPEndPoint originatorEndPoint = socket.RemoteEndPoint as IPEndPoint; + + this.RaiseRequestReceived(originatorEndPoint.Address.ToString(), (uint)originatorEndPoint.Port); + + var channel = this.Session.CreateChannel(); + + channel.Bind(this.Host, this.Port, socket); + } + catch (Exception exp) + { + this.RaiseExceptionEvent(exp); + } + }); + } + } + catch (SocketException exp) + { + if (!(exp.SocketErrorCode == SocketError.Interrupted)) + { + this.RaiseExceptionEvent(exp); + } + } + catch (Exception exp) + { + this.RaiseExceptionEvent(exp); + } + finally + { + this._listenerTaskCompleted.Set(); + } + }); + + this.IsStarted = true; + } + + partial void InternalStop() + { + // If port not started you cant stop it + if (!this.IsStarted) + return; + + this._listener.Stop(); + this._listenerTaskCompleted.WaitOne(this.Session.ConnectionInfo.Timeout); + this._listenerTaskCompleted.Dispose(); + this._listenerTaskCompleted = null; + + this.IsStarted = false; + } + } +} diff --git a/Renci.SshClient/Renci.SshNet.NET35/ForwardedPortRemote.NET35.cs b/Renci.SshClient/Renci.SshNet.NET35/ForwardedPortRemote.NET35.cs new file mode 100644 index 00000000..85dba32c --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/ForwardedPortRemote.NET35.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; + +namespace Renci.SshNet +{ + /// + /// Provides functionality for remote port forwarding + /// + public partial class ForwardedPortRemote + { + partial void ExecuteThread(Action action) + { + ThreadPool.QueueUserWorkItem((o) => { action(); }); + } + } +} diff --git a/Renci.SshClient/Renci.SshNet.NET35/KeyboardInteractiveConnectionInfo.NET35.cs b/Renci.SshClient/Renci.SshNet.NET35/KeyboardInteractiveConnectionInfo.NET35.cs new file mode 100644 index 00000000..c4b7cc9f --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/KeyboardInteractiveConnectionInfo.NET35.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; + +namespace Renci.SshNet +{ + /// + /// Provides connection information when keyboard interactive authentication method is used + /// + public partial class KeyboardInteractiveConnectionInfo + { + partial void ExecuteThread(Action action) + { + ThreadPool.QueueUserWorkItem((o) => { action(); }); + } + } +} diff --git a/Renci.SshClient/Renci.SshNet.NET35/PasswordConnectionInfo.NET35.cs b/Renci.SshClient/Renci.SshNet.NET35/PasswordConnectionInfo.NET35.cs new file mode 100644 index 00000000..430bca78 --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/PasswordConnectionInfo.NET35.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; + +namespace Renci.SshNet +{ + /// + /// Provides connection information when password authentication method is used + /// + public partial class PasswordConnectionInfo + { + partial void ExecuteThread(Action action) + { + ThreadPool.QueueUserWorkItem((o) => { action(); }); + } + } +} diff --git a/Renci.SshClient/Renci.SshNet.NET35/Properties/AssemblyInfo.cs b/Renci.SshClient/Renci.SshNet.NET35/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..7562d1ac --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Renci.SshNet.NET35")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Renci.SshNet.NET35")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("a9698831-4993-469b-81f1-aed4e5379252")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj b/Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj new file mode 100644 index 00000000..376022e7 --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj @@ -0,0 +1,710 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {DD1C552F-7F48-4269-ABB3-2E4C89B7E43A} + Library + Properties + Renci.SshNet.NET35 + Renci.SshNet.NET35 + v3.5 + 512 + SAK + SAK + SAK + SAK + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + BaseClient.cs + + + ChannelAsyncResult.cs + + + Channels\Channel.cs + + + Channels\ChannelDirectTcpip.cs + + + Channels\ChannelForwardedTcpip.cs + + + Channels\ChannelForwardedTcpip.NET40.cs + + + Channels\ChannelSession.cs + + + Channels\ChannelTypes.cs + + + CipherInfo.cs + + + Common\ASCIIEncoding.cs + + + Common\ASCIIEncoding.NET40.cs + + + Common\AsyncResult.cs + + + Common\AuthenticationBannerEventArgs.cs + + + Common\AuthenticationEventArgs.cs + + + Common\AuthenticationPasswordChangeEventArgs.cs + + + Common\AuthenticationPrompt.cs + + + Common\AuthenticationPromptEventArgs.cs + + + Common\BigInteger.cs + + + Common\ChannelDataEventArgs.cs + + + Common\ChannelEventArgs.cs + + + Common\ChannelOpenFailedEventArgs.cs + + + Common\ChannelRequestEventArgs.cs + + + Common\DerData.cs + + + Common\ExceptionEventArgs.cs + + + Common\Extensions.cs + + + Common\ObjectIdentifier.cs + + + Common\PipeStream.cs + + + Common\PortForwardEventArgs.cs + + + Common\SemaphoreLight.cs + + + Common\SftpPathNotFoundException.cs + + + Common\SftpPathNotFoundException.NET40.cs + + + Common\SftpPermissionDeniedException.cs + + + Common\SftpPermissionDeniedException.NET40.cs + + + Common\SshAuthenticationException.cs + + + Common\SshAuthenticationException.NET40.cs + + + Common\SshConnectionException.cs + + + Common\SshConnectionException.NET40.cs + + + Common\SshData.cs + + + Common\SshException.cs + + + Common\SshException.NET40.cs + + + Common\SshOperationTimeoutException.cs + + + Common\SshOperationTimeoutException.NET40.cs + + + Common\SshPassPhraseNullOrEmptyException.cs + + + Common\SshPassPhraseNullOrEmptyException.NET40.cs + + + Compression\Compressor.cs + + + Compression\Zlib.cs + + + Compression\ZlibOpenSsh.cs + + + ConnectionInfo.cs + + + ForwardedPort.cs + + + ForwardedPortLocal.cs + + + ForwardedPortRemote.cs + + + KeyboardInteractiveConnectionInfo.cs + + + MessageEventArgs.cs + + + Messages\Authentication\BannerMessage.cs + + + Messages\Authentication\FailureMessage.cs + + + Messages\Authentication\InformationRequestMessage.cs + + + Messages\Authentication\InformationResponseMessage.cs + + + Messages\Authentication\PasswordChangeRequiredMessage.cs + + + Messages\Authentication\PublicKeyMessage.cs + + + Messages\Authentication\RequestMessage.cs + + + Messages\Authentication\RequestMessageHost.cs + + + Messages\Authentication\RequestMessageKeyboardInteractive.cs + + + Messages\Authentication\RequestMessageNone.cs + + + Messages\Authentication\RequestMessagePassword.cs + + + Messages\Authentication\RequestMessagePublicKey.cs + + + Messages\Authentication\SuccessMessage.cs + + + Messages\Connection\ChannelCloseMessage.cs + + + Messages\Connection\ChannelDataMessage.cs + + + Messages\Connection\ChannelEofMessage.cs + + + Messages\Connection\ChannelExtendedDataMessage.cs + + + Messages\Connection\ChannelFailureMessage.cs + + + Messages\Connection\ChannelMessage.cs + + + Messages\Connection\ChannelOpenConfirmationMessage.cs + + + Messages\Connection\ChannelOpenFailureMessage.cs + + + Messages\Connection\ChannelOpenFailureReasons.cs + + + Messages\Connection\ChannelOpen\ChannelOpenInfo.cs + + + Messages\Connection\ChannelOpen\ChannelOpenMessage.cs + + + Messages\Connection\ChannelOpen\DirectTcpipChannelInfo.cs + + + Messages\Connection\ChannelOpen\ForwardedTcpipChannelInfo.cs + + + Messages\Connection\ChannelOpen\SessionChannelOpenInfo.cs + + + Messages\Connection\ChannelOpen\X11ChannelOpenInfo.cs + + + Messages\Connection\ChannelRequest\ChannelRequestMessage.cs + + + Messages\Connection\ChannelRequest\EndOfWriteRequestInfo.cs + + + Messages\Connection\ChannelRequest\EnvironmentVariableRequestInfo.cs + + + Messages\Connection\ChannelRequest\ExecRequestInfo.cs + + + Messages\Connection\ChannelRequest\ExitSignalRequestInfo.cs + + + Messages\Connection\ChannelRequest\ExitStatusRequestInfo.cs + + + Messages\Connection\ChannelRequest\KeepAliveRequestInfo.cs + + + Messages\Connection\ChannelRequest\PseudoTerminalInfo.cs + + + Messages\Connection\ChannelRequest\RequestInfo.cs + + + Messages\Connection\ChannelRequest\ShellRequestInfo.cs + + + Messages\Connection\ChannelRequest\SignalRequestInfo.cs + + + Messages\Connection\ChannelRequest\SubsystemRequestInfo.cs + + + Messages\Connection\ChannelRequest\WindowChangeRequestInfo.cs + + + Messages\Connection\ChannelRequest\X11ForwardingRequestInfo.cs + + + Messages\Connection\ChannelRequest\XonXoffRequestInfo.cs + + + Messages\Connection\ChannelSuccessMessage.cs + + + Messages\Connection\ChannelWindowAdjustMessage.cs + + + Messages\Connection\GlobalRequestMessage.cs + + + Messages\Connection\GlobalRequestName.cs + + + Messages\Connection\RequestFailureMessage.cs + + + Messages\Connection\RequestSuccessMessage.cs + + + Messages\Message.cs + + + Messages\MessageAttribute.cs + + + Messages\ServiceName.cs + + + Messages\Transport\DebugMessage.cs + + + Messages\Transport\DisconnectMessage.cs + + + Messages\Transport\DisconnectReason.cs + + + Messages\Transport\IgnoreMessage.cs + + + Messages\Transport\KeyExchangeDhGroupExchangeGroup.cs + + + Messages\Transport\KeyExchangeDhGroupExchangeInit.cs + + + Messages\Transport\KeyExchangeDhGroupExchangeReply.cs + + + Messages\Transport\KeyExchangeDhGroupExchangeRequest.cs + + + Messages\Transport\KeyExchangeDhInitMessage.cs + + + Messages\Transport\KeyExchangeDhReplyMessage.cs + + + Messages\Transport\KeyExchangeInitMessage.cs + + + Messages\Transport\NewKeysMessage.cs + + + Messages\Transport\ServiceAcceptMessage.cs + + + Messages\Transport\ServiceRequestMessage.cs + + + Messages\Transport\UnimplementedMessage.cs + + + NoneConnectionInfo.cs + + + PasswordConnectionInfo.cs + + + PrivateKeyConnectionInfo.cs + + + PrivateKeyFile.cs + + + Security\Algorithm.cs + + + Security\CertificateHostAlgorithm.cs + + + Security\Cryptography\AsymmetricCipher.cs + + + Security\Cryptography\BlockCipher.cs + + + Security\Cryptography\Cipher.cs + + + Security\Cryptography\CipherDigitalSignature.cs + + + Security\Cryptography\Ciphers\AesCipher.cs + + + Security\Cryptography\Ciphers\Arc4Cipher.cs + + + Security\Cryptography\Ciphers\BlowfishCipher.cs + + + Security\Cryptography\Ciphers\CastCipher.cs + + + Security\Cryptography\Ciphers\CipherBase.cs + + + Security\Cryptography\Ciphers\CipherMode.cs + + + Security\Cryptography\Ciphers\CipherPadding.cs + + + Security\Cryptography\Ciphers\DesCipher.cs + + + Security\Cryptography\Ciphers\Modes\CbcCipherMode.cs + + + Security\Cryptography\Ciphers\Modes\CfbCipherMode.cs + + + Security\Cryptography\Ciphers\Modes\CtrCipherMode.cs + + + Security\Cryptography\Ciphers\Modes\OfbCipherMode.cs + + + Security\Cryptography\Ciphers\Paddings\PKCS7Padding.cs + + + Security\Cryptography\Ciphers\RsaCipher.cs + + + Security\Cryptography\Ciphers\SerpentCipher.cs + + + Security\Cryptography\Ciphers\TripleDesCipher.cs + + + Security\Cryptography\Ciphers\TwofishCipher.cs + + + Security\Cryptography\DigitalSignature.cs + + + Security\Cryptography\DsaDigitalSignature.cs + + + Security\Cryptography\DsaKey.cs + + + Security\Cryptography\Hashes\MD5Hash.cs + + + Security\Cryptography\Hashes\SHA1Hash.cs + + + Security\Cryptography\Hashes\SHA256Hash.cs + + + Security\Cryptography\HMac.cs + + + Security\Cryptography\Key.cs + + + Security\Cryptography\RsaDigitalSignature.cs + + + Security\Cryptography\RsaKey.cs + + + Security\Cryptography\StreamCipher.cs + + + Security\Cryptography\SymmetricCipher.cs + + + Security\HostAlgorithm.cs + + + Security\KeyExchange.cs + + + Security\KeyExchangeDiffieHellman.cs + + + Security\KeyExchangeDiffieHellmanGroup14Sha1.cs + + + Security\KeyExchangeDiffieHellmanGroup1Sha1.cs + + + Security\KeyExchangeDiffieHellmanGroupExchangeSha1.cs + + + Security\KeyExchangeDiffieHellmanGroupExchangeSha256.cs + + + Security\KeyHostAlgorithm.cs + + + Session.cs + + + SftpClient.cs + + + Sftp\Flags.cs + + + Sftp\Requests\SftpCloseRequest.cs + + + Sftp\Requests\SftpFSetStatRequest.cs + + + Sftp\Requests\SftpFStatRequest.cs + + + Sftp\Requests\SftpInitRequest.cs + + + Sftp\Requests\SftpLStatRequest.cs + + + Sftp\Requests\SftpMkDirRequest.cs + + + Sftp\Requests\SftpOpenDirRequest.cs + + + Sftp\Requests\SftpOpenRequest.cs + + + Sftp\Requests\SftpReadDirRequest.cs + + + Sftp\Requests\SftpReadLinkRequest.cs + + + Sftp\Requests\SftpReadRequest.cs + + + Sftp\Requests\SftpRealPathRequest.cs + + + Sftp\Requests\SftpRemoveRequest.cs + + + Sftp\Requests\SftpRenameRequest.cs + + + Sftp\Requests\SftpRequest.cs + + + Sftp\Requests\SftpRmDirRequest.cs + + + Sftp\Requests\SftpSetStatRequest.cs + + + Sftp\Requests\SftpStatRequest.cs + + + Sftp\Requests\SftpSymLinkRequest.cs + + + Sftp\Requests\SftpWriteRequest.cs + + + Sftp\Responses\SftpAttrsResponse.cs + + + Sftp\Responses\SftpDataResponse.cs + + + Sftp\Responses\SftpExtendedReplyResponse.cs + + + Sftp\Responses\SftpHandleResponse.cs + + + Sftp\Responses\SftpNameResponse.cs + + + Sftp\Responses\SftpResponse.cs + + + Sftp\Responses\SftpStatusResponse.cs + + + Sftp\Responses\SftpVersionResponse.cs + + + Sftp\SftpDataMessage.cs + + + Sftp\SftpDownloadAsyncResult.cs + + + Sftp\SftpFile.cs + + + Sftp\SftpFileAttributes.cs + + + Sftp\SftpFileStream.cs + + + Sftp\SftpListDirectoryAsyncResult.cs + + + Sftp\SftpMessage.cs + + + Sftp\SftpMessageTypes.cs + + + Sftp\SftpSession.cs + + + Sftp\SftpUploadAsyncResult.cs + + + Sftp\StatusCodes.cs + + + Shell.cs + + + SshClient.cs + + + SshCommand.cs + + + SubsystemSession.cs + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj.vspscc b/Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj.vspscc new file mode 100644 index 00000000..feffdeca --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/Renci.SshNet.NET35.csproj.vspscc @@ -0,0 +1,10 @@ +"" +{ +"FILE_VERSION" = "9237" +"ENLISTMENT_CHOICE" = "NEVER" +"PROJECT_FILE_RELATIVE_PATH" = "" +"NUMBER_OF_EXCLUDED_FILES" = "0" +"ORIGINAL_PROJECT_FILE_PATH" = "" +"NUMBER_OF_NESTED_PROJECTS" = "0" +"SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" +} diff --git a/Renci.SshClient/Renci.SshNet.NET35/Session.NET35.cs b/Renci.SshClient/Renci.SshNet.NET35/Session.NET35.cs new file mode 100644 index 00000000..871880f9 --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/Session.NET35.cs @@ -0,0 +1,139 @@ +using System.Linq; +using System; +using System.Net.Sockets; +using System.Net; +using Renci.SshNet.Messages; +using Renci.SshNet.Common; +using System.Threading; +using Renci.SshNet.Messages.Transport; + +namespace Renci.SshNet +{ + /// + /// Provides functionality to connect and interact with SSH server. + /// + public partial class Session + { + partial void ExecuteThread(Action action) + { + ThreadPool.QueueUserWorkItem((o) => { action(); }); + } + + partial void InternalRegisterMessage(string messageName) + { + lock (this._messagesMetadata) + { + foreach (var m in from m in this._messagesMetadata where m.Name == messageName select m) + { + m.Enabled = true; + m.Activated = true; + } + } + } + + partial void InternalUnRegisterMessage(string messageName) + { + lock (this._messagesMetadata) + { + foreach (var m in from m in this._messagesMetadata where m.Name == messageName select m) + { + m.Enabled = false; + m.Activated = false; + } + } + } + + partial void OpenSocket() + { + var ep = new IPEndPoint(Dns.GetHostAddresses(this.ConnectionInfo.Host)[0], this.ConnectionInfo.Port); + this._socket = new Socket(ep.AddressFamily, SocketType.Stream, ProtocolType.Tcp); + + var socketBufferSize = 2 * MAXIMUM_PACKET_SIZE; + + this._socket.SetSocketOption(SocketOptionLevel.Tcp, SocketOptionName.NoDelay, true); + this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, socketBufferSize); + this._socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, socketBufferSize); + + + // Connect socket with 5 seconds timeout + var connectResult = this._socket.BeginConnect(ep, null, null); + + connectResult.AsyncWaitHandle.WaitOne(this.ConnectionInfo.Timeout); + + // Build list of available messages while connecting + this._messagesMetadata = (from type in this.GetType().Assembly.GetTypes() + from messageAttribute in type.GetCustomAttributes(false).OfType() + select new MessageMetadata + { + Name = messageAttribute.Name, + Number = messageAttribute.Number, + Enabled = false, + Activated = false, + Type = type, + }).ToList(); + + this._socket.EndConnect(connectResult); + } + + partial void InternalRead(int length, ref byte[] buffer) + { + var offset = 0; + int receivedTotal = 0; // how many bytes is already received + + do + { + try + { + var receivedBytes = this._socket.Receive(buffer, offset + receivedTotal, length - receivedTotal, SocketFlags.None); + if (receivedBytes > 0) + { + receivedTotal += receivedBytes; + continue; + } + else + { + throw new SshConnectionException("An established connection was aborted by the software in your host machine.", DisconnectReason.ConnectionLost); + } + } + catch (SocketException exp) + { + if (exp.SocketErrorCode == SocketError.WouldBlock || + exp.SocketErrorCode == SocketError.IOPending || + exp.SocketErrorCode == SocketError.NoBufferSpaceAvailable) + { + // socket buffer is probably empty, wait and try again + Thread.Sleep(30); + } + else + throw; // any serious error occurred + } + } while (receivedTotal < length); + } + + partial void Write(byte[] data) + { + int sent = 0; // how many bytes is already sent + int length = data.Length; + + do + { + try + { + sent += this._socket.Send(data, sent, length - sent, SocketFlags.None); + } + catch (SocketException ex) + { + if (ex.SocketErrorCode == SocketError.WouldBlock || + ex.SocketErrorCode == SocketError.IOPending || + ex.SocketErrorCode == SocketError.NoBufferSpaceAvailable) + { + // socket buffer is probably full, wait and try again + Thread.Sleep(30); + } + else + throw; // any serious error occurr + } + } while (sent < length); + } + } +} diff --git a/Renci.SshClient/Renci.SshNet.NET35/SftpClient.NET35.cs b/Renci.SshClient/Renci.SshNet.NET35/SftpClient.NET35.cs new file mode 100644 index 00000000..0b8ef313 --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/SftpClient.NET35.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; + +namespace Renci.SshNet +{ + /// + /// + /// + public partial class SftpClient + { + partial void ExecuteThread(Action action) + { + ThreadPool.QueueUserWorkItem((o) => { action(); }); + } + } +} \ No newline at end of file diff --git a/Renci.SshClient/Renci.SshNet.NET35/Shell.NET35.cs b/Renci.SshClient/Renci.SshNet.NET35/Shell.NET35.cs new file mode 100644 index 00000000..a6004581 --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/Shell.NET35.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; + +namespace Renci.SshNet +{ + /// + /// Represents instance of the SSH shell object + /// + public partial class Shell + { + partial void ExecuteThread(Action action) + { + ThreadPool.QueueUserWorkItem((o) => { action(); }); + } + } +} diff --git a/Renci.SshClient/Renci.SshNet.NET35/SshCommand.NET35.cs b/Renci.SshClient/Renci.SshNet.NET35/SshCommand.NET35.cs new file mode 100644 index 00000000..5ae6fe58 --- /dev/null +++ b/Renci.SshClient/Renci.SshNet.NET35/SshCommand.NET35.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading; + +namespace Renci.SshNet +{ + /// + /// Represents SSH command that can be executed. + /// + public partial class SshCommand + { + partial void ExecuteThread(Action action) + { + ThreadPool.QueueUserWorkItem((o) => { action(); }); + } + } +} diff --git a/Renci.SshClient/Renci.SshNet.sln b/Renci.SshClient/Renci.SshNet.sln index 7b0902c0..13a164d6 100644 --- a/Renci.SshClient/Renci.SshNet.sln +++ b/Renci.SshClient/Renci.SshNet.sln @@ -11,11 +11,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Renci.SshNet.Silverlight", "Renci.SshNet.Silverlight\Renci.SshNet.Silverlight.csproj", "{77C294BB-1DC2-49DC-BE16-963F8F22794D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.Web", "Test.Web\Test.Web.csproj", "{1A1BAB9E-0DAD-4171-A979-6F2F221E3C28}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Renci.SshNet.NET35", "Renci.SshNet.NET35\Renci.SshNet.NET35.csproj", "{DD1C552F-7F48-4269-ABB3-2E4C89B7E43A}" EndProject Global GlobalSection(TeamFoundationVersionControl) = preSolution - SccNumberOfProjects = 4 + SccNumberOfProjects = 5 SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs11 SccLocalPath0 = . @@ -28,9 +28,12 @@ Global SccProjectUniqueName3 = Renci.SshNet.Silverlight\\Renci.SshNet.Silverlight.csproj SccProjectName3 = Renci.SshNet.Silverlight SccLocalPath3 = Renci.SshNet.Silverlight + SccProjectUniqueName4 = Renci.SshNet.NET35\\Renci.SshNet.NET35.csproj + SccProjectName4 = Renci.SshNet.NET35 + SccLocalPath4 = Renci.SshNet.NET35 EndGlobalSection GlobalSection(TestCaseManagementSettings) = postSolution - CategoryFile = Renci.SshNet.vsmdi + CategoryFile = Renci.SshNet1.vsmdi EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -81,16 +84,16 @@ Global {77C294BB-1DC2-49DC-BE16-963F8F22794D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {77C294BB-1DC2-49DC-BE16-963F8F22794D}.Release|Mixed Platforms.Build.0 = Release|Any CPU {77C294BB-1DC2-49DC-BE16-963F8F22794D}.Release|x86.ActiveCfg = Release|Any CPU - {1A1BAB9E-0DAD-4171-A979-6F2F221E3C28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1A1BAB9E-0DAD-4171-A979-6F2F221E3C28}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1A1BAB9E-0DAD-4171-A979-6F2F221E3C28}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {1A1BAB9E-0DAD-4171-A979-6F2F221E3C28}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {1A1BAB9E-0DAD-4171-A979-6F2F221E3C28}.Debug|x86.ActiveCfg = Debug|Any CPU - {1A1BAB9E-0DAD-4171-A979-6F2F221E3C28}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1A1BAB9E-0DAD-4171-A979-6F2F221E3C28}.Release|Any CPU.Build.0 = Release|Any CPU - {1A1BAB9E-0DAD-4171-A979-6F2F221E3C28}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {1A1BAB9E-0DAD-4171-A979-6F2F221E3C28}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {1A1BAB9E-0DAD-4171-A979-6F2F221E3C28}.Release|x86.ActiveCfg = Release|Any CPU + {DD1C552F-7F48-4269-ABB3-2E4C89B7E43A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD1C552F-7F48-4269-ABB3-2E4C89B7E43A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD1C552F-7F48-4269-ABB3-2E4C89B7E43A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {DD1C552F-7F48-4269-ABB3-2E4C89B7E43A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {DD1C552F-7F48-4269-ABB3-2E4C89B7E43A}.Debug|x86.ActiveCfg = Debug|Any CPU + {DD1C552F-7F48-4269-ABB3-2E4C89B7E43A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD1C552F-7F48-4269-ABB3-2E4C89B7E43A}.Release|Any CPU.Build.0 = Release|Any CPU + {DD1C552F-7F48-4269-ABB3-2E4C89B7E43A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {DD1C552F-7F48-4269-ABB3-2E4C89B7E43A}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {DD1C552F-7F48-4269-ABB3-2E4C89B7E43A}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Renci.SshClient/Renci.SshNet/Common/SshData.cs b/Renci.SshClient/Renci.SshNet/Common/SshData.cs index 5633360d..af6172bb 100644 --- a/Renci.SshClient/Renci.SshNet/Common/SshData.cs +++ b/Renci.SshClient/Renci.SshNet/Common/SshData.cs @@ -256,7 +256,7 @@ namespace Renci.SshNet.Common /// Reads next name-list data type from internal buffer. /// /// - protected IEnumerable ReadNamesList() + protected string[] ReadNamesList() { var namesList = this.ReadString(); return namesList.Split(','); @@ -402,7 +402,7 @@ namespace Renci.SshNet.Common /// Writes name-list data into internal buffer. /// /// name-list data to write. - protected void Write(IEnumerable data) + protected void Write(string[] data) { this.Write(string.Join(",", data)); } diff --git a/Renci.SshClient/Renci.SshNet/Messages/Authentication/FailureMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Authentication/FailureMessage.cs index cce568f4..a8cce50d 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Authentication/FailureMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Authentication/FailureMessage.cs @@ -15,7 +15,7 @@ namespace Renci.SshNet.Messages.Authentication /// /// The allowed authentications. /// - public IEnumerable AllowedAuthentications { get; set; } + public string[] AllowedAuthentications { get; set; } /// /// Gets failure message. diff --git a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeInitMessage.cs b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeInitMessage.cs index 567ca2b9..88578e6f 100644 --- a/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeInitMessage.cs +++ b/Renci.SshClient/Renci.SshNet/Messages/Transport/KeyExchangeInitMessage.cs @@ -35,7 +35,7 @@ namespace Renci.SshNet.Messages.Transport /// /// Supported key exchange algorithms. /// - public IEnumerable KeyExchangeAlgorithms { get; set; } + public string[] KeyExchangeAlgorithms { get; set; } /// /// Gets or sets supported server host key algorithms. @@ -43,7 +43,7 @@ namespace Renci.SshNet.Messages.Transport /// /// Supported server host key algorithms. /// - public IEnumerable ServerHostKeyAlgorithms { get; set; } + public string[] ServerHostKeyAlgorithms { get; set; } /// /// Gets or sets supported encryption algorithms client to server. @@ -51,7 +51,7 @@ namespace Renci.SshNet.Messages.Transport /// /// Supported encryption algorithms client to server. /// - public IEnumerable EncryptionAlgorithmsClientToServer { get; set; } + public string[] EncryptionAlgorithmsClientToServer { get; set; } /// /// Gets or sets supported encryption algorithms server to client. @@ -59,7 +59,7 @@ namespace Renci.SshNet.Messages.Transport /// /// Supported encryption algorithms server to client. /// - public IEnumerable EncryptionAlgorithmsServerToClient { get; set; } + public string[] EncryptionAlgorithmsServerToClient { get; set; } /// /// Gets or sets supported hash algorithms client to server. @@ -67,7 +67,7 @@ namespace Renci.SshNet.Messages.Transport /// /// Supported hash algorithms client to server. /// - public IEnumerable MacAlgorithmsClientToServer { get; set; } + public string[] MacAlgorithmsClientToServer { get; set; } /// /// Gets or sets supported hash algorithms server to client. @@ -75,7 +75,7 @@ namespace Renci.SshNet.Messages.Transport /// /// Supported hash algorithms server to client. /// - public IEnumerable MacAlgorithmsServerToClient { get; set; } + public string[] MacAlgorithmsServerToClient { get; set; } /// /// Gets or sets supported compression algorithms client to server. @@ -83,7 +83,7 @@ namespace Renci.SshNet.Messages.Transport /// /// Supported compression algorithms client to server. /// - public IEnumerable CompressionAlgorithmsClientToServer { get; set; } + public string[] CompressionAlgorithmsClientToServer { get; set; } /// /// Gets or sets supported compression algorithms server to client. @@ -91,7 +91,7 @@ namespace Renci.SshNet.Messages.Transport /// /// Supported compression algorithms server to client. /// - public IEnumerable CompressionAlgorithmsServerToClient { get; set; } + public string[] CompressionAlgorithmsServerToClient { get; set; } /// /// Gets or sets supported languages client to server. @@ -99,7 +99,7 @@ namespace Renci.SshNet.Messages.Transport /// /// Supported languages client to server. /// - public IEnumerable LanguagesClientToServer { get; set; } + public string[] LanguagesClientToServer { get; set; } /// /// Gets or sets supported languages server to client. @@ -107,7 +107,7 @@ namespace Renci.SshNet.Messages.Transport /// /// The languages server to client. /// - public IEnumerable LanguagesServerToClient { get; set; } + public string[] LanguagesServerToClient { get; set; } /// /// Gets or sets a value indicating whether first key exchange packet follows. diff --git a/Renci.SshClient/Renci.SshNet/Session.cs b/Renci.SshClient/Renci.SshNet/Session.cs index 93befe87..305f7deb 100644 --- a/Renci.SshClient/Renci.SshNet/Session.cs +++ b/Renci.SshClient/Renci.SshNet/Session.cs @@ -201,14 +201,14 @@ namespace Renci.SshNet { this._clientInitMessage = new KeyExchangeInitMessage() { - KeyExchangeAlgorithms = this.ConnectionInfo.KeyExchangeAlgorithms.Keys, - ServerHostKeyAlgorithms = this.ConnectionInfo.HostKeyAlgorithms.Keys, - EncryptionAlgorithmsClientToServer = this.ConnectionInfo.Encryptions.Keys, - EncryptionAlgorithmsServerToClient = this.ConnectionInfo.Encryptions.Keys, - MacAlgorithmsClientToServer = this.ConnectionInfo.HmacAlgorithms.Keys, - MacAlgorithmsServerToClient = this.ConnectionInfo.HmacAlgorithms.Keys, - CompressionAlgorithmsClientToServer = this.ConnectionInfo.CompressionAlgorithms.Keys, - CompressionAlgorithmsServerToClient = this.ConnectionInfo.CompressionAlgorithms.Keys, + KeyExchangeAlgorithms = this.ConnectionInfo.KeyExchangeAlgorithms.Keys.ToArray(), + ServerHostKeyAlgorithms = this.ConnectionInfo.HostKeyAlgorithms.Keys.ToArray(), + EncryptionAlgorithmsClientToServer = this.ConnectionInfo.Encryptions.Keys.ToArray(), + EncryptionAlgorithmsServerToClient = this.ConnectionInfo.Encryptions.Keys.ToArray(), + MacAlgorithmsClientToServer = this.ConnectionInfo.HmacAlgorithms.Keys.ToArray(), + MacAlgorithmsServerToClient = this.ConnectionInfo.HmacAlgorithms.Keys.ToArray(), + CompressionAlgorithmsClientToServer = this.ConnectionInfo.CompressionAlgorithms.Keys.ToArray(), + CompressionAlgorithmsServerToClient = this.ConnectionInfo.CompressionAlgorithms.Keys.ToArray(), LanguagesClientToServer = new string[] { string.Empty }, LanguagesServerToClient = new string[] { string.Empty }, FirstKexPacketFollows = false,