* Removed DataTypeCode from ChannelDataEventArgs, as this is specific to extended data.
* Large set of optimizations in receive and send of SSH messages:
- removed several buffer copies
- modified most of the SSH messages to allow the size of the message to be calculated in advance to eliminate need to resize buffer.
- added Compress(byte[] data, int offset, int length) overload to Compressor to compress part of a given buffer thereby avoiding need for buffer copy.
- added Encrypt(byte[] data, int offset, int length) overload to Cipher to encrypt part of a given buffer thereby avoiding need for buffer copy.
* SshData:
- SshData.GetBytes uses a SshDataStream which has a capacity that (in almost all cases) matches the size of the SSH message.
- Added a Load(byte[] value, int offset) overload.
- Added a LoadBytes(byte[] bytes, int offset) overload.
- Added a Write(byte[] data) overload.
- Added a Write(byte[] buffer, int offset, int count) overload.
* Added SendData(byte[] data, int offset, int size) overload to Channel to allow sending part of a given buffer.
This avoids a buffer copy in ScpClient, SftpClient, Shell, ChannelDirectTcpip, ChannelForwardedTcpip.
Fixes issue #1516.
All optimization changes above are only active when the TUNING conditional compilation symbol is defined.
By default, this symbol is defined.
Use TrySendMessage to send SSH_MSG_DISCONNECT, SSH_MSG_CHANNEL_EOF, SSH_MSG_CHANNEL_CLOSE and SSH_MSG_IGNORE messages to avoid throwing exceptions while closing/disposing or sending keep-alive messages.
Avoid sending multiple keep-alive messages concurrently for the same client.
Fixed regression in multi-factor authentication.
* Only send SSH_MSG_CHANNEL_EOF message to remote party when we haven't received a SSH_MSG_CHANNEL_EOF or SSH_MSG_CHANNEL_CLOSE message from the remote party.
* Move logic for sending SSH_MSG_CHANNEL_EOF message from derived classes and client classes into Channel.Close(bool) method.
* Move initialization to ctor.
ChannelSession:
* Avoid leaking session semaphores.
SftpFileStream:
* Modify CanRead, CanWrite and CanSeek to return false when the stream is disposed.
* Modify other public members to throw ObjectDisposedException when the stream is disposed or the SFTP session is no longer open.
* Modify Dispose to only flush the write buffer and/or close the SFTP file handle when the SFTP session is open.
* No longer flush write buffer or close SFTP file handle in finalizer. Fixes issue #2013.
Session:
* Remove CreateClientChannel<T> and CreateServerChannel<T> methods; use specific constructors of channels instead.
SftpClient:
* BufferSize was not used for AppendText(String, Encoding) and Create(String) overloads.
SubsystemSession:
* Added IsOpen property.
* Throw ObjectDisposedException in all public members - except for IsOpen - when the session is disposed.
* Throw InvalidOperationException in all public members - except for Connect and IsOpen - when the session is not open.
* Modify Disconnect to release managed resources that are linked to the connected session.
* Modify Dispose to use Disconnect to managed resources that are linked to the connected session.
Unit tests:
* Added large set of tests for changes listed above.
* Tests for which the code was automatically, and that are not yet correctly implemented, are now marked as Ignore.
* Tests that require a (specifically configured) running SSH server are now marked with test category "integration".
The SSH_MSG_CHANNEL_EOF message is now only sent from Close(bool), and we now only ever wait for an SSH_MSG_CHANNEL_CLOSE message once the client has shut down.
The SSH_MSG_CHANNEL_EOF which is sent by the server is now only used to interrupt the blocking receive on the client socket, and close it.